From: Francois Fleuret Date: Mon, 8 Jun 2009 07:45:43 +0000 (+0200) Subject: Cosmetics. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=2166d4e6b12465e6fed37eafbf4692ecbf99d824;p=selector.git Cosmetics. --- diff --git a/selector.cc b/selector.cc index a22329c..7488bfd 100644 --- a/selector.cc +++ b/selector.cc @@ -61,10 +61,10 @@ char *title = 0; int error_flash = 0; #define COLOR_MODELINE 1 -#define COLOR_HIGHLIGHTED_LINE 2 +#define COLOR_FOCUS_LINE 2 #define COLOR_ERROR 3 -int attr_modeline, attr_highlighted_line, attr_error; +int attr_modeline, attr_focus_line, attr_error; ////////////////////////////////////////////////////////////////////// @@ -333,7 +333,7 @@ int next_visible(int current_line, int nb_lines, char **lines, matcher_t *matche ////////////////////////////////////////////////////////////////////// -void update_screen(int *current_line, int *temporary_line, int motion, +void update_screen(int *current_focus_line, int *temporary_line, int motion, int nb_lines, char **lines, int cursor_position, char *pattern) { @@ -358,29 +358,29 @@ void update_screen(int *current_line, int *temporary_line, int motion, if(matcher.regexp_error) { attron(attr_error); - addnstr("[regexp error]", console_width); + addnstr("Regexp syntax error", console_width); attroff(attr_error); } else if(nb_lines > 0) { - int new_line; - if(match(lines[*current_line], &matcher)) { - new_line = *current_line; + int new_focus_line; + if(match(lines[*current_focus_line], &matcher)) { + new_focus_line = *current_focus_line; } else { - new_line = next_visible(*current_line, nb_lines, lines, &matcher); - if(new_line < 0) { - new_line = previous_visible(*current_line, nb_lines, lines, &matcher); + new_focus_line = next_visible(*current_focus_line, nb_lines, lines, &matcher); + if(new_focus_line < 0) { + new_focus_line = previous_visible(*current_focus_line, nb_lines, lines, &matcher); } } // If we found a visible line and we should move, let's move - if(new_line >= 0 && motion != 0) { - int l = new_line; + if(new_focus_line >= 0 && motion != 0) { + int l = new_focus_line; if(motion > 0) { // We want to go down, let's find the first visible line below for(int m = 0; l >= 0 && m < motion; m++) { l = next_visible(l, nb_lines, lines, &matcher); if(l >= 0) { - new_line = l; + new_focus_line = l; } } } else { @@ -388,17 +388,17 @@ void update_screen(int *current_line, int *temporary_line, int motion, for(int m = 0; l >= 0 && m < -motion; m++) { l = previous_visible(l, nb_lines, lines, &matcher); if(l >= 0) { - new_line = l; + new_focus_line = l; } } } } - // Here new_line is either a line number matching the patterns, or -1 + // Here new_focus_line is either a line number matching the patterns, or -1 - if(new_line >= 0) { + if(new_focus_line >= 0) { - int first_line = new_line, last_line = new_line, nb_match = 1; + int first_line = new_focus_line, last_line = new_focus_line, nb_match = 1; // We find the first and last line to show, so that the total of // visible lines between them (them included) is console_height-1 @@ -441,7 +441,7 @@ void update_screen(int *current_line, int *temporary_line, int motion, // We fill the rest of the line with blanks if this is the // highlighted line - if(l == new_line) { + if(l == new_focus_line) { while(k < console_width) { buffer[k++] = ' '; } @@ -454,10 +454,10 @@ void update_screen(int *current_line, int *temporary_line, int motion, // Highlight the highlighted line ... - if(l == new_line) { - attron(attr_highlighted_line); + if(l == new_focus_line) { + attron(attr_focus_line); addnstr(buffer, console_width); - attroff(attr_highlighted_line); + attroff(attr_focus_line); } else { addnstr(buffer, console_width); } @@ -467,20 +467,20 @@ void update_screen(int *current_line, int *temporary_line, int motion, } if(motion != 0) { - *current_line = new_line; + *current_focus_line = new_focus_line; } } - *temporary_line = new_line; + *temporary_line = new_focus_line; if(nb_printed_lines == 0) { attron(attr_error); - addnstr("[no selection]", console_width); + addnstr("No selection", console_width); attroff(attr_error); } } else { attron(attr_error); - addnstr("[empty choice]", console_width); + addnstr("Empty choice", console_width); attroff(attr_error); } @@ -885,7 +885,7 @@ int main(int argc, char **argv) { attr_error = A_STANDOUT; attr_modeline = A_REVERSE; - attr_highlighted_line = A_STANDOUT; + attr_focus_line = A_STANDOUT; if(with_colors && has_colors()) { @@ -902,19 +902,19 @@ int main(int argc, char **argv) { } init_pair(COLOR_MODELINE, color_fg_modeline, color_bg_modeline); - init_pair(COLOR_HIGHLIGHTED_LINE, color_fg_highlight, color_bg_highlight); + init_pair(COLOR_FOCUS_LINE, color_fg_highlight, color_bg_highlight); init_pair(COLOR_ERROR, COLOR_WHITE, COLOR_RED); attr_modeline = COLOR_PAIR(COLOR_MODELINE); - attr_highlighted_line = COLOR_PAIR(COLOR_HIGHLIGHTED_LINE); + attr_focus_line = COLOR_PAIR(COLOR_FOCUS_LINE); attr_error = COLOR_PAIR(COLOR_ERROR); } int key; - int current_line = 0, temporary_line = 0; + int current_focus_line = 0, temporary_line = 0; - update_screen(¤t_line, &temporary_line, 0, + update_screen(¤t_focus_line, &temporary_line, 0, nb_lines, labels, cursor_position, pattern); do { @@ -939,11 +939,11 @@ int main(int argc, char **argv) { } else if(key == KEY_HOME) { - current_line = 0; + current_focus_line = 0; } else if(key == KEY_END) { - current_line = nb_lines - 1; + current_focus_line = nb_lines - 1; } else if(key == KEY_NPAGE) { @@ -1005,7 +1005,7 @@ int main(int argc, char **argv) { clear(); } - update_screen(¤t_line, &temporary_line, motion, + update_screen(¤t_focus_line, &temporary_line, motion, nb_lines, labels, cursor_position, pattern); } while(key != '\007' && // ^G