From 08d03b2190422e99020b8d743f0df8b6503265d3 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 6 Jan 2024 17:05:42 +0000 Subject: [PATCH] Kinda fix pager(1) man bullet points. --- utils/pager.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/utils/pager.c b/utils/pager.c index 17acce7d..6450bec3 100644 --- a/utils/pager.c +++ b/utils/pager.c @@ -333,18 +333,30 @@ static void push_wchar(wchar_t wc) { if ( incoming_line_width ) incoming_line_width--; - while ( line->content_used && - (line->content[line->content_used-1] & 0xC0) == 0x80 ) - line->content_used--; - if ( line->content_used ) + size_t index = line->content_used; + const char* unbold = "\e[22m"; + if ( strlen(unbold) <= index && + !memcmp(unbold, line->content + index - strlen(unbold), strlen(unbold)) ) + index -= strlen(unbold); + while ( index && (line->content[index-1] & 0xC0) == 0x80 ) + index--; + const char* bold = "\e[1m"; + if ( strlen(bold) <= index && + !memcmp(bold, line->content + index - strlen(bold), strlen(bold)) ) { - char c = line->content[--line->content_used]; + index -= strlen(bold); + next_bold = true; + } + if ( index ) + { + char c = line->content[index - 1]; if ( c == '_' ) next_underline = true; else if ( c == ' ' ) next_bold = false; else next_bold = true; + line_push_char(line, '\b'); } return; }