Introduction
Introduction Statistics Contact Development Disclaimer Help
tChange view_get_line to macro to make the error message more useful - ledit - …
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 60f311ec4a85a62f84f76d5a1a05432f08417287
parent 3da18ab09b9d07340479d8e03052c5638cd63d91
Author: lumidify <[email protected]>
Date: Fri, 2 Jun 2023 13:40:53 +0200
Change view_get_line to macro to make the error message more useful
Diffstat:
M keys_basic.c | 2 ++
M uglycrap.h | 2 +-
M view.c | 2 ++
M view.h | 7 ++++++-
4 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/keys_basic.c b/keys_basic.c
t@@ -28,6 +28,7 @@
#include <X11/cursorfont.h>
#include "util.h"
+#include "assert.h"
#include "memory.h"
#include "common.h"
#include "txtbuf.h"
t@@ -2118,6 +2119,7 @@ enter_visual(ledit_view *view, char *text, size_t len) {
(void)text;
(void)len;
view_set_mode(view, VISUAL);
+ /* FIXME: set view->sel_valid? */
view->sel.line1 = view->sel.line2 = view->cur_line;
view->sel.byte1 = view->sel.byte2 = view->cur_index;
view_wipe_line_cursor_attrs(view, view->cur_line);
diff --git a/uglycrap.h b/uglycrap.h
t@@ -1,7 +1,7 @@
#ifndef _UGLYCRAP_H_
#define _UGLYCRAP_H_
-/* FIXME: Figure out where to put it - it would make sens to put it in
+/* FIXME: Figure out where to put it - it would make sense to put it in
keys_command.h, but it is needed by view.h to make the command mode
per-view, but I don't want view.* to depend on keys_command.h */
diff --git a/view.c b/view.c
t@@ -162,6 +162,7 @@ view_unlock(ledit_view *view) {
view->lock_text = NULL;
}
+#if 0
ledit_view_line *
view_get_line(ledit_view *view, size_t index) {
ledit_assert(index < view->lines_num);
t@@ -169,6 +170,7 @@ view_get_line(ledit_view *view, size_t index) {
&view->lines[index] :
&view->lines[index + view->lines_cap - view->lines_num];
}
+#endif
static void
move_line_gap(ledit_view *view, size_t index) {
diff --git a/view.h b/view.h
t@@ -113,7 +113,12 @@ void view_unlock(ledit_view *view);
* The returned line is only valid until the next
* action that appends or deletes line entries.
*/
-ledit_view_line *view_get_line(ledit_view *view, size_t index);
+/* ledit_view_line *view_get_line(ledit_view *view, size_t index); */
+
+/* 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.
+ */
+#define view_get_line(view, index) (ledit_assert((index) < (view)->lines_num),…
/*
* These notification functions are called by the buffer when text
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.