projects
/
visor
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
hacking the spans
[visor]
/
libvisor
/
include
/
visor.h
diff --git
a/libvisor/include/visor.h
b/libvisor/include/visor.h
index
2846218
..
a9b3ec7
100644
(file)
--- a/
libvisor/include/visor.h
+++ b/
libvisor/include/visor.h
@@
-1,5
+1,5
@@
/*
/*
-This file is part of the visor text editor and text editor framework
+visor - lightweight system-independent text editor and framework
Copyright (C) 2019 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
Copyright (C) 2019 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
@@
-26,8
+26,9
@@
struct visor;
struct vi_buffer;
struct vi_span {
struct vi_buffer;
struct vi_span {
- vi_addr beg;
+ vi_addr start;
unsigned long size;
unsigned long size;
+ int src;
};
enum vi_motdir {
};
enum vi_motdir {
@@
-68,8
+69,14
@@
struct vi_alloc {
void *(*realloc)(void*, unsigned long); /* can be null, will use malloc/free */
};
void *(*realloc)(void*, unsigned long); /* can be null, will use malloc/free */
};
+/* open flags (same as POSIX O_*) */
+enum { VI_RDONLY, VI_WRONLY, VI_RDWR, VI_CREAT = 0x100 };
+/* seek origin (same as C SEEK_*) */
+enum { VI_SEEK_SET, VI_SEEK_CUR, VI_SEEK_END };
+
+
struct vi_fileops {
struct vi_fileops {
- vi_file *(*open)(const char *path);
+ vi_file *(*open)(const char *path, unsigned int flags);
long (*size)(vi_file *file);
void (*close)(vi_file *file);
void *(*map)(vi_file *file);
long (*size)(vi_file *file);
void (*close)(vi_file *file);
void *(*map)(vi_file *file);
@@
-135,6
+142,10
@@
int vi_buf_read(struct vi_buffer *vb, const char *path);
int vi_buf_write(struct vi_buffer *vb, const char *path);
long vi_buf_size(struct vi_buffer *vb);
int vi_buf_write(struct vi_buffer *vb, const char *path);
long vi_buf_size(struct vi_buffer *vb);
+/* find the span which corresponds to the specified text position */
+struct vi_span *vi_buf_find_span(struct vi_buffer *vb, vi_addr at);
+const char *vi_buf_span_text(struct vi_buffer *vb, struct vi_span *span);
+
void vi_buf_ins_begin(struct vi_buffer *vb, vi_motion mot);
void vi_buf_insert(struct vi_buffer *vb, char *s);
void vi_buf_ins_end(struct vi_buffer *vb);
void vi_buf_ins_begin(struct vi_buffer *vb, vi_motion mot);
void vi_buf_insert(struct vi_buffer *vb, char *s);
void vi_buf_ins_end(struct vi_buffer *vb);