diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-23 11:57:46 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-23 11:57:46 +0200 |
commit | d31a0fea0b5ea2a914b15831772ac2d5b0c93824 (patch) | |
tree | ed2838483fe834cc6fcb8197e41c2aac51444e3f | |
parent | 6ae324a6088efdc353478623804f5b13de8a0b0b (diff) |
Colorize man page links
-rw-r--r-- | cli/context.cxx | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/cli/context.cxx b/cli/context.cxx index 63de336..86de357 100644 --- a/cli/context.cxx +++ b/cli/context.cxx @@ -321,6 +321,8 @@ translate (string const& s, std::set<string> const& set) void context:: format_line (output_type ot, string& r, const char* s, size_t n) { + bool color (options.ansi_color ()); + typedef unsigned char block; // Mask. const block code = 1; @@ -666,7 +668,7 @@ format_line (output_type ot, string& r, const char* s, size_t n) { if ((b & link) == 0) { - if (options.ansi_color ()) + if (color) { if (b & bold) r += "\033[1m"; @@ -771,14 +773,24 @@ format_line (output_type ot, string& r, const char* s, size_t n) if (link_section.empty ()) r += link_target; else - r += link_target + "(" + link_section + ")"; + { + if (color) + r += "\033[1m"; + + r += link_target; + + if (color) + r += "\033[0m"; + + r += "(" + link_section + ")"; + } if (!link_empty) r += ")"; } else { - if (options.ansi_color ()) + if (color) { // While there are codes to turn off bold (22) and // underline (24), it is not clear how widely they |