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;
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
-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) {
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 {
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
// 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++] = ' ';
}
// 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);
}
}
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);
}
attr_error = A_STANDOUT;
attr_modeline = A_REVERSE;
- attr_highlighted_line = A_STANDOUT;
+ attr_focus_line = A_STANDOUT;
if(with_colors && has_colors()) {
}
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 {
}
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) {
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