diff options
author | pgen <p.gen.progs@gmail.com> | 2016-12-11 21:00:20 +0100 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2016-12-11 21:00:20 +0100 |
commit | 83a621695ceff472c039c71847744e8a4eef3343 (patch) | |
tree | cc370dd9897c3254a5b36ed1e1326d4a10b96b4b | |
parent | 8de3d84d4c01d91a0c05af81030565a437c6228b (diff) |
Add a new configuration parameter for the cursor
When the selected word is tagged, the cursor can now have an other aspect
than when the word it selects is not tagged.
-rw-r--r-- | smenu.1 | 1 | ||||
-rw-r--r-- | smenu.c | 76 |
2 files changed, 35 insertions, 42 deletions
@@ -183,6 +183,7 @@ allowed: method=ansi ; classic | ansi (default) cursor=0/2 ; cursor attributes + cursor_on_tag=0/2,u ; cursor on tag attributes shift=6,b ; shift symbol attributes bar = 7/4,b ; scroll bar attributes search_field = 0/6 ; search field attributes @@ -381,14 +381,15 @@ struct win_s unsigned char wide; /* -w */ unsigned char center; /* -M */ - txt_attr_t cursor_attr; /* current cursor attributes */ - txt_attr_t bar_attr; /* scrollbar attributes */ - txt_attr_t shift_attr; /* shift indicator attributes */ - txt_attr_t search_field_attr; /* search mode field attributes */ - txt_attr_t search_text_attr; /* search mode text attributes */ - txt_attr_t exclude_attr; /* non-selectable words attributes */ - txt_attr_t tag_attr; /* non-selectable words attributes */ - txt_attr_t special_attr[5]; /* special (-1,...) words attributes */ + txt_attr_t cursor_attr; /* current cursor attributes */ + txt_attr_t cursor_on_tag_attr; /* current cursor on tag attributes */ + txt_attr_t bar_attr; /* scrollbar attributes */ + txt_attr_t shift_attr; /* shift indicator attributes */ + txt_attr_t search_field_attr; /* search mode field attributes */ + txt_attr_t search_text_attr; /* search mode text attributes */ + txt_attr_t exclude_attr; /* non-selectable words attributes */ + txt_attr_t tag_attr; /* non-selectable words attributes */ + txt_attr_t special_attr[5]; /* special (-1,...) words attributes */ }; /* Sed like node structure */ @@ -1060,6 +1061,7 @@ ini_cb(win_t * win, term_t * term, limits_t * limits, const char * section, CHECK_ATTR(search_text) CHECK_ATTR(exclude) CHECK_ATTR(tag) + CHECK_ATTR(cursor_on_tag) CHECK_ATT_ATTR(special, 1) CHECK_ATT_ATTR(special, 2) CHECK_ATT_ATTR(special, 3) @@ -3544,38 +3546,27 @@ disp_word(word_t * word_a, int pos, int search_mode, char * buffer, } else { - /* If we are not in search mode, display in the cursor in reverse video */ - /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + /* If we are not in search mode, display a normal cursor */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""""" */ if (win->cursor_attr.is_set) { - if (win->cursor_attr.bold > 0) - (void)tputs(enter_bold_mode, 1, outch); - - if (win->cursor_attr.dim > 0) - (void)tputs(enter_dim_mode, 1, outch); - - if (win->cursor_attr.reverse > 0) + if (word_a[pos].is_tagged) + apply_txt_attr(term, win->cursor_on_tag_attr); + else + apply_txt_attr(term, win->cursor_attr); + } + else + { + if (word_a[pos].is_tagged) + { + if (term->has_underline) + (void)tputs(enter_underline_mode, 1, outch); + } + if (term->has_reverse) (void)tputs(enter_reverse_mode, 1, outch); - - if (win->cursor_attr.standout > 0) + else if (term->has_standout) (void)tputs(enter_standout_mode, 1, outch); - - if (win->cursor_attr.underline > 0) - (void)tputs(enter_underline_mode, 1, outch); - - if (win->cursor_attr.italic > 0) - (void)tputs(enter_italics_mode, 1, outch); - - if (win->cursor_attr.fg >= 0 && term->colors > 7) - set_foreground_color(term, win->cursor_attr.fg); - - if (win->cursor_attr.fg >= 0 && term->colors > 7) - set_background_color(term, win->cursor_attr.bg); } - else if (term->has_reverse) - (void)tputs(enter_reverse_mode, 1, outch); - else if (term->has_standout) - (void)tputs(enter_standout_mode, 1, outch); (void)mb_strprefix(tmp_max_word, word_a[pos].str, (int)word_a[pos].mb - 1, &p); @@ -4584,13 +4575,14 @@ main(int argc, char * argv[]) init_attr.underline = -1; init_attr.italic = -1; - win.cursor_attr = init_attr; - win.bar_attr = init_attr; - win.shift_attr = init_attr; - win.search_field_attr = init_attr; - win.search_text_attr = init_attr; - win.exclude_attr = init_attr; - win.tag_attr = init_attr; + win.cursor_attr = init_attr; + win.cursor_on_tag_attr = init_attr; + win.bar_attr = init_attr; + win.shift_attr = init_attr; + win.search_field_attr = init_attr; + win.search_text_attr = init_attr; + win.exclude_attr = init_attr; + win.tag_attr = init_attr; win.sel_sep = NULL; |