diff options
author | pgen <p.gen.progs@gmail.com> | 2018-04-02 13:50:51 +0200 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2018-04-02 15:43:08 +0200 |
commit | 9614ee92c883da09e2b3abb35ea5dbbb398292d4 (patch) | |
tree | 1720ad6bb7570319c532771e94753e1ed37f387f /smenu.c | |
parent | 890e7bf2026ff1ec3e877e445b1105d81f74d4a7 (diff) |
Improves movement among words
←, h Previous word
↑, k Previous line
PgUp, K (new) Previous pages
Home First word of the window
CTRL+Home (new), SHIFT+Home (new), CTRL+k (new) First word
→, l Next Word
↓, j Next line
PgDn, J (new) Next pages
End Last word of the window
CTRL+End (new), SHIFT+End (new), CTRL+j (new) Last word
Diffstat (limited to 'smenu.c')
-rw-r--r-- | smenu.c | 92 |
1 files changed, 90 insertions, 2 deletions
@@ -8860,6 +8860,12 @@ main(int argc, char * argv[]) break; } + if (memcmp("\x1b[1;5H", buffer, 6) == 0 + || memcmp("\x1b[1;2H", buffer, 6) == 0) + /* SHIFT/CTRL HOME key has been pressed */ + /* """""""""""""""""""""""""""""""""""" */ + goto kschome; + if (memcmp("\x1bOF", buffer, 3) == 0 || memcmp("\x1b[F", buffer, 3) == 0) { @@ -8916,6 +8922,12 @@ main(int argc, char * argv[]) break; } + if (memcmp("\x1b[1;5F", buffer, 6) == 0 + || memcmp("\x1b[1;2F", buffer, 6) == 0) + /* SHIFT/CTRL END key has been pressed */ + /* """"""""""""""""""""""""""""""""""" */ + goto kscend; + if (memcmp("\x1bOD", buffer, 3) == 0 || memcmp("\x1b[D", buffer, 3) == 0) /* Left arrow key has been pressed */ @@ -9471,6 +9483,15 @@ main(int argc, char * argv[]) break; + case 0x0b: + /* ^K key has been pressed */ + /* """"""""""""""""""""""" */ + goto kschome; + + case 'K': + if (search_mode) + goto special_cmds_when_searching; + kpp: /* PgUp key has been pressed */ /* """"""""""""""""""""""""" */ @@ -9485,7 +9506,6 @@ main(int argc, char * argv[]) search_timer = -1; /* Disable the timer */ } - case 'K': case 'k': if (!search_mode) { @@ -9627,6 +9647,45 @@ main(int argc, char * argv[]) break; + kschome: + /* Go to the first selectable word. */ + /* """""""""""""""""""""""""""""""" */ + current = 0; + + if (search_mode) + { + search_mode = 0; + search_timer = -1; /* Disable the timer */ + } + + /* Find the first selectable word */ + /* """""""""""""""""""""""""""""" */ + while (!word_a[current].is_selectable) + current++; + + /* In column mode we need to take care of the */ + /* horizontal scrolling */ + /* """""""""""""""""""""""""""""""""""""""""" */ + if (win.col_mode || win.line_mode) + if (word_a[current].end < win.first_column) + win.first_column = word_a[current].start; + + if (current < win.start || current > win.end) + last_line = build_metadata(word_a, &term, count, &win); + + nl = disp_lines(word_a, &win, &toggle, current, count, search_mode, + search_buf, &term, last_line, tmp_word, &langinfo); + break; + + case 0x0a: + /* ^J key has been pressed */ + /* """"""""""""""""""""""" */ + goto kscend; + + case 'J': + if (search_mode) + goto special_cmds_when_searching; + knp: /* PgDn key has been pressed */ /* """"""""""""""""""""""""" */ @@ -9641,7 +9700,6 @@ main(int argc, char * argv[]) search_timer = -1; /* Disable the timer */ } - case 'J': case 'j': if (!search_mode) { @@ -9797,6 +9855,36 @@ main(int argc, char * argv[]) break; + kscend: + /* Go to the last selectable word. */ + /* """"""""""""""""""""""""""""""" */ + current = count - 1; + + if (search_mode) + { + search_mode = 0; + search_timer = -1; /* Disable the timer */ + } + + /* Find the first selectable word */ + /* """""""""""""""""""""""""""""" */ + while (!word_a[current].is_selectable) + current--; + + /* In column mode we need to take care of the */ + /* horizontal scrolling */ + /* """""""""""""""""""""""""""""""""""""""""" */ + if (win.col_mode || win.line_mode) + if (word_a[current].end < win.first_column) + win.first_column = word_a[current].start; + + if (current < win.start || current > win.end) + last_line = build_metadata(word_a, &term, count, &win); + + nl = disp_lines(word_a, &win, &toggle, current, count, search_mode, + search_buf, &term, last_line, tmp_word, &langinfo); + break; + case 0x06: case '/': /* / or CTRL-F key has been pressed (start of a search session) */ |