From 95af56f1edfd910ce0443612e69f8996810dcbc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Diego=20Aur=C3=A9lio=20Mesquita?= Date: Mon, 20 Apr 2020 11:53:55 -0300 Subject: [PATCH] Use right top corner to display state --- src/nano.c | 4 ++++ src/nano.h | 3 ++- src/rcfile.c | 1 + src/text.c | 1 + src/winio.c | 28 ++++++++++++++++++++-------- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/nano.c b/src/nano.c index 024a5f19..b72af15c 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1104,6 +1104,7 @@ void do_toggle(int flag) statusline(HUSH, "%s %s", _(flagtostr(flag)), enabled ? _("enabled") : _("disabled")); + titlebar(NULL); } #endif /* !NANO_TINY */ @@ -1447,6 +1448,7 @@ void process_a_keystroke(void) #ifndef NANO_TINY if (openfile->mark && openfile->kind_of_mark == SOFTMARK) { openfile->mark = NULL; + titlebar(NULL); refresh_needed = TRUE; } #endif @@ -1509,6 +1511,7 @@ void process_a_keystroke(void) openfile->mark = openfile->current; openfile->mark_x = openfile->current_x; openfile->kind_of_mark = SOFTMARK; + titlebar(NULL); } #endif @@ -1525,6 +1528,7 @@ void process_a_keystroke(void) openfile->current_x != was_x || wanted_to_move(shortcut->func))) { openfile->mark = NULL; + titlebar(NULL); refresh_needed = TRUE; } else if (openfile->current != was_current) also_the_last = FALSE; diff --git a/src/nano.h b/src/nano.h index 75f6f3c7..90300c5e 100644 --- a/src/nano.h +++ b/src/nano.h @@ -540,7 +540,8 @@ enum LET_THEM_ZAP, BREAK_LONG_LINES, JUMPY_SCROLLING, - EMPTY_LINE + EMPTY_LINE, + SHOW_STATE }; /* Flags for the menus in which a given function should be present. */ diff --git a/src/rcfile.c b/src/rcfile.c index 0e090f1c..72157646 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -86,6 +86,7 @@ static const rcoption rcopts[] = { {"rawsequences", RAW_SEQUENCES}, {"rebinddelete", REBIND_DELETE}, {"regexp", USE_REGEXP}, + {"showstate", SHOW_STATE}, #ifdef ENABLE_SPELLER {"speller", 0}, #endif diff --git a/src/text.c b/src/text.c index a002280e..53c67a68 100644 --- a/src/text.c +++ b/src/text.c @@ -56,6 +56,7 @@ void do_mark(void) statusbar(_("Mark Unset")); refresh_needed = TRUE; } + titlebar(NULL); } #endif /* !NANO_TINY */ diff --git a/src/winio.c b/src/winio.c index eb89e16d..faa8c84f 100644 --- a/src/winio.c +++ b/src/winio.c @@ -97,6 +97,8 @@ void record_macro(void) snip_last_keystroke(); statusbar(_("Stopped recording")); } + + titlebar(NULL); } /* Copy the stored sequence of codes into the regular key buffer, @@ -2018,6 +2020,7 @@ void titlebar(const char *path) const char *prefix = ""; /* What is shown before the path -- "DIR:" or nothing. */ const char *state = ""; + char state_chars[] = {' ', ' ', ' ', ' ', ' ', ' ',' ', ' ', ' ', '\0'} ; /* The state of the current buffer -- "Modified", "View", or "". */ char *caption; /* The presentable form of the pathname. */ @@ -2067,14 +2070,23 @@ void titlebar(const char *path) else path = openfile->filename; - if (openfile->modified) - state = _("Modified"); - else if (ISSET(VIEW_MODE)) - state = _("View"); - else if (ISSET(RESTRICTED)) - state = _("Restricted"); - else - pluglen = breadth(_("Modified")) + 1; + if (ISSET(SHOW_STATE)) { + state_chars[0] = openfile->modified ? '*' : ' '; + state_chars[2] = recording ? 'M' : ' '; + state_chars[4] = ISSET(AUTOINDENT) ? 'I' : ' '; + state_chars[6] = openfile->mark ? 'S' : ' '; + state_chars[8] = ISSET(BREAK_LONG_LINES) ? 'H' : ' '; + state = state_chars; + } else { + if (openfile->modified) + state = _("Modified"); + else if (ISSET(VIEW_MODE)) + state = _("View"); + else if (ISSET(RESTRICTED)) + state = _("Restricted"); + else + pluglen = breadth(_("Modified")) + 1; + } } /* Determine the widths of the four elements, including their padding. */ -- 2.17.1