Fix bug with scrolling using ctrl-e - ledit - Text editor (WIP) | |
git clone git://lumidify.org/ledit.git (fast, but not encrypted) | |
git clone https://lumidify.org/ledit.git (encrypted, but very slow) | |
git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/… | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit f08805b3d2b41daefe6a552a569440a3e09b4b65 | |
parent 2f53fc9c11a1f7d9261c257e6c53be259bb1f41e | |
Author: lumidify <[email protected]> | |
Date: Thu, 5 Sep 2024 08:50:11 +0200 | |
Fix bug with scrolling using ctrl-e | |
Diffstat: | |
M LICENSE | 2 +- | |
M keys_basic.c | 2 +- | |
M view.c | 7 ++++--- | |
M view.h | 2 ++ | |
4 files changed, 8 insertions(+), 5 deletions(-) | |
--- | |
diff --git a/LICENSE b/LICENSE | |
@@ -6,7 +6,7 @@ Note 4: See LICENSE.ctrlsel for ctrlsel.{c,h} | |
ISC License | |
-Copyright (c) 2021-2023 lumidify <[email protected]> | |
+Copyright (c) 2021-2024 lumidify <[email protected]> | |
Permission to use, copy, modify, and/or distribute this software for any | |
purpose with or without fee is hereby granted, provided that the above | |
diff --git a/keys_basic.c b/keys_basic.c | |
@@ -1781,7 +1781,7 @@ move_cursor_left_right(ledit_view *view, int dir, int all… | |
motion_callback cb; | |
int num = get_key_repeat_and_motion_cb(view, &cb); | |
if (num == -1) | |
- (void)err_invalid_key(view); | |
+ (void)err_invalid_key(view); /* FIXME: why do I not return her… | |
if (num == 0) | |
num = 1; | |
diff --git a/view.c b/view.c | |
@@ -1039,7 +1039,6 @@ view_move_cursor_visually(ledit_view *view, size_t line, … | |
new_index, trailing, dir, | |
&new_index, &trailing | |
); | |
- /* for some reason, this is necessary */ | |
if (new_index < 0) | |
new_index = 0; | |
else if (new_index > (int)cur_line->len) | |
@@ -1580,7 +1579,8 @@ view_get_nearest_legal_pos( | |
/* search for the hard line covering the top of the screen */ | |
size_t hline = line; | |
while (vline->y_offset + vline->h <= view->display_offset && h… | |
- vline = view_get_line(view, ++hline); | |
+ ++hline; | |
+ vline = view_get_line(view, hline); | |
} | |
/* the current hard line is now the one at the very top of the… | |
layout = get_pango_layout(view, hline); | |
@@ -1617,7 +1617,8 @@ view_get_nearest_legal_pos( | |
/* search for the hard line covering the bottom of the screen … | |
size_t hline = line; | |
while (vline->y_offset > view->display_offset + text_h && hlin… | |
- vline = view_get_line(view, --hline); | |
+ --hline; | |
+ vline = view_get_line(view, hline); | |
} | |
/* the current hard line is now the one at the very bottom of … | |
layout = get_pango_layout(view, hline); | |
diff --git a/view.h b/view.h | |
@@ -117,6 +117,8 @@ void view_unlock(ledit_view *view); | |
/* This is very hacky - it's so the actual function calling view_get_line is r… | |
* There probably is a better way to do this. | |
+ * FIXME: couldn't this just use the same trick that assert does? | |
+ * WARNING: Since this is now a macro, the arguments are not allowed to have s… | |
*/ | |
#define view_get_line(view, index) (ledit_assert((index) < (view)->lines_num),… | |