diff options
| -rw-r--r-- | main.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -1,7 +1,5 @@ -#include <stdio.h> #include <stdint.h> #include <stddef.h> -#include <ctype.h> #include <err.h> #include <fcntl.h> @@ -154,12 +152,13 @@ u32 move_par_down(Txt *t, u32 cur) { void find_view_window(Txt *t, u32 curs, TxtLoc *start, TxtLoc *end) { TxtLoc l = txt_at(t, curs); - u32 n = LINES; u32 u = LINES / 2; TxtLoc a = l; for (u32 i = 0; i < u; i++) a = prev_newline(t, a); + u32 n = 0; TxtLoc b = a; - while (!txt_at_end(t, b) && n--) b = next_newline(t, b); + while (!txt_at_end(t, b) && n++ < LINES) b = next_newline(t, b); + while (!txt_at_start(t, a) && n++ < LINES) a = prev_newline(t, a); if (!txt_at_start(t,a) && txt_byte(t,a) == '\n') a = txt_next(t, a); *start = a; *end = b; @@ -263,6 +262,12 @@ int main(int argc, const char **argv) { case KEY_END: cur = txt_ofs(&txt, next_newline(&txt, txt_at(&txt, cur))); break; + case KEY_HOME | KEY_CTRL_BIT: + cur = 0; + break; + case KEY_END | KEY_CTRL_BIT: + cur = txt.len; + break; case 0x17 /* ^W */: cur = del_between(&txt, move_word_back(&txt, cur), cur); break; |
