diff options
author | pgen <p.gen.progs@gmail.com> | 2018-12-26 16:06:57 +0100 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2019-01-20 10:49:46 +0100 |
commit | 6c95885fc3b608a06e669284a572480c87397c9e (patch) | |
tree | 4e21da2cf20f20a727522b5f1dceb9fdf3a35506 | |
parent | a710b60a4226fe4c066b81fab6de4cf9636637ae (diff) |
Create the move_{left,right,up,down} functions
-rw-r--r-- | smenu.c | 926 | ||||
-rw-r--r-- | smenu.h | 20 |
2 files changed, 499 insertions, 447 deletions
@@ -4145,6 +4145,477 @@ select_starting_matches(win_t * win, term_t * term, search_data_t * search_data, } } +/* ====================== */ +/* Moves the cursor left */ +/* ====================== */ +void +move_left(win_t * win, term_t * term, toggle_t * toggle, + search_data_t * search_data, langinfo_t * langinfo, long * nl, + long last_line, char * tmp_word) +{ + long old_current = current; + long old_start = win->start; + long old_first_column = win->first_column; + long wi; /* word index */ + + do + { + if (current > 0) + { + if (current == win->start) + if (win->start > 0) + { + for (wi = win->start - 1; wi >= 0 && word_a[wi].start != 0; wi--) + { + } + win->start = wi; + + if (word_a[wi].str != NULL) + win->start = wi; + + if (win->end < count - 1) + { + for (wi = win->end + 2; wi < count - 1 && word_a[wi].start != 0; + wi++) + { + } + if (word_a[wi].str != NULL) + win->end = wi; + } + } + + /* In column mode we need to take care of the */ + /* horizontal scrolling */ + /* """""""""""""""""""""""""""""""""""""""""" */ + if (win->col_mode || win->line_mode) + { + long pos; + + if (word_a[current].start == 0) + { + long len; + + len = term->ncolumns - 3; + pos = first_word_in_line_a[line_nb_of_word_a[current - 1]]; + + while (word_a[current - 1].end - win->first_column >= len) + { + win->first_column += word_a[pos].end - word_a[pos].start + 2; + + pos++; + } + } + else if (word_a[current - 1].start < win->first_column) + win->first_column = word_a[current - 1].start; + } + current--; + } + else + break; + } while (current != old_current && !word_a[current].is_selectable); + + if (!word_a[current].is_selectable) + { + current = old_current; + win->start = old_start; + if (win->col_mode || win->line_mode) + win->first_column = old_first_column; + } + + if (current != old_current) + *nl = disp_lines(win, toggle, current, count, search_mode, search_data, + term, last_line, tmp_word, langinfo); +} + +/* ====================== */ +/* Moves the cursor right */ +/* ====================== */ +void +move_right(win_t * win, term_t * term, toggle_t * toggle, + search_data_t * search_data, langinfo_t * langinfo, long * nl, + long last_line, char * tmp_word) +{ + long old_current = current; + long old_start = win->start; + long old_first_column = win->first_column; + long wi; /* word index */ + + do + { + if (current < count - 1) + { + if (current == win->end) + if (win->start < count - 1 && win->end != count - 1) + { + for (wi = win->start + 1; wi < count - 1 && word_a[wi].start != 0; + wi++) + { + } + + if (word_a[wi].str != NULL) + win->start = wi; + + if (win->end < count - 1) + { + for (wi = win->end + 2; wi < count - 1 && word_a[wi].start != 0; + wi++) + { + } + if (word_a[wi].str != NULL) + win->end = wi; + } + } + + /* In column mode we need to take care of the */ + /* horizontal scrolling */ + /* """""""""""""""""""""""""""""""""""""""""" */ + if (win->col_mode || win->line_mode) + { + if (word_a[current].is_last) + win->first_column = 0; + else + { + long pos; + long len; + + len = term->ncolumns - 3; + + if (word_a[current + 1].end >= len + win->first_column) + { + /* Find the first word to be displayed in this line */ + /* """""""""""""""""""""""""""""""""""""""""""""""" */ + pos = first_word_in_line_a[line_nb_of_word_a[current]]; + + while (word_a[pos].start <= win->first_column) + pos++; + + pos--; + + /* If the new current word cannot be displayed, search */ + /* the first word in the line that can be displayed by */ + /* iterating on pos. */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""" */ + while (word_a[current + 1].end - word_a[pos].start >= len) + pos++; + + if (word_a[pos].start > 0) + win->first_column = word_a[pos].start; + } + } + } + current++; + } + else + break; + } while (current != old_current && !word_a[current].is_selectable); + + if (!word_a[current].is_selectable) + { + current = old_current; + win->start = old_start; + if (win->col_mode || win->line_mode) + win->first_column = old_first_column; + } + + if (current != old_current) + *nl = disp_lines(win, toggle, current, count, search_mode, search_data, + term, last_line, tmp_word, langinfo); +} + +/* =================== */ +/* Moves the cursor up */ +/* =================== */ +void +move_up(win_t * win, term_t * term, toggle_t * toggle, + search_data_t * search_data, langinfo_t * langinfo, long * nl, + long page, long last_line, char * tmp_word) +{ + long cur_line; + long start_line; + long last_word; + long cursor; + long old_current = current; + long old_start = win->start; + long index; + long s, e; /* Starting and ending terminal position of a word */ + + /* Store the initial starting and ending positions of */ + /* the word under the cursor */ + /* """""""""""""""""""""""""""""""""""""""""""""""""" */ + s = word_a[current].start; + e = word_a[current].end; + + do + { + /* Identify the line number of the first window's line */ + /* and the line number of the current line */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""" */ + start_line = line_nb_of_word_a[win->start]; + cur_line = line_nb_of_word_a[current]; + + if (cur_line == 0) + break; + + /* Manage the different cases */ + /* """""""""""""""""""""""""" */ + if (start_line >= page) + { + if (start_line > cur_line - page) + start_line -= page; + } + else + start_line = 0; + + /* Get the index of the last word of the destination line */ + /* """""""""""""""""""""""""""""""""""""""""""""""""""""" */ + if (cur_line >= page) + last_word = first_word_in_line_a[cur_line - page + 1] - 1; + else + last_word = first_word_in_line_a[1] - 1; + + /* And set the new value of the starting word of the window */ + /* """""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + win->start = first_word_in_line_a[start_line]; + + /* Look for the first word whose start position in the line is */ + /* less or equal to the source word starting position */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + cursor = last_word; + while (word_a[cursor].start > s) + cursor--; + + /* In case no word is eligible, keep the cursor on */ + /* the last word */ + /* """"""""""""""""""""""""""""""""""""""""""""""" */ + if (cursor == last_word && word_a[cursor].start > 0) + cursor--; + + /* Try to guess the best choice if we have multiple choices */ + /* """""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + if (word_a[cursor].end >= s + && word_a[cursor].end - s >= e - word_a[cursor + 1].start) + current = cursor; + else + { + if (cursor < last_word) + current = cursor + 1; + else + current = cursor; + } + + /* Set new first column to display */ + /* """"""""""""""""""""""""""""""" */ + set_new_first_column(win, term); + + /* If the word is not selectable, try to find a selectable word */ + /* in ts line */ + /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + if (!word_a[current].is_selectable) + { + index = 0; + while (word_a[current - index].start > 0 + && !word_a[current - index].is_selectable) + index++; + + if (word_a[current - index].is_selectable) + current -= index; + else + { + index = 0; + while (current + index < last_word + && !word_a[current + index].is_selectable) + index++; + + if (word_a[current + index].is_selectable) + current += index; + } + } + } while (current != old_current && !word_a[current].is_selectable); + + /* If no selectable word could be find; stay at the original */ + /* position */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + if (!word_a[current].is_selectable) + { + current = old_current; + win->start = old_start; + } + + /* Display the window */ + /* """""""""""""""""" */ + if (current != old_current) + *nl = disp_lines(win, toggle, current, count, search_mode, search_data, + term, last_line, tmp_word, langinfo); + else + { + /* We couldn't move to a selectable word, */ + /* try to move the window offset instead */ + /* """""""""""""""""""""""""""""""""""""" */ + if (line_nb_of_word_a[old_start] > 0 && win->cur_line < win->max_lines + && page == 1) + { + win->start = first_word_in_line_a[line_nb_of_word_a[old_start] - 1]; + + *nl = disp_lines(win, toggle, current, count, search_mode, search_data, + term, last_line, tmp_word, langinfo); + } + } +} + +/* ===================== */ +/* Moves the cursor down */ +/* ===================== */ +void +move_down(win_t * win, term_t * term, toggle_t * toggle, + search_data_t * search_data, langinfo_t * langinfo, long * nl, + long page, long last_line, char * tmp_word) +{ + long cur_line; + long start_line; + long last_word; + long cursor; + long old_current = current; + long old_start = win->start; + long index; + long s, e; /* Starting and ending terminal position of a word */ + + /* Store the initial starting and ending positions of */ + /* the word under the cursor */ + /* """""""""""""""""""""""""""""""""""""""""""""""""" */ + s = word_a[current].start; + e = word_a[current].end; + + do + { + /* Identify the line number of the first window's line */ + /* and the line number of the current line */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""" */ + start_line = line_nb_of_word_a[win->start]; + cur_line = line_nb_of_word_a[current]; + + /* Do nothing when we are already on the last line */ + /* """"""""""""""""""""""""""""""""""""""""""""""" */ + if (cur_line == last_line) + break; + + /* Determine and set the future start of the window */ + /* """""""""""""""""""""""""""""""""""""""""""""""" */ + if (start_line > 0 || last_line >= page) + if (cur_line + page > start_line + win->max_lines - 1) + { + if (last_line - (cur_line + page) < page) + { + start_line = last_line - win->max_lines + 1; + win->start = first_word_in_line_a[start_line]; + } + else + { + if (win->end < count - 1) + { + start_line += page; + win->start = first_word_in_line_a[start_line]; + } + } + } + + /* Calculate the index of the last word of the target line */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""""""" */ + if (cur_line + 1 == last_line) + last_word = count - 1; + else + { + if (cur_line + page < last_line) + last_word = first_word_in_line_a[cur_line + page + 1] - 1; + else + last_word = count - 1; + } + + /* Look for the first word whose start position in the line is */ + /* less or equal than the source word starting position */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + cursor = last_word; + while (word_a[cursor].start > s) + cursor--; + + /* In case no word is eligible, keep the cursor on */ + /* the last word */ + /* """"""""""""""""""""""""""""""""""""""""""""""" */ + if (cursor == last_word && word_a[cursor].start > 0) + cursor--; + + /* Try to guess the best choice if we have multiple choices */ + /* """""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + if (cursor < count - 1 + && word_a[cursor].end - s >= e - word_a[cursor + 1].start) + current = cursor; + else + { + if (cursor < count - 1) + { + if (cursor < last_word) + current = cursor + 1; + else + current = cursor; + } + else + current = count - 1; + } + + /* Set the new first column to display */ + /* """"""""""""""""""""""""""""""""""" */ + set_new_first_column(win, term); + + /* If the word is not selectable, try to find a selectable word */ + /* in ts line */ + /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + if (!word_a[current].is_selectable) + { + index = 0; + while (word_a[current - index].start > 0 + && !word_a[current - index].is_selectable) + index++; + + if (word_a[current - index].is_selectable) + current -= index; + else + { + index = 0; + while (current + index < last_word + && !word_a[current + index].is_selectable) + index++; + + if (word_a[current + index].is_selectable) + current += index; + } + } + } while (current != old_current && !word_a[current].is_selectable); + + if (!word_a[current].is_selectable) + { + current = old_current; + win->start = old_start; + } + + /* Display the window */ + /* """""""""""""""""" */ + if (current != old_current) + *nl = disp_lines(win, toggle, current, count, search_mode, search_data, + term, last_line, tmp_word, langinfo); + else + { + /* We couldn't move to a selectable word, */ + /* try to move the window offset instead */ + /* """""""""""""""""""""""""""""""""""""" */ + if (win->cur_line > 1 && win->end < count - 1 && page == 1) + { + win->start = first_word_in_line_a[line_nb_of_word_a[old_start] + 1]; + + *nl = disp_lines(win, toggle, current, count, search_mode, search_data, + term, last_line, tmp_word, langinfo); + } + } +} + /* ================ */ /* Main entry point */ /* ================ */ @@ -4395,8 +4866,6 @@ main(int argc, char * argv[]) long last_selectable; /* Index of the last selectable word in the input * * stream */ - long s, e; /* word variable to contain the starting and ending * - * terminal position of a word */ long min_size; /* Minimum screen width of a column in tabular mode */ long tab_max_size; /* Maximum screen width of a column in tabular * @@ -8920,82 +9389,8 @@ main(int argc, char * argv[]) case 'H': case 'h': if (search_mode == NONE) - { - long old_current = current; - long old_start = win.start; - long old_first_column = win.first_column; - - do - { - if (current > 0) - { - if (current == win.start) - if (win.start > 0) - { - for (wi = win.start - 1; wi >= 0 && word_a[wi].start != 0; - wi--) - { - } - win.start = wi; - - if (word_a[wi].str != NULL) - win.start = wi; - - if (win.end < count - 1) - { - for (wi = win.end + 2; - wi < count - 1 && word_a[wi].start != 0; wi++) - { - } - if (word_a[wi].str != NULL) - win.end = wi; - } - } - - /* In column mode we need to take care of the */ - /* horizontal scrolling */ - /* """""""""""""""""""""""""""""""""""""""""" */ - if (win.col_mode || win.line_mode) - { - long pos; - - if (word_a[current].start == 0) - { - long len; - - len = term.ncolumns - 3; - pos = first_word_in_line_a[line_nb_of_word_a[current - 1]]; - - while (word_a[current - 1].end - win.first_column >= len) - { - win.first_column += word_a[pos].end - word_a[pos].start - + 2; - - pos++; - } - } - else if (word_a[current - 1].start < win.first_column) - win.first_column = word_a[current - 1].start; - } - current--; - } - else - break; - } while (current != old_current && !word_a[current].is_selectable); - - if (!word_a[current].is_selectable) - { - current = old_current; - win.start = old_start; - if (win.col_mode || win.line_mode) - win.first_column = old_first_column; - } - - if (current != old_current) - nl = disp_lines(&win, &toggle, current, count, search_mode, - &search_data, &term, last_line, tmp_word, - &langinfo); - } + move_left(&win, &term, &toggle, &search_data, &langinfo, &nl, + last_line, tmp_word); else goto special_cmds_when_searching; @@ -9010,93 +9405,8 @@ main(int argc, char * argv[]) case 'L': case 'l': if (search_mode == NONE) - { - long old_current = current; - long old_start = win.start; - long old_first_column = win.first_column; - - do - { - if (current < count - 1) - { - if (current == win.end) - if (win.start < count - 1 && win.end != count - 1) - { - for (wi = win.start + 1; - wi < count - 1 && word_a[wi].start != 0; wi++) - { - } - - if (word_a[wi].str != NULL) - win.start = wi; - - if (win.end < count - 1) - { - for (wi = win.end + 2; - wi < count - 1 && word_a[wi].start != 0; wi++) - { - } - if (word_a[wi].str != NULL) - win.end = wi; - } - } - - /* In column mode we need to take care of the */ - /* horizontal scrolling */ - /* """""""""""""""""""""""""""""""""""""""""" */ - if (win.col_mode || win.line_mode) - { - if (word_a[current].is_last) - win.first_column = 0; - else - { - long pos; - long len; - - len = term.ncolumns - 3; - - if (word_a[current + 1].end >= len + win.first_column) - { - /* Find the first word to be displayed in this line */ - /* """""""""""""""""""""""""""""""""""""""""""""""" */ - pos = first_word_in_line_a[line_nb_of_word_a[current]]; - - while (word_a[pos].start <= win.first_column) - pos++; - - pos--; - - /* If the new current word cannot be displayed, search */ - /* the first word in the line that can be displayed by */ - /* iterating on pos. */ - /* """"""""""""""""""""""""""""""""""""""""""""""""""" */ - while (word_a[current + 1].end - word_a[pos].start >= len) - pos++; - - if (word_a[pos].start > 0) - win.first_column = word_a[pos].start; - } - } - } - current++; - } - else - break; - } while (current != old_current && !word_a[current].is_selectable); - - if (!word_a[current].is_selectable) - { - current = old_current; - win.start = old_start; - if (win.col_mode || win.line_mode) - win.first_column = old_first_column; - } - - if (current != old_current) - nl = disp_lines(&win, &toggle, current, count, search_mode, - &search_data, &term, last_line, tmp_word, - &langinfo); - } + move_right(&win, &term, &toggle, &search_data, &langinfo, &nl, + last_line, tmp_word); else goto special_cmds_when_searching; @@ -9124,140 +9434,8 @@ main(int argc, char * argv[]) case 'k': if (search_mode == NONE) - { - long cur_line; - long start_line; - long last_word; - long cursor; - long old_current = current; - long old_start = win.start; - long index; - - /* Store the initial starting and ending positions of */ - /* the word under the cursor */ - /* """""""""""""""""""""""""""""""""""""""""""""""""" */ - s = word_a[current].start; - e = word_a[current].end; - - do - { - /* Identify the line number of the first window's line */ - /* and the line number of the current line */ - /* """"""""""""""""""""""""""""""""""""""""""""""""""" */ - start_line = line_nb_of_word_a[win.start]; - cur_line = line_nb_of_word_a[current]; - - if (cur_line == 0) - break; - - /* Manage the different cases */ - /* """""""""""""""""""""""""" */ - if (start_line >= page) - { - if (start_line > cur_line - page) - start_line -= page; - } - else - start_line = 0; - - /* Get the index of the last word of the destination line */ - /* """""""""""""""""""""""""""""""""""""""""""""""""""""" */ - if (cur_line >= page) - last_word = first_word_in_line_a[cur_line - page + 1] - 1; - else - last_word = first_word_in_line_a[1] - 1; - - /* And set the new value of the starting word of the window */ - /* """""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - win.start = first_word_in_line_a[start_line]; - - /* Look for the first word whose start position in the line is */ - /* less or equal to the source word starting position */ - /* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - cursor = last_word; - while (word_a[cursor].start > s) - cursor--; - - /* In case no word is eligible, keep the cursor on */ - /* the last word */ - /* """"""""""""""""""""""""""""""""""""""""""""""" */ - if (cursor == last_word && word_a[cursor].start > 0) - cursor--; - - /* Try to guess the best choice if we have multiple choices */ - /* """""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - if (word_a[cursor].end >= s - && word_a[cursor].end - s >= e - word_a[cursor + 1].start) - current = cursor; - else - { - if (cursor < last_word) - current = cursor + 1; - else - current = cursor; - } - - /* Set new first column to display */ - /* """"""""""""""""""""""""""""""" */ - set_new_first_column(&win, &term); - - /* If the word is not selectable, try to find a selectable word */ - /* in ts line */ - /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - if (!word_a[current].is_selectable) - { - index = 0; - while (word_a[current - index].start > 0 - && !word_a[current - index].is_selectable) - index++; - - if (word_a[current - index].is_selectable) - current -= index; - else - { - index = 0; - while (current + index < last_word - && !word_a[current + index].is_selectable) - index++; - - if (word_a[current + index].is_selectable) - current += index; - } - } - } while (current != old_current && !word_a[current].is_selectable); - - /* If no selectable word could be find; stay at the original */ - /* position */ - /* """"""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - if (!word_a[current].is_selectable) - { - current = old_current; - win.start = old_start; - } - - /* Display the window */ - /* """""""""""""""""" */ - if (current != old_current) - nl = disp_lines(&win, &toggle, current, count, search_mode, - &search_data, &term, last_line, tmp_word, - &langinfo); - else - { - /* We couldn't move to a selectable word, */ - /* try to move the window offset instead */ - /* """""""""""""""""""""""""""""""""""""" */ - if (line_nb_of_word_a[old_start] > 0 - && win.cur_line < win.max_lines && page == 1) - { - win.start = - first_word_in_line_a[line_nb_of_word_a[old_start] - 1]; - - nl = disp_lines(&win, &toggle, current, count, search_mode, - &search_data, &term, last_line, tmp_word, - &langinfo); - } - } - } + move_up(&win, &term, &toggle, &search_data, &langinfo, &nl, page, + last_line, tmp_word); else goto special_cmds_when_searching; @@ -9322,154 +9500,8 @@ main(int argc, char * argv[]) case 'j': if (search_mode == NONE) - { - long cur_line; - long start_line; - long last_word; - long cursor; - long old_current = current; - long old_start = win.start; - long index; - - /* Store the initial starting and ending positions of */ - /* the word under the cursor */ - /* """""""""""""""""""""""""""""""""""""""""""""""""" */ - s = word_a[current].start; - e = word_a[current].end; - - do - { - /* Identify the line number of the first window's line */ - /* and the line number of the current line */ - /* """"""""""""""""""""""""""""""""""""""""""""""""""" */ - start_line = line_nb_of_word_a[win.start]; - cur_line = line_nb_of_word_a[current]; - - /* Do nothing when we are already on the last line */ - /* """"""""""""""""""""""""""""""""""""""""""""""" */ - if (cur_line == last_line) - break; - - /* Determine and set the future start of the window */ - /* """""""""""""""""""""""""""""""""""""""""""""""" */ - if (start_line > 0 || last_line >= page) - if (cur_line + page > start_line + win.max_lines - 1) - { - if (last_line - (cur_line + page) < page) - { - start_line = last_line - win.max_lines + 1; - win.start = first_word_in_line_a[start_line]; - } - else - { - if (win.end < count - 1) - { - start_line += page; - win.start = first_word_in_line_a[start_line]; - } - } - } - - /* Calculate the index of the last word of the target line */ - /* """"""""""""""""""""""""""""""""""""""""""""""""""""""" */ - if (cur_line + 1 == last_line) - last_word = count - 1; - else - { - if (cur_line + page < last_line) - last_word = first_word_in_line_a[cur_line + page + 1] - 1; - else - last_word = count - 1; - } - - /* Look for the first word whose start position in the line is */ - /* less or equal than the source word starting position */ - /* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - cursor = last_word; - while (word_a[cursor].start > s) - cursor--; - - /* In case no word is eligible, keep the cursor on */ - /* the last word */ - /* """"""""""""""""""""""""""""""""""""""""""""""" */ - if (cursor == last_word && word_a[cursor].start > 0) - cursor--; - - /* Try to guess the best choice if we have multiple choices */ - /* """""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - if (cursor < count - 1 - && word_a[cursor].end - s >= e - word_a[cursor + 1].start) - current = cursor; - else - { - if (cursor < count - 1) - { - if (cursor < last_word) - current = cursor + 1; - else - current = cursor; - } - else - current = count - 1; - } - - /* Set the new first column to display */ - /* """"""""""""""""""""""""""""""""""" */ - set_new_first_column(&win, &term); - - /* If the word is not selectable, try to find a selectable word */ - /* in ts line */ - /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - if (!word_a[current].is_selectable) - { - index = 0; - while (word_a[current - index].start > 0 - && !word_a[current - index].is_selectable) - index++; - - if (word_a[current - index].is_selectable) - current -= index; - else - { - index = 0; - while (current + index < last_word - && !word_a[current + index].is_selectable) - index++; - - if (word_a[current + index].is_selectable) - current += index; - } - } - } while (current != old_current && !word_a[current].is_selectable); - - if (!word_a[current].is_selectable) - { - current = old_current; - win.start = old_start; - } - - /* Display the window */ - /* """""""""""""""""" */ - if (current != old_current) - nl = disp_lines(&win, &toggle, current, count, search_mode, - &search_data, &term, last_line, tmp_word, - &langinfo); - else - { - /* We couldn't move to a selectable word, */ - /* try to move the window offset instead */ - /* """""""""""""""""""""""""""""""""""""" */ - if (win.cur_line > 1 && win.end < count - 1 && page == 1) - { - win.start = - first_word_in_line_a[line_nb_of_word_a[old_start] + 1]; - - nl = disp_lines(&win, &toggle, current, count, search_mode, - &search_data, &term, last_line, tmp_word, - &langinfo); - } - } - } + move_down(&win, &term, &toggle, &search_data, &langinfo, &nl, page, + last_line, tmp_word); else goto special_cmds_when_searching; @@ -224,6 +224,26 @@ apply_attr(term_t * term, attr_t attr); int delims_cmp(const void * a, const void * b); +void +move_left(win_t * win, term_t * term, toggle_t * toggle, + search_data_t * search_data, langinfo_t * langinfo, long * nl, + long last_line, char * tmp_word); + +void +move_right(win_t * win, term_t * term, toggle_t * toggle, + search_data_t * search_data, langinfo_t * langinfo, long * nl, + long last_line, char * tmp_word); + +void +move_up(win_t * win, term_t * term, toggle_t * toggle, + search_data_t * search_data, langinfo_t * langinfo, long * nl, + long page, long last_line, char * tmp_word); + +void +move_down(win_t * win, term_t * term, toggle_t * toggle, + search_data_t * search_data, langinfo_t * langinfo, long * nl, + long page, long last_line, char * tmp_word); + /* ***************** */ /* Emums and structs */ /* ***************** */ |