- if(first_line > 0) {
- first_line--;
- while(first_line > 0 && !match(lines[first_line], nb_patterns, patterns)) {
- first_line--;
- }
- if(match(lines[first_line], nb_patterns, patterns)) {
- nb_match++;
- }
+void update_screen(int *current_line, int *temporary_line, int motion,
+ int nb_lines, char **lines,
+ int cursor_position,
+ char *pattern) {
+
+ char buffer[buffer_size];
+ matcher_t matcher;
+
+ initialize_matcher(use_regexp, case_sensitive, &matcher, pattern);
+
+ // We now take care of printing the lines per se
+
+ int console_width = getmaxx(stdscr);
+ int console_height = getmaxy(stdscr);
+
+ // First, we find a visible line. In priority: The current, or the
+ // first visible after it, or the first visible before it.
+
+ int nb_printed_lines = 0;
+
+ clear();
+ use_default_colors();
+ addstr("\n");
+
+ if(matcher.regexp_error) {
+ addstr("[regexp error]");
+ } else if(nb_lines > 0) {
+ int new_line;
+ if(match(lines[*current_line], &matcher)) {
+ new_line = *current_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);