diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-18 15:35:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-18 15:35:45 +0200 |
commit | 6280033ac4d3d3646c4c512a1c852c9c8f088f80 (patch) | |
tree | 29d61def865015dca6f1f5f820f0ae7de5904bf8 /cli/context.cxx | |
parent | 6dc69580d6101fb1adb1733dad11b5f5ab5fc831 (diff) |
Add support for ANSI colorization of usage output
Diffstat (limited to 'cli/context.cxx')
-rw-r--r-- | cli/context.cxx | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/cli/context.cxx b/cli/context.cxx index d41bb3c..7459406 100644 --- a/cli/context.cxx +++ b/cli/context.cxx @@ -614,8 +614,23 @@ format_line (output_type ot, string& r, const char* s, size_t n) { case ot_plain: { - if (b & code) - r += "'"; + if ((b & link) == 0) + { + if (options.ansi_color ()) + { + if (b & bold) + r += "\033[1m"; + + if (b & itlc) + r += "\033[4m"; + } + else + { + if (b & code) + r += "'"; + } + } + break; } case ot_html: @@ -713,8 +728,25 @@ format_line (output_type ot, string& r, const char* s, size_t n) } else { - if (b & code) - r += "'"; + if (options.ansi_color ()) + { + // While there are codes to turn off bold (22) and + // underline (24), it is not clear how widely they + // are supported. + // + r += "\033[0m"; // Clear all. + + if (eb & bold) + r += "\033[1m"; + + if (eb & itlc) + r += "\033[4m"; + } + else + { + if (b & code) + r += "'"; + } } break; |