Introduction
Introduction Statistics Contact Development Disclaimer Help
tFix crash; modify config slightly - ledit - Text editor (WIP)
git clone git://lumidify.org/ledit.git (fast, but not encrypted)
git clone https://lumidify.org/git/ledit.git (encrypted, but very slow)
Log
Files
Refs
README
LICENSE
---
commit 7a93ac1c6f53c9464eb548bef555f22da0d9bbac
parent 9c2c62d13afcfb127994530a319c80897429f662
Author: lumidify <[email protected]>
Date: Sat, 23 Sep 2023 10:51:54 +0200
Fix crash; modify config slightly
Diffstat:
M leditrc.example | 2 +-
M view.c | 33 +++++++++++++++++++----------…
2 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/leditrc.example b/leditrc.example
t@@ -24,7 +24,7 @@ theme = {
bindings = {
language = "English (US)"
basic-keys = {
- bind delete-chars-backwards-multiline keysym backspace modes i…
+ bind delete-chars-backwards-multiline keysym backspace modes i…
bind cursor-left keysym left modes visual|insert|normal
bind cursor-right keysym right modes visual|insert|normal
bind cursor-up keysym up modes visual|insert|normal
diff --git a/view.c b/view.c
t@@ -255,12 +255,15 @@ view_notify_append_line(ledit_view *view, size_t line) {
void
view_notify_delete_lines(ledit_view *view, size_t index1, size_t index2) {
+ /* FIXME: this is needed to avoid some bugs, but maybe check if it bre…
+ int sel_valid = view->sel_valid;
+ view_wipe_selection(view);
if (index2 < view->cur_line) {
view->cur_line -= index2 - index1 + 1;
} else if (index1 <= view->cur_line) {
/* FIXME: set cur_index properly */
if (index2 < view->lines_num - 1) {
- view->cur_line = index2 + 1;
+ view->cur_line = index1;
view->cur_index = 0;
} else if (index1 > 0) {
view->cur_line = index1 - 1;
t@@ -274,7 +277,7 @@ view_notify_delete_lines(ledit_view *view, size_t index1, …
if (vl->cursor_index_valid)
view_set_line_cursor_attrs(view, view->cur_line, view-…
}
- if (view->sel_valid)
+ if (sel_valid)
view_set_selection(view, view->cur_line, view->cur_index, view…
cache_invalidate_from_line(
view->cache, index1, view,
t@@ -1773,21 +1776,25 @@ view_set_selection(ledit_view *view, size_t line1, siz…
sort_range(&l1_new, &b1_new, &l2_new, &b2_new);
sort_range(&view->sel.line1, &view->sel.byte1, &view->sel.line2, &view…
/* FIXME: make this a bit nicer and optimize it */
- if (view->sel.line1 > l2_new || view->sel.line2 < l1_new) {
- for (size_t i = view->sel.line1; i <= view->sel.line2; i++) {
- view_wipe_line_cursor_attrs(view, i);
- }
- } else {
- for (size_t i = view->sel.line1; i < l1_new; i++) {
- view_wipe_line_cursor_attrs(view, i);
- }
- for (size_t i = view->sel.line2; i > l2_new; i--) {
- view_wipe_line_cursor_attrs(view, i);
+ /* FIXME: always reset view->sel so bugs like this can't happen where
+ a function forgets to check sel_valid */
+ if (view->sel_valid) {
+ if (view->sel.line1 > l2_new || view->sel.line2 < l1_new) {
+ for (size_t i = view->sel.line1; i <= view->sel.line2;…
+ view_wipe_line_cursor_attrs(view, i);
+ }
+ } else {
+ for (size_t i = view->sel.line1; i < l1_new; i++) {
+ view_wipe_line_cursor_attrs(view, i);
+ }
+ for (size_t i = view->sel.line2; i > l2_new; i--) {
+ view_wipe_line_cursor_attrs(view, i);
+ }
}
}
for (size_t i = l1_new; i <= l2_new; i++) {
/* only change the ones that were not already selected */
- if (i <= view->sel.line1 || i >= view->sel.line2) {
+ if (!view->sel_valid || i <= view->sel.line1 || i >= view->sel…
ledit_view_line *vl = view_get_line(view, i);
vl->highlight_dirty = 1;
}
You are viewing proxied material from lumidify.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.