commit 4aca634c431a29518a56b662e0aac57c95737974
parent da472f5508527b1221e1365fa152e2171e877897
Author: lumidify <nobody@lumidify.org>
Date: Sun, 26 Dec 2021 18:27:19 +0100
Wipe line cursor on undo/redo
Diffstat:
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/README b/README
@@ -8,7 +8,12 @@ layout.
Additionally, it allows multiple views on a text buffer so that different
parts of a file can be shown at the same time.
-REQUIREMENTS: pango, xlib (extensions: xkb, xdbe)
+REQUIREMENTS: pango (with xft), xlib (extensions: xkb, xdbe)
+
+Packages to install:
+On OpenBSD: pango
+On MX Linux: libpango1.0-dev, libx11-dev, libxkbfile-dev
+(this is just from memory, I need to test it with a fresh system sometime)
The documentation can be viewed in ledit.1 or at the following locations:
diff --git a/keys_basic.c b/keys_basic.c
@@ -2008,9 +2008,7 @@ undo(ledit_view *view, char *text, size_t len) {
if (num == 0)
num = 1;
view_wipe_selection(view);
- view_wipe_line_cursor_attrs(view, view->cur_line);
view_undo(view, num);
- view_set_line_cursor_attrs(view, view->cur_line, view->cur_index);
finalize_repetition_stack();
return (struct action){ACTION_NONE, NULL};
}
@@ -2026,9 +2024,7 @@ redo(ledit_view *view, char *text, size_t len) {
if (num == 0)
num = 1;
view_wipe_selection(view);
- view_wipe_line_cursor_attrs(view, view->cur_line);
view_redo(view, num);
- view_set_line_cursor_attrs(view, view->cur_line, view->cur_index);
finalize_repetition_stack();
return (struct action){ACTION_NONE, NULL};
}
diff --git a/view.c b/view.c
@@ -1958,38 +1958,44 @@ void
view_undo(ledit_view *view, int num) {
/* FIXME: maybe wipe selection (although I guess this
currently isn't possible in visual mode anyways) */
+ view_wipe_line_cursor_attrs(view, view->cur_line);
for (int i = 0; i < num; i++) {
- view_wipe_line_cursor_attrs(view, view->cur_line);
undo_status s = buffer_undo(view->buffer, view->mode, &view->cur_line, &view->cur_index);
if (view->mode == NORMAL) {
view->cur_index = view_get_legal_normal_pos(
view, view->cur_line, view->cur_index
);
}
- view_set_line_cursor_attrs(view, view->cur_line, view->cur_index);
if (s != UNDO_NORMAL) {
window_show_message(view->window, undo_state_to_str(s), -1);
break;
}
}
+ if (view->mode == NORMAL)
+ view_set_line_cursor_attrs(view, view->cur_line, view->cur_index);
+ else
+ view_wipe_line_cursor_attrs(view, view->cur_line);
}
void
view_redo(ledit_view *view, int num) {
+ view_wipe_line_cursor_attrs(view, view->cur_line);
for (int i = 0; i < num; i++) {
- view_wipe_line_cursor_attrs(view, view->cur_line);
undo_status s = buffer_redo(view->buffer, view->mode, &view->cur_line, &view->cur_index);
if (view->mode == NORMAL) {
view->cur_index = view_get_legal_normal_pos(
view, view->cur_line, view->cur_index
);
}
- view_set_line_cursor_attrs(view, view->cur_line, view->cur_index);
if (s != UNDO_NORMAL) {
window_show_message(view->window, undo_state_to_str(s), -1);
break;
}
}
+ if (view->mode == NORMAL)
+ view_set_line_cursor_attrs(view, view->cur_line, view->cur_index);
+ else
+ view_wipe_line_cursor_attrs(view, view->cur_line);
}
/* FIXME: this could give weird results if the paste occurs in multiple