summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-08-05 10:33:26 -0400
committerpommicket <pommicket@gmail.com>2023-08-05 10:33:26 -0400
commit2cd73992ef519eb1aaf6c83abe87a34dadf7ac31 (patch)
tree89aa98c9641dd8de2975df6a78a819de1ff38935 /buffer.c
parentb3244ce71e137b4a259d78b7dc043beb2a5c2aa9 (diff)
add some functions for plug-ins
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/buffer.c b/buffer.c
index fae8924..2ce9fdf 100644
--- a/buffer.c
+++ b/buffer.c
@@ -66,6 +66,26 @@ bool buffer_is_named_file(TextBuffer *buffer) {
return buffer->path != NULL;
}
+
+bool buffer_is_view_only(TextBuffer *buffer) {
+ return buffer->view_only;
+}
+
+void buffer_set_view_only(TextBuffer *buffer, bool view_only) {
+ buffer->view_only = view_only;
+}
+
+size_t buffer_get_path(TextBuffer *buffer, char *buf, size_t bufsz) {
+ if (!buffer->path) {
+ if (bufsz) *buf = '\0';
+ return 1;
+ }
+ if (bufsz > 0) {
+ str_cpy(buf, bufsz, buffer->path);
+ }
+ return strlen(buffer->path) + 1;
+}
+
const char *buffer_display_filename(TextBuffer *buffer) {
return buffer->path ? path_filename(buffer->path) : BUFFER_UNTITLED;
}