summaryrefslogtreecommitdiff
path: root/src/dged/buffer.h
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2023-06-14 00:03:47 +0200
committerAlbert Cervin <albert@acervin.com>2023-07-11 21:26:49 +0200
commit3a8ae83aa13636679c151027cace905fa87ebd8e (patch)
tree4a68bfb1e32dc1d6dbd4c8779312f0f32fcba926 /src/dged/buffer.h
parentbc5696e5bbd4739691f53563f3506b30b9be1ad3 (diff)
downloaddged-3a8ae83aa13636679c151027cace905fa87ebd8e.tar.gz
dged-3a8ae83aa13636679c151027cace905fa87ebd8e.tar.xz
dged-3a8ae83aa13636679c151027cace905fa87ebd8e.zip
Implement replace + autocomplete
Autocomplete is currently a POC and works only with find-file.
Diffstat (limited to 'src/dged/buffer.h')
-rw-r--r--src/dged/buffer.h44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/dged/buffer.h b/src/dged/buffer.h
index dad6ef1..28d9797 100644
--- a/src/dged/buffer.h
+++ b/src/dged/buffer.h
@@ -3,7 +3,6 @@
#include <stdio.h>
#include <time.h>
-#include "bits/stdint-uintn.h"
#include "command.h"
#include "lang.h"
#include "text.h"
@@ -13,6 +12,24 @@
struct keymap;
struct command_list;
+enum text_property_type {
+ TextProperty_Colors,
+};
+
+struct text_property_colors {
+ bool set_fg;
+ uint32_t fg;
+ bool set_bg;
+ uint32_t bg;
+};
+
+struct text_property {
+ enum text_property_type type;
+ union {
+ struct text_property_colors colors;
+ };
+};
+
/**
* Margins where buffer text should not be
*/
@@ -90,6 +107,10 @@ struct buffer_location {
uint32_t col;
};
+bool buffer_location_is_between(struct buffer_location location,
+ struct buffer_location start,
+ struct buffer_location end);
+
struct match {
struct buffer_location begin;
struct buffer_location end;
@@ -125,6 +146,12 @@ void buffer_view_scroll_up(struct buffer_view *view, uint32_t height);
void buffer_view_destroy(struct buffer_view *view);
+struct text_property_entry {
+ struct buffer_location start;
+ struct buffer_location end;
+ struct text_property property;
+};
+
/**
* A buffer of text that can be modified, read from and written to disk.
*
@@ -158,6 +185,8 @@ struct buffer {
/** Buffer programming language */
struct language lang;
+
+ VEC(struct text_property_entry) text_properties;
};
struct buffer buffer_create(char *name);
@@ -209,6 +238,19 @@ void buffer_paste(struct buffer_view *view);
void buffer_paste_older(struct buffer_view *view);
void buffer_cut(struct buffer_view *view);
+void buffer_clear_text_properties(struct buffer *buffer);
+
+void buffer_add_text_property(struct buffer *buffer,
+ struct buffer_location start,
+ struct buffer_location end,
+ struct text_property property);
+
+void buffer_get_text_properties(struct buffer *buffer,
+ struct buffer_location location,
+ struct text_property **properties,
+ uint32_t max_nproperties,
+ uint32_t *nproperties);
+
struct text_chunk buffer_get_line(struct buffer *buffer, uint32_t line);
uint32_t buffer_add_update_hook(struct buffer *buffer, update_hook_cb hook,