Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using special enter/leave stderr escape sequence on DomTerm #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

stderr in red.

This fork adds improved support for [DomTerm](https://domterm.org):
If the `DOMTERM` environment variable is set, emits the DomTerm-specfic
escape sequendes for entering/exiting stderr. This works better if there
are other escape sequences in stderr; it also allows more flexible styling.

## About

stderred hooks on write() and a family of stream functions (fwrite, fprintf,
Expand Down
7 changes: 6 additions & 1 deletion src/stderred.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ __attribute__((constructor)) void init() {

start_color_code = getenv("STDERRED_ESC_CODE");
if (start_color_code == NULL) {
start_color_code = "\x1b[31m";
bool isDomTerm = getenv("DOMTERM") != NULL;
if (isDomTerm) {
start_color_code = "\033[12u";
end_color_code = "\033[11u";
} else
start_color_code = "\x1b[31m";
}
start_color_code_size = strlen(start_color_code);
end_color_code_size = strlen(end_color_code);
Expand Down