summaryrefslogtreecommitdiff
path: root/src/dged
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2023-05-09 22:51:57 +0200
committerAlbert Cervin <albert@acervin.com>2023-05-09 22:51:57 +0200
commit5a5ec57d8521a5aa7317d2658ead95b8e2fde5b9 (patch)
tree4097ded91a3e9f708903ddd066464bb0779513e0 /src/dged
parent1d8b5da24db92f9598cd6aeb59d283ae39024349 (diff)
downloaddged-5a5ec57d8521a5aa7317d2658ead95b8e2fde5b9.tar.gz
dged-5a5ec57d8521a5aa7317d2658ead95b8e2fde5b9.tar.xz
dged-5a5ec57d8521a5aa7317d2658ead95b8e2fde5b9.zip
Finish buflist implementation
Also fix tests and man page install.
Diffstat (limited to 'src/dged')
-rw-r--r--src/dged/buffer.c3
-rw-r--r--src/dged/buffers.c1
-rw-r--r--src/dged/window.c14
-rw-r--r--src/dged/window.h1
4 files changed, 19 insertions, 0 deletions
diff --git a/src/dged/buffer.c b/src/dged/buffer.c
index 201a75e..f2e7eb9 100644
--- a/src/dged/buffer.c
+++ b/src/dged/buffer.c
@@ -522,6 +522,9 @@ void buffer_read_from_file(struct buffer *b) {
struct buffer buffer_from_file(char *filename) {
char *full_filename = realpath(filename, NULL);
+ if (full_filename == NULL) {
+ full_filename = strdup(filename);
+ }
struct buffer b = create_internal(basename((char *)filename), full_filename);
buffer_read_from_file(&b);
diff --git a/src/dged/buffers.c b/src/dged/buffers.c
index 265a248..99dad9a 100644
--- a/src/dged/buffers.c
+++ b/src/dged/buffers.c
@@ -61,4 +61,5 @@ void buffers_destroy(struct buffers *buffers) {
VEC_FOR_EACH(&buffers->buffers, struct buffer * b) { buffer_destroy(b); }
VEC_DESTROY(&buffers->buffers);
+ VEC_DESTROY(&buffers->add_hooks);
}
diff --git a/src/dged/window.c b/src/dged/window.c
index efdcd29..33659a7 100644
--- a/src/dged/window.c
+++ b/src/dged/window.c
@@ -202,6 +202,20 @@ void windows_set_active(struct window *window) {
}
}
+struct window *window_find_by_buffer(struct buffer *b) {
+ struct window_node *n = BINTREE_ROOT(&g_windows.windows);
+ BINTREE_FIRST(n);
+ while (n != NULL) {
+ struct window *w = &BINTREE_VALUE(n);
+ if (window_buffer(w) == b) {
+ return w;
+ }
+ BINTREE_NEXT(n);
+ }
+
+ return NULL;
+}
+
struct window *windows_get_active() {
return &BINTREE_VALUE(g_windows.active);
}
diff --git a/src/dged/window.h b/src/dged/window.h
index b3284e9..be9b952 100644
--- a/src/dged/window.h
+++ b/src/dged/window.h
@@ -27,6 +27,7 @@ void windows_set_active(struct window *window);
struct window *windows_focus(uint32_t id);
struct window *windows_get_active();
struct window *windows_focus_next();
+struct window *window_find_by_buffer(struct buffer *b);
void window_set_buffer(struct window *window, struct buffer *buffer);
struct buffer *window_buffer(struct window *window);