aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandy Palamar <randy@rnpnr.xyz>2025-12-05 12:05:32 -0700
committerRandy Palamar <randy@rnpnr.xyz>2025-12-16 11:28:44 -0700
commit1d1d19ed30309b39fc5e43c830cabb4cdd004d07 (patch)
tree56bb7c09d3b07118e39e7fc6174403b0235d56a7
parent65dd46e0bba74948c824370a06e509cba462cd72 (diff)
downloadvis-1d1d19ed30309b39fc5e43c830cabb4cdd004d07.tar.gz
vis-1d1d19ed30309b39fc5e43c830cabb4cdd004d07.tar.xz
mark all functions in headers with VIS_EXPORT or VIS_INTERNAL
if vis actually wants to be a library exported symbols may need mark up depending on the platform (eg. __declspec(dllexport)). This needs to be hidden behind a macro because the way you export is not the same on every platform. I did this based on the assumption that vis.h was supposed to be the only interface to the "vis" library. Since nobody actually uses vis as a library I have no idea if this is actually correct. Anyway marking up all prototypes like this allows for one to convert all functions to static if a single translation unit is used by inserting at the start: #define VIS_INTERNAL static #define VIS_EXPORT static
-rw-r--r--array.c3
-rw-r--r--array.h40
-rw-r--r--buffer.c1
-rw-r--r--buffer.h28
-rw-r--r--libutf.c3
-rw-r--r--libutf.h4
-rw-r--r--main.c3
-rw-r--r--map.h30
-rw-r--r--sam.c4
-rw-r--r--sam.h6
-rw-r--r--test/core/Makefile2
-rw-r--r--test/core/array-test.c5
-rw-r--r--text-internal.h22
-rw-r--r--text-motions.h116
-rw-r--r--text-objects.h54
-rw-r--r--text-regex.h14
-rw-r--r--text-util.h16
-rw-r--r--text.h104
-rw-r--r--ui.h54
-rw-r--r--util.h7
-rw-r--r--view.h128
-rw-r--r--vis-core.h64
-rw-r--r--vis-lua.c3
-rw-r--r--vis-lua.h10
-rw-r--r--vis-subprocess.c4
-rw-r--r--vis-subprocess.h10
-rw-r--r--vis.c3
-rw-r--r--vis.h200
28 files changed, 480 insertions, 458 deletions
diff --git a/array.c b/array.c
index f5a34cf..b1e55b2 100644
--- a/array.c
+++ b/array.c
@@ -2,9 +2,10 @@
#include <string.h>
#include <errno.h>
-#include "array.h"
#include "util.h"
+#include "array.h"
+
#define ARRAY_SIZE 16
void array_init(Array *arr) {
diff --git a/array.h b/array.h
index 2cc3362..1d9e1cf 100644
--- a/array.h
+++ b/array.h
@@ -38,26 +38,26 @@ typedef struct {
* .. note:: Is equivalent to ``array_init_sized(arr, sizeof(void*))``.
* @endrst
*/
-void array_init(Array*);
+VIS_INTERNAL void array_init(Array*);
/**
* Initialize an Array object to store arbitrarily sized objects.
*/
-void array_init_sized(Array*, size_t elem_size);
+VIS_INTERNAL void array_init_sized(Array*, size_t elem_size);
/** Initialize Array by using the same element size as in ``from``. */
-void array_init_from(Array*, const Array *from);
+VIS_INTERNAL void array_init_from(Array*, const Array *from);
/** Release storage space. Reinitializes Array object. */
-void array_release(Array*);
+VIS_INTERNAL void array_release(Array*);
/**
* Release storage space and call `free(3)` for each stored pointer.
* @rst
* .. warning:: Assumes array elements to be pointers.
* @endrst
*/
-void array_release_full(Array*);
+VIS_INTERNAL void array_release_full(Array*);
/** Empty array, keep allocated memory. */
-void array_clear(Array*);
+VIS_INTERNAL void array_clear(Array*);
/** Reserve memory to store at least ``count`` elements. */
-bool array_reserve(Array*, size_t count);
+VIS_INTERNAL bool array_reserve(Array*, size_t count);
/**
* Get array element.
* @rst
@@ -66,7 +66,7 @@ bool array_reserve(Array*, size_t count);
* of new elements) might invalidate the pointer.
* @endrst
*/
-void *array_get(const Array*, size_t idx);
+VIS_INTERNAL void *array_get(const Array*, size_t idx);
/**
* Set array element.
* @rst
@@ -74,24 +74,24 @@ void *array_get(const Array*, size_t idx);
* the corresponding memory region will be cleared.
* @endrst
*/
-bool array_set(Array*, size_t idx, void *item);
+VIS_INTERNAL bool array_set(Array*, size_t idx, void *item);
/** Dereference pointer stored in array element. */
-void *array_get_ptr(const Array*, size_t idx);
+VIS_INTERNAL void *array_get_ptr(const Array*, size_t idx);
/** Store the address to which ``item`` points to into the array. */
-bool array_set_ptr(Array*, size_t idx, void *item);
+VIS_INTERNAL bool array_set_ptr(Array*, size_t idx, void *item);
/** Add element to the end of the array. */
-bool array_add(Array*, void *item);
+VIS_INTERNAL bool array_add(Array*, void *item);
/** Add pointer to the end of the array. */
-bool array_add_ptr(Array*, void *item);
+VIS_INTERNAL bool array_add_ptr(Array*, void *item);
/**
* Remove an element by index.
* @rst
* .. note:: Might not shrink underlying memory region.
* @endrst
*/
-bool array_remove(Array*, size_t idx);
+VIS_INTERNAL bool array_remove(Array*, size_t idx);
/** Remove all elements with index greater or equal to ``length``, keep allocated memory. */
-bool array_truncate(Array*, size_t length);
+VIS_INTERNAL bool array_truncate(Array*, size_t length);
/**
* Change length.
* @rst
@@ -99,31 +99,31 @@ bool array_truncate(Array*, size_t length);
* Newly accessible elements preserve their previous values.
* @endrst
*/
-bool array_resize(Array*, size_t length);
+VIS_INTERNAL bool array_resize(Array*, size_t length);
/**
* Sort array, the comparision function works as for `qsort(3)`.
*/
-void array_sort(Array*, int (*compar)(const void*, const void*));
+VIS_INTERNAL void array_sort(Array*, int (*compar)(const void*, const void*));
/**
* Push item onto the top of the stack.
* @rst
* .. note:: Is equivalent to ``array_add(arr, item)``.
* @endrst
*/
-bool array_push(Array*, void *item);
+VIS_INTERNAL bool array_push(Array*, void *item);
/**
* Get and remove item at the top of the stack.
* @rst
* .. warning:: The same ownership rules as for ``array_get`` apply.
* @endrst
*/
-void *array_pop(Array*);
+VIS_INTERNAL void *array_pop(Array*);
/**
* Get item at the top of the stack without removing it.
* @rst
* .. warning:: The same ownership rules as for ``array_get`` apply.
* @endrst
*/
-void *array_peek(const Array*);
+VIS_INTERNAL void *array_peek(const Array*);
#endif
diff --git a/buffer.c b/buffer.c
index 4841b22..709a328 100644
--- a/buffer.c
+++ b/buffer.c
@@ -4,7 +4,6 @@
#include <stdio.h>
#include "buffer.h"
-#include "util.h"
#ifndef BUFFER_SIZE
#define BUFFER_SIZE 1024
diff --git a/buffer.h b/buffer.h
index 1c30a0e..66e8d4d 100644
--- a/buffer.h
+++ b/buffer.h
@@ -21,36 +21,36 @@ typedef struct {
} Buffer;
/** Release all resources, reinitialize buffer. */
-void buffer_release(Buffer*);
+VIS_INTERNAL void buffer_release(Buffer*);
/** Reserve space to store at least ``size`` bytes.*/
-bool buffer_reserve(Buffer*, size_t size);
+VIS_INTERNAL bool buffer_reserve(Buffer*, size_t size);
/** Reserve space for at least ``len`` *more* bytes. */
-bool buffer_grow(Buffer*, size_t len);
+VIS_INTERNAL bool buffer_grow(Buffer*, size_t len);
/** If buffer is non-empty, make sure it is ``NUL`` terminated. */
-bool buffer_terminate(Buffer*);
+VIS_INTERNAL bool buffer_terminate(Buffer*);
/** Set buffer content, growing the buffer as needed. */
-bool buffer_put(Buffer*, const void *data, size_t len);
+VIS_INTERNAL bool buffer_put(Buffer*, const void *data, size_t len);
/** Set buffer content to ``NUL`` terminated data. */
-bool buffer_put0(Buffer*, const char *data);
+VIS_INTERNAL bool buffer_put0(Buffer*, const char *data);
/** Remove ``len`` bytes starting at ``pos``. */
-bool buffer_remove(Buffer*, size_t pos, size_t len);
+VIS_INTERNAL bool buffer_remove(Buffer*, size_t pos, size_t len);
/** Insert NUL-terminated data at pos. */
-bool buffer_insert0(Buffer*, size_t pos, const char *data);
+VIS_INTERNAL bool buffer_insert0(Buffer*, size_t pos, const char *data);
/** Append further content to the end. */
-bool buffer_append(Buffer*, const void *data, size_t len);
+VIS_INTERNAL bool buffer_append(Buffer*, const void *data, size_t len);
/** Append NUL-terminated data. */
-bool buffer_append0(Buffer*, const char *data);
+VIS_INTERNAL bool buffer_append0(Buffer*, const char *data);
/** Append formatted buffer content, ensures NUL termination on success. */
-bool buffer_appendf(Buffer*, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+VIS_INTERNAL bool buffer_appendf(Buffer*, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
/** Return length of a buffer without trailing NUL byte. */
-size_t buffer_length0(Buffer*);
+VIS_INTERNAL size_t buffer_length0(Buffer*);
/**
* Get pointer to buffer data.
* Guaranteed to return a NUL terminated string even if buffer is empty.
*/
-const char *buffer_content0(Buffer*);
+VIS_INTERNAL const char *buffer_content0(Buffer*);
/** ``read(3p)`` like interface for reading into a Buffer (``context``) */
-ssize_t read_into_buffer(void *context, char *data, size_t len);
+VIS_INTERNAL ssize_t read_into_buffer(void *context, char *data, size_t len);
#endif
diff --git a/libutf.c b/libutf.c
index 2a82dc7..108595e 100644
--- a/libutf.c
+++ b/libutf.c
@@ -1,7 +1,8 @@
/* libutf8 © 2012-2015 Connor Lane Smith <cls@lubutu.com> */
-#include "libutf.h"
#include "util.h"
+#include "libutf.h"
+
int
runelen(Rune r)
{
diff --git a/libutf.h b/libutf.h
index a2b81b7..30255cc 100644
--- a/libutf.h
+++ b/libutf.h
@@ -28,7 +28,7 @@ typedef unsigned long Rune;
#define Runeself 0x80 /* rune and utf are equal (<) */
#define Runemax RUNE_C(0x10FFFF) /* maximum rune value */
-int runelen(Rune r);
-int runetochar(char *s, const Rune *p);
+VIS_INTERNAL int runelen(Rune r);
+VIS_INTERNAL int runetochar(char *s, const Rune *p);
#endif
diff --git a/main.c b/main.c
index 953f6e4..458ef4c 100644
--- a/main.c
+++ b/main.c
@@ -10,13 +10,14 @@
#include <sys/stat.h>
#include <sys/types.h>
+#include "util.h"
+
#include "ui.h"
#include "vis.h"
#include "vis-lua.h"
#include "text-util.h"
#include "text-motions.h"
#include "text-objects.h"
-#include "util.h"
#include "libutf.h"
#include "array.h"
#include "buffer.h"
diff --git a/map.h b/map.h
index d3457d9..490b4d9 100644
--- a/map.h
+++ b/map.h
@@ -1,7 +1,7 @@
#ifndef MAP_H
#define MAP_H
-#include <stdbool.h>
+#include "util.h"
/**
* @file
@@ -13,19 +13,19 @@
typedef struct Map Map;
/** Allocate a new map. */
-Map *map_new(void);
+VIS_INTERNAL Map *map_new(void);
/**
* Lookup a value, returns ``NULL`` if not found.
* @param map The map to search within.
* @param key The key to look up.
*/
-void *map_get(const Map *map, const char *key);
+VIS_INTERNAL void *map_get(const Map *map, const char *key);
/**
* Get first element of the map, or ``NULL`` if empty.
* @param map The map to query.
* @param key Updated with the key of the first element.
*/
-void *map_first(const Map *map, const char **key);
+VIS_INTERNAL void *map_first(const Map *map, const char **key);
/**
* Lookup element by unique prefix match.
* @param map The map to search within.
@@ -33,14 +33,14 @@ void *map_first(const Map *map, const char **key);
* @return The corresponding value, if the given prefix is unique.
* Otherwise ``NULL``.
*/
-void *map_closest(const Map *map, const char *prefix);
+VIS_INTERNAL void *map_closest(const Map *map, const char *prefix);
/**
* Check whether the map contains the given prefix, or
* whether it can be extended to match a key of a map element.
* @param map The map to check.
* @param prefix The prefix to search for.
*/
-bool map_contains(const Map *map, const char *prefix);
+VIS_INTERNAL bool map_contains(const Map *map, const char *prefix);
/**
* Store a key value pair in the map.
* @param map The map to store the key-value pair in.
@@ -49,20 +49,20 @@ bool map_contains(const Map *map, const char *prefix);
* @return False if we run out of memory, or if the key
* already appears in the map.
*/
-bool map_put(Map *map, const char *key, const void *value);
+VIS_INTERNAL bool map_put(Map *map, const char *key, const void *value);
/**
* Remove a map element.
* @param map The map to remove the element from.
* @param key The key of the element to remove.
* @return The removed entry or ``NULL`` if no such element exists.
*/
-void *map_delete(Map *map, const char *key);
+VIS_INTERNAL void *map_delete(Map *map, const char *key);
/**
* Copy all entries from ``src`` into ``dest``, overwrites existing entries in ``dest``.
* @param dest The destination map.
* @param src The source map.
*/
-bool map_copy(Map *dest, Map *src);
+VIS_INTERNAL bool map_copy(Map *dest, Map *src);
/**
* Ordered iteration over a map.
* Invokes the passed callback for every map entry.
@@ -71,7 +71,7 @@ bool map_copy(Map *dest, Map *src);
* @param handle A function invoked for every map element.
* @param data A context pointer, passed as last argument to ``handle``.
*/
-void map_iterate(const Map *map, bool (*handle)(const char *key, void *value, void *data), const void *data);
+VIS_INTERNAL void map_iterate(const Map *map, bool (*handle)(const char *key, void *value, void *data), const void *data);
/**
* Get a sub map matching a prefix.
* @param map The map to get the sub-map from.
@@ -81,22 +81,22 @@ void map_iterate(const Map *map, bool (*handle)(const char *key, void *value, vo
* Do not alter the map while using the return value.
* @endrst
*/
-const Map *map_prefix(const Map *map, const char *prefix);
+VIS_INTERNAL const Map *map_prefix(const Map *map, const char *prefix);
/**
* Test whether the map is empty (contains no elements).
* @param map The map to check.
*/
-bool map_empty(const Map *map);
+VIS_INTERNAL bool map_empty(const Map *map);
/**
* Empty the map.
* @param map The map to clear.
*/
-void map_clear(Map *map);
+VIS_INTERNAL void map_clear(Map *map);
/**
* Release all memory associated with this map.
* @param map The map to free.
*/
-void map_free(Map *map);
+VIS_INTERNAL void map_free(Map *map);
/**
* Call `free(3)` for every map element, then free the map itself.
* @param map The map to free its elements and itself.
@@ -104,6 +104,6 @@ void map_free(Map *map);
* .. warning:: Assumes map elements to be pointers.
* @endrst
*/
-void map_free_full(Map *map);
+VIS_INTERNAL void map_free_full(Map *map);
#endif
diff --git a/sam.c b/sam.c
index 0f9810d..2d6e634 100644
--- a/sam.c
+++ b/sam.c
@@ -24,6 +24,9 @@
#include <unistd.h>
#include <limits.h>
#include <fcntl.h>
+
+#include "util.h"
+
#include "sam.h"
#include "vis-core.h"
#include "buffer.h"
@@ -31,7 +34,6 @@
#include "text-motions.h"
#include "text-objects.h"
#include "text-regex.h"
-#include "util.h"
#define MAX_ARGV 8
diff --git a/sam.h b/sam.h
index 0de831e..4c37da3 100644
--- a/sam.h
+++ b/sam.h
@@ -23,8 +23,8 @@ enum SamError {
SAM_ERR_COUNT,
};
-bool sam_init(Vis*);
-enum SamError sam_cmd(Vis*, const char *cmd);
-const char *sam_error(enum SamError);
+VIS_INTERNAL bool sam_init(Vis*);
+VIS_INTERNAL enum SamError sam_cmd(Vis*, const char *cmd);
+VIS_INTERNAL const char *sam_error(enum SamError);
#endif
diff --git a/test/core/Makefile b/test/core/Makefile
index 5f1e965..4430cde 100644
--- a/test/core/Makefile
+++ b/test/core/Makefile
@@ -28,7 +28,7 @@ map-test: config.h map-test.c ../../map.c
array-test: config.h array-test.c ../../array.c
@echo Compiling $@ binary
- @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_EXTRA} ${filter %.c, $^} ${SRC} ${LDFLAGS} -o $@
+ @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_EXTRA} array-test.c ${SRC} ${LDFLAGS} -o $@
debug: clean
$(MAKE) CFLAGS_EXTRA='${CFLAGS_EXTRA} ${CFLAGS_DEBUG}'
diff --git a/test/core/array-test.c b/test/core/array-test.c
index 72a6678..e4da4f6 100644
--- a/test/core/array-test.c
+++ b/test/core/array-test.c
@@ -4,9 +4,10 @@
#include <string.h>
#include <stdio.h>
#include <errno.h>
+
#include "tap.h"
-#include "array.h"
-#include "util.h"
+
+#include "array.c"
typedef struct {
char key[64];
diff --git a/text-internal.h b/text-internal.h
index 5ed84ae..3f9052f 100644
--- a/text-internal.h
+++ b/text-internal.h
@@ -19,17 +19,17 @@ typedef struct {
} type;
} Block;
-Block *block_alloc(size_t size);
-Block *block_read(size_t size, int fd);
-Block *block_mmap(size_t size, int fd, off_t offset);
-Block *block_load(int dirfd, const char *filename, enum TextLoadMethod method, struct stat *info);
-void block_free(Block*);
-bool block_capacity(Block*, size_t len);
-const char *block_append(Block*, const char *data, size_t len);
-bool block_insert(Block*, size_t pos, const char *data, size_t len);
-bool block_delete(Block*, size_t pos, size_t len);
+VIS_INTERNAL Block *block_alloc(size_t size);
+VIS_INTERNAL Block *block_read(size_t size, int fd);
+VIS_INTERNAL Block *block_mmap(size_t size, int fd, off_t offset);
+VIS_INTERNAL Block *block_load(int dirfd, const char *filename, enum TextLoadMethod method, struct stat *info);
+VIS_INTERNAL void block_free(Block*);
+VIS_INTERNAL bool block_capacity(Block*, size_t len);
+VIS_INTERNAL const char *block_append(Block*, const char *data, size_t len);
+VIS_INTERNAL bool block_insert(Block*, size_t pos, const char *data, size_t len);
+VIS_INTERNAL bool block_delete(Block*, size_t pos, size_t len);
-Block *text_block_mmaped(Text*);
-void text_saved(Text*, struct stat *meta);
+VIS_INTERNAL Block *text_block_mmaped(Text*);
+VIS_INTERNAL void text_saved(Text*, struct stat *meta);
#endif
diff --git a/text-motions.h b/text-motions.h
index 1cb21d8..4bfc6c2 100644
--- a/text-motions.h
+++ b/text-motions.h
@@ -9,24 +9,24 @@
#include "text.h"
#include "text-regex.h"
-size_t text_begin(Text*, size_t pos);
-size_t text_end(Text*, size_t pos);
+VIS_INTERNAL size_t text_begin(Text*, size_t pos);
+VIS_INTERNAL size_t text_end(Text*, size_t pos);
/* char refers to a grapheme (might skip over multiple Unicode codepoints) */
-size_t text_char_next(Text*, size_t pos);
-size_t text_char_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_char_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_char_prev(Text*, size_t pos);
-size_t text_codepoint_next(Text*, size_t pos);
-size_t text_codepoint_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_codepoint_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_codepoint_prev(Text*, size_t pos);
/* find the given substring either in forward or backward direction.
* does not wrap around at file start / end. If no match is found return
* original position */
-size_t text_find_next(Text*, size_t pos, const char *s);
-size_t text_find_prev(Text*, size_t pos, const char *s);
+VIS_INTERNAL size_t text_find_next(Text*, size_t pos, const char *s);
+VIS_INTERNAL size_t text_find_prev(Text*, size_t pos, const char *s);
/* same as above but limit searched range to the line containing pos */
-size_t text_line_find_next(Text*, size_t pos, const char *s);
-size_t text_line_find_prev(Text*, size_t pos, const char *s);
+VIS_INTERNAL size_t text_line_find_next(Text*, size_t pos, const char *s);
+VIS_INTERNAL size_t text_line_find_prev(Text*, size_t pos, const char *s);
/* begin finish next
* v v v
@@ -34,64 +34,64 @@ size_t text_line_find_prev(Text*, size_t pos, const char *s);
* ^ ^ ^
* prev start end
*/
-size_t text_line_prev(Text*, size_t pos);
-size_t text_line_begin(Text*, size_t pos);
-size_t text_line_start(Text*, size_t pos);
-size_t text_line_finish(Text*, size_t pos);
-size_t text_line_end(Text*, size_t pos);
-size_t text_line_next(Text*, size_t pos);
-size_t text_line_offset(Text*, size_t pos, size_t off);
+VIS_INTERNAL size_t text_line_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_begin(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_start(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_finish(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_end(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_offset(Text*, size_t pos, size_t off);
/* get grapheme count of the line upto `pos' */
-int text_line_char_get(Text*, size_t pos);
+VIS_INTERNAL int text_line_char_get(Text*, size_t pos);
/* get position of the `count' grapheme in the line containing `pos' */
-size_t text_line_char_set(Text*, size_t pos, int count);
+VIS_INTERNAL size_t text_line_char_set(Text*, size_t pos, int count);
/* get display width of line upto `pos' */
-int text_line_width_get(Text*, size_t pos);
+VIS_INTERNAL int text_line_width_get(Text*, size_t pos);
/* get position of character being displayed at `width' in line containing `pos' */
-size_t text_line_width_set(Text*, size_t pos, int width);
+VIS_INTERNAL size_t text_line_width_set(Text*, size_t pos, int width);
/* move to the next/previous grapheme on the same line */
-size_t text_line_char_next(Text*, size_t pos);
-size_t text_line_char_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_char_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_char_prev(Text*, size_t pos);
/* move to the next/previous empty line */
-size_t text_line_empty_next(Text*, size_t pos);
-size_t text_line_empty_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_empty_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_empty_prev(Text*, size_t pos);
/* move to start of next/previous blank line */
-size_t text_line_blank_next(Text*, size_t pos);
-size_t text_line_blank_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_blank_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_blank_prev(Text*, size_t pos);
/* move to same offset in previous/next line */
-size_t text_line_up(Text*, size_t pos);
-size_t text_line_down(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_up(Text*, size_t pos);
+VIS_INTERNAL size_t text_line_down(Text*, size_t pos);
/* functions to iterate over all line beginnings in a given range */
-size_t text_range_line_first(Text*, Filerange*);
-size_t text_range_line_last(Text*, Filerange*);
-size_t text_range_line_next(Text*, Filerange*, size_t pos);
-size_t text_range_line_prev(Text*, Filerange*, size_t pos);
+VIS_INTERNAL size_t text_range_line_first(Text*, Filerange*);
+VIS_INTERNAL size_t text_range_line_last(Text*, Filerange*);
+VIS_INTERNAL size_t text_range_line_next(Text*, Filerange*, size_t pos);
+VIS_INTERNAL size_t text_range_line_prev(Text*, Filerange*, size_t pos);
/*
* A longword consists of a sequence of non-blank characters, separated with
* white space. TODO?: An empty line is also considered to be a word.
* This is equivalent to a WORD in vim terminology.
*/
-size_t text_longword_end_next(Text*, size_t pos);
-size_t text_longword_end_prev(Text*, size_t pos);
-size_t text_longword_start_next(Text*, size_t pos);
-size_t text_longword_start_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_longword_end_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_longword_end_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_longword_start_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_longword_start_prev(Text*, size_t pos);
/*
* A word consists of a sequence of letters, digits and underscores, or a
* sequence of other non-blank characters, separated with white space.
* TODO?: An empty line is also considered to be a word.
* This is equivalent to a word (lowercase) in vim terminology.
*/
-size_t text_word_end_next(Text*, size_t pos);
-size_t text_word_end_prev(Text*, size_t pos);
-size_t text_word_start_next(Text*, size_t pos);
-size_t text_word_start_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_word_end_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_word_end_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_word_start_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_word_start_prev(Text*, size_t pos);
/*
* More general versions of the above, define your own word boundaries.
*/
-size_t text_customword_start_next(Text*, size_t pos, int (*isboundary)(int));
-size_t text_customword_start_prev(Text*, size_t pos, int (*isboundary)(int));
-size_t text_customword_end_next(Text*, size_t pos, int (*isboundary)(int));
-size_t text_customword_end_prev(Text*, size_t pos, int (*isboundary)(int));
+VIS_INTERNAL size_t text_customword_start_next(Text*, size_t pos, int (*isboundary)(int));
+VIS_INTERNAL size_t text_customword_start_prev(Text*, size_t pos, int (*isboundary)(int));
+VIS_INTERNAL size_t text_customword_end_next(Text*, size_t pos, int (*isboundary)(int));
+VIS_INTERNAL size_t text_customword_end_prev(Text*, size_t pos, int (*isboundary)(int));
/* TODO: implement the following semantics
* A sentence is defined as ending at a '.', '!' or '?' followed by either the
* end of a line, or by a space or tab. Any number of closing ')', ']', '"'
@@ -99,34 +99,34 @@ size_t text_customword_end_prev(Text*, size_t pos, int (*isboundary)(int));
* tabs or end of line. A paragraph and section boundary is also a sentence
* boundary.
*/
-size_t text_sentence_next(Text*, size_t pos);
-size_t text_sentence_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_sentence_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_sentence_prev(Text*, size_t pos);
/* TODO: implement the following semantics
* A paragraph begins after each empty line. A section boundary is also a
* paragraph boundary. Note that a blank line (only containing white space)
* is NOT a paragraph boundary.
*/
-size_t text_paragraph_next(Text*, size_t pos);
-size_t text_paragraph_prev(Text*, size_t pos);
+VIS_INTERNAL size_t text_paragraph_next(Text*, size_t pos);
+VIS_INTERNAL size_t text_paragraph_prev(Text*, size_t pos);
/* A section begins after a form-feed in the first column.
size_t text_section_next(Text*, size_t pos);
size_t text_section_prev(Text*, size_t pos);
*/
-size_t text_block_start(Text*, size_t pos);
-size_t text_block_end(Text*, size_t pos);
-size_t text_parenthesis_start(Text*, size_t pos);
-size_t text_parenthesis_end(Text*, size_t pos);
+VIS_INTERNAL size_t text_block_start(Text*, size_t pos);
+VIS_INTERNAL size_t text_block_end(Text*, size_t pos);
+VIS_INTERNAL size_t text_parenthesis_start(Text*, size_t pos);
+VIS_INTERNAL size_t text_parenthesis_end(Text*, size_t pos);
/* search corresponding '(', ')', '{', '}', '[', ']', '>', '<', '"', ''' */
-size_t text_bracket_match(Text*, size_t pos, const Filerange *limits);
+VIS_INTERNAL size_t text_bracket_match(Text*, size_t pos, const Filerange *limits);
/* same as above but explicitly specify symbols to match */
-size_t text_bracket_match_symbol(Text*, size_t pos, const char *symbols, const Filerange *limits);
+VIS_INTERNAL size_t text_bracket_match_symbol(Text*, size_t pos, const char *symbols, const Filerange *limits);
/* search the given regex pattern in either forward or backward direction,
* starting from pos. Does wrap around if no match was found. */
-size_t text_search_forward(Text *txt, size_t pos, Regex *regex);
-size_t text_search_backward(Text *txt, size_t pos, Regex *regex);
+VIS_INTERNAL size_t text_search_forward(Text *txt, size_t pos, Regex *regex);
+VIS_INTERNAL size_t text_search_backward(Text *txt, size_t pos, Regex *regex);
/* is c a special symbol delimiting a word? */
-int is_word_boundary(int c);
+VIS_INTERNAL int is_word_boundary(int c);
#endif
diff --git a/text-objects.h b/text-objects.h
index 3fb829e..d9ea218 100644
--- a/text-objects.h
+++ b/text-objects.h
@@ -10,48 +10,48 @@
#include "text.h"
/* return range covering the entire text */
-Filerange text_object_entire(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_entire(Text*, size_t pos);
/* word which happens to be at pos without any neighbouring white spaces */
-Filerange text_object_word(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_word(Text*, size_t pos);
/* includes trailing white spaces. If at pos happens to be a white space
* include all neighbouring leading white spaces and the following word. */
-Filerange text_object_word_outer(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_word_outer(Text*, size_t pos);
/* find next occurrence of `word' (as word not substring) in forward/backward direction */
-Filerange text_object_word_find_next(Text*, size_t pos, const char *word);
-Filerange text_object_word_find_prev(Text*, size_t pos, const char *word);
+VIS_INTERNAL Filerange text_object_word_find_next(Text*, size_t pos, const char *word);
+VIS_INTERNAL Filerange text_object_word_find_prev(Text*, size_t pos, const char *word);
/* find next occurrence of a literal string (not regex) in forward/backward direction */
-Filerange text_object_find_next(Text *txt, size_t pos, const char *search);
-Filerange text_object_find_prev(Text *txt, size_t pos, const char *search);
+VIS_INTERNAL Filerange text_object_find_next(Text *txt, size_t pos, const char *search);
+VIS_INTERNAL Filerange text_object_find_prev(Text *txt, size_t pos, const char *search);
/* same semantics as above but for a longword (i.e. delimited by white spaces) */
-Filerange text_object_longword(Text*, size_t pos);
-Filerange text_object_longword_outer(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_longword(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_longword_outer(Text*, size_t pos);
-Filerange text_object_line(Text*, size_t pos);
-Filerange text_object_line_inner(Text*, size_t pos);
-Filerange text_object_sentence(Text*, size_t pos);
-Filerange text_object_paragraph(Text*, size_t pos);
-Filerange text_object_paragraph_outer(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_line(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_line_inner(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_sentence(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_paragraph(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_paragraph_outer(Text*, size_t pos);
/* these are inner text objects i.e. the delimiters themself are not
* included in the range */
-Filerange text_object_square_bracket(Text*, size_t pos);
-Filerange text_object_curly_bracket(Text*, size_t pos);
-Filerange text_object_angle_bracket(Text*, size_t pos);
-Filerange text_object_parenthesis(Text*, size_t pos);
-Filerange text_object_quote(Text*, size_t pos);
-Filerange text_object_single_quote(Text*, size_t pos);
-Filerange text_object_backtick(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_square_bracket(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_curly_bracket(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_angle_bracket(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_parenthesis(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_quote(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_single_quote(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_backtick(Text*, size_t pos);
/* match a search term in either forward or backward direction */
-Filerange text_object_search_forward(Text*, size_t pos, Regex*);
-Filerange text_object_search_backward(Text*, size_t pos, Regex*);
+VIS_INTERNAL Filerange text_object_search_forward(Text*, size_t pos, Regex*);
+VIS_INTERNAL Filerange text_object_search_backward(Text*, size_t pos, Regex*);
/* match all lines with same indentation level as the current one */
-Filerange text_object_indentation(Text*, size_t pos);
+VIS_INTERNAL Filerange text_object_indentation(Text*, size_t pos);
/* extend a range to cover whole lines */
-Filerange text_range_linewise(Text*, Filerange*);
+VIS_INTERNAL Filerange text_range_linewise(Text*, Filerange*);
/* trim leading and trailing white spaces from range */
-Filerange text_range_inner(Text*, Filerange*);
+VIS_INTERNAL Filerange text_range_inner(Text*, Filerange*);
/* test whether a given range covers whole lines */
-bool text_range_is_linewise(Text*, Filerange*);
+VIS_INTERNAL bool text_range_is_linewise(Text*, Filerange*);
#endif
diff --git a/text-regex.h b/text-regex.h
index dd87c1c..4b64218 100644
--- a/text-regex.h
+++ b/text-regex.h
@@ -14,12 +14,12 @@
typedef struct Regex Regex;
typedef Filerange RegexMatch;
-Regex *text_regex_new(void);
-int text_regex_compile(Regex*, const char *pattern, int cflags);
-size_t text_regex_nsub(Regex*);
-void text_regex_free(Regex*);
-int text_regex_match(Regex*, const char *data, int eflags);
-int text_search_range_forward(Text*, size_t pos, size_t len, Regex *r, size_t nmatch, RegexMatch pmatch[], int eflags);
-int text_search_range_backward(Text*, size_t pos, size_t len, Regex *r, size_t nmatch, RegexMatch pmatch[], int eflags);
+VIS_INTERNAL Regex *text_regex_new(void);
+VIS_INTERNAL int text_regex_compile(Regex*, const char *pattern, int cflags);
+VIS_INTERNAL size_t text_regex_nsub(Regex*);
+VIS_INTERNAL void text_regex_free(Regex*);
+VIS_INTERNAL int text_regex_match(Regex*, const char *data, int eflags);
+VIS_INTERNAL int text_search_range_forward(Text*, size_t pos, size_t len, Regex *r, size_t nmatch, RegexMatch pmatch[], int eflags);
+VIS_INTERNAL int text_search_range_backward(Text*, size_t pos, size_t len, Regex *r, size_t nmatch, RegexMatch pmatch[], int eflags);
#endif
diff --git a/text-util.h b/text-util.h
index 85bfa04..922bab3 100644
--- a/text-util.h
+++ b/text-util.h
@@ -12,20 +12,20 @@
/* create an empty / invalid range of size zero */
#define text_range_empty() (Filerange){.start = EPOS, .end = EPOS}
/* merge two ranges into a new one which contains both of them */
-Filerange text_range_union(const Filerange*, const Filerange*);
+VIS_INTERNAL Filerange text_range_union(const Filerange*, const Filerange*);
/* get intersection of two ranges */
-Filerange text_range_intersect(const Filerange*, const Filerange*);
+VIS_INTERNAL Filerange text_range_intersect(const Filerange*, const Filerange*);
/* create new range [min(a,b), max(a,b)] */
-Filerange text_range_new(size_t a, size_t b);
+VIS_INTERNAL Filerange text_range_new(size_t a, size_t b);
/* test whether two ranges are equal */
-bool text_range_equal(const Filerange*, const Filerange*);
+VIS_INTERNAL bool text_range_equal(const Filerange*, const Filerange*);
/* test whether two ranges overlap */
-bool text_range_overlap(const Filerange*, const Filerange*);
+VIS_INTERNAL bool text_range_overlap(const Filerange*, const Filerange*);
/* test whether a given position is within a certain range */
-bool text_range_contains(const Filerange*, size_t pos);
+VIS_INTERNAL bool text_range_contains(const Filerange*, size_t pos);
/* count the number of graphemes in data */
-int text_char_count(const char *data, size_t len);
+VIS_INTERNAL int text_char_count(const char *data, size_t len);
/* get the approximate display width of data */
-int text_string_width(const char *data, size_t len);
+VIS_INTERNAL int text_string_width(const char *data, size_t len);
#endif
diff --git a/text.h b/text.h
index 33666ff..dc8fdfc 100644
--- a/text.h
+++ b/text.h
@@ -9,6 +9,8 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include "util.h"
+
/** A mark. */
typedef uintptr_t Mark;
@@ -93,7 +95,7 @@ enum TextLoadMethod {
* .. note:: Equivalent to ``text_load_method(filename, TEXT_LOAD_AUTO)``.
* @endrst
*/
-Text *text_load(const char *filename);
+VIS_INTERNAL Text *text_load(const char *filename);
/**
* Create a text instance populated with the given file content.
*
@@ -107,17 +109,17 @@ Text *text_load(const char *filename);
* - ``ENOTSUP`` otherwise.
* @endrst
*/
-Text *text_load_method(const char *filename, enum TextLoadMethod method);
-Text *text_loadat_method(int dirfd, const char *filename, enum TextLoadMethod);
+VIS_INTERNAL Text *text_load_method(const char *filename, enum TextLoadMethod method);
+VIS_INTERNAL Text *text_loadat_method(int dirfd, const char *filename, enum TextLoadMethod);
/** Release all resources associated with this text instance. */
-void text_free(Text*);
+VIS_INTERNAL void text_free(Text*);
/**
* @}
* @defgroup state Text State
* @{
*/
/** Return the size in bytes of the whole text. */
-size_t text_size(const Text*);
+VIS_INTERNAL size_t text_size(const Text*);
/**
* Get file information at time of load or last save, whichever happened more
* recently.
@@ -128,9 +130,9 @@ size_t text_size(const Text*);
* @endrst
* @return See ``stat(2)`` for details.
*/
-struct stat text_stat(const Text*);
+VIS_INTERNAL struct stat text_stat(const Text*);
/** Query whether the text contains any unsaved modifications. */
-bool text_modified(const Text*);
+VIS_INTERNAL bool text_modified(const Text*);
/**
* @}
* @defgroup modify Text Modification
@@ -145,7 +147,7 @@ bool text_modified(const Text*);
* @param len The length of the data in bytes.
* @return Whether the insertion succeeded.
*/
-bool text_insert(Text *txt, size_t pos, const char *data, size_t len);
+VIS_INTERNAL bool text_insert(Text *txt, size_t pos, const char *data, size_t len);
/**
* Delete data at given byte position.
*
@@ -154,10 +156,10 @@ bool text_insert(Text *txt, size_t pos, const char *data, size_t len);
* @param len The number of bytes to delete, starting from ``pos``.
* @return Whether the deletion succeeded.
*/
-bool text_delete(Text *txt, size_t pos, size_t len);
-bool text_delete_range(Text *txt, const Filerange*);
-bool text_printf(Text *txt, size_t pos, const char *format, ...) __attribute__((format(printf, 3, 4)));
-bool text_appendf(Text *txt, const char *format, ...) __attribute__((format(printf, 2, 3)));
+VIS_INTERNAL bool text_delete(Text *txt, size_t pos, size_t len);
+VIS_INTERNAL bool text_delete_range(Text *txt, const Filerange*);
+VIS_INTERNAL bool text_printf(Text *txt, size_t pos, const char *format, ...) __attribute__((format(printf, 3, 4)));
+VIS_INTERNAL bool text_appendf(Text *txt, const char *format, ...) __attribute__((format(printf, 2, 3)));
/**
* @}
* @defgroup history Undo/Redo History
@@ -166,7 +168,7 @@ bool text_appendf(Text *txt, const char *format, ...) __attribute__((format(prin
/**
* Create a text snapshot, that is a vertex in the history graph.
*/
-bool text_snapshot(Text*);
+VIS_INTERNAL bool text_snapshot(Text*);
/**
* Revert to previous snapshot along the main branch.
* @rst
@@ -175,7 +177,7 @@ bool text_snapshot(Text*);
* @return The position of the first change or ``EPOS``, if already at the
* oldest state i.e. there was nothing to undo.
*/
-size_t text_undo(Text*);
+VIS_INTERNAL size_t text_undo(Text*);
/**
* Reapply an older change along the main branch.
* @rst
@@ -184,27 +186,27 @@ size_t text_undo(Text*);
* @return The position of the first change or ``EPOS``, if already at the
* newest state i.e. there was nothing to redo.
*/
-size_t text_redo(Text*);
-size_t text_earlier(Text*);
-size_t text_later(Text*);
+VIS_INTERNAL size_t text_redo(Text*);
+VIS_INTERNAL size_t text_earlier(Text*);
+VIS_INTERNAL size_t text_later(Text*);
/**
* Restore the text to the state closest to the time given
*/
-size_t text_restore(Text*, time_t);
+VIS_INTERNAL size_t text_restore(Text*, time_t);
/**
* Get creation time of current state.
* @rst
* .. note:: TODO: This is currently not the same as the time of the last snapshot.
* @endrst
*/
-time_t text_state(const Text*);
+VIS_INTERNAL time_t text_state(const Text*);
/**
* @}
* @defgroup lines Line Operations
* @{
*/
-size_t text_pos_by_lineno(Text*, size_t lineno);
-size_t text_lineno_by_pos(Text*, size_t pos);
+VIS_INTERNAL size_t text_pos_by_lineno(Text*, size_t lineno);
+VIS_INTERNAL size_t text_lineno_by_pos(Text*, size_t pos);
/**
* @}
@@ -222,7 +224,7 @@ size_t text_lineno_by_pos(Text*, size_t pos);
* return an artificial NUL byte at EOF.
* @endrst
*/
-bool text_byte_get(const Text *txt, size_t pos, char *byte);
+VIS_INTERNAL bool text_byte_get(const Text *txt, size_t pos, char *byte);
/**
* Store at most ``len`` bytes starting from ``pos`` into ``buf``.
* @param txt The text instance to modify.
@@ -234,7 +236,7 @@ bool text_byte_get(const Text *txt, size_t pos, char *byte);
* .. warning:: ``buf`` will not be NUL terminated.
* @endrst
*/
-size_t text_bytes_get(const Text *txt, size_t pos, size_t len, char *buf);
+VIS_INTERNAL size_t text_bytes_get(const Text *txt, size_t pos, size_t len, char *buf);
/**
* Fetch text range into newly allocate memory region.
* @param txt The text instance to modify.
@@ -246,44 +248,44 @@ size_t text_bytes_get(const Text *txt, size_t pos, size_t len, char *buf);
* .. warning:: The returned pointer must be freed by the caller.
* @endrst
*/
-char *text_bytes_alloc0(const Text *txt, size_t pos, size_t len);
+VIS_INTERNAL char *text_bytes_alloc0(const Text *txt, size_t pos, size_t len);
/**
* @}
* @defgroup iterator Text Iterators
* @{
*/
-Iterator text_iterator_get(const Text*, size_t pos);
-bool text_iterator_init(const Text*, Iterator*, size_t pos);
-const Text *text_iterator_text(const Iterator*);
-bool text_iterator_valid(const Iterator*);
-bool text_iterator_has_next(const Iterator*);
-bool text_iterator_has_prev(const Iterator*);
-bool text_iterator_next(Iterator*);
-bool text_iterator_prev(Iterator*);
+VIS_INTERNAL Iterator text_iterator_get(const Text*, size_t pos);
+VIS_INTERNAL bool text_iterator_init(const Text*, Iterator*, size_t pos);
+VIS_INTERNAL const Text *text_iterator_text(const Iterator*);
+VIS_INTERNAL bool text_iterator_valid(const Iterator*);
+VIS_INTERNAL bool text_iterator_has_next(const Iterator*);
+VIS_INTERNAL bool text_iterator_has_prev(const Iterator*);
+VIS_INTERNAL bool text_iterator_next(Iterator*);
+VIS_INTERNAL bool text_iterator_prev(Iterator*);
/**
* @}
* @defgroup iterator_byte Byte Iterators
* @{
*/
-bool text_iterator_byte_get(const Iterator*, char *b);
-bool text_iterator_byte_prev(Iterator*, char *b);
-bool text_iterator_byte_next(Iterator*, char *b);
-bool text_iterator_byte_find_prev(Iterator*, char b);
-bool text_iterator_byte_find_next(Iterator*, char b);
+VIS_INTERNAL bool text_iterator_byte_get(const Iterator*, char *b);
+VIS_INTERNAL bool text_iterator_byte_prev(Iterator*, char *b);
+VIS_INTERNAL bool text_iterator_byte_next(Iterator*, char *b);
+VIS_INTERNAL bool text_iterator_byte_find_prev(Iterator*, char b);
+VIS_INTERNAL bool text_iterator_byte_find_next(Iterator*, char b);
/**
* @}
* @defgroup iterator_code Codepoint Iterators
* @{
*/
-bool text_iterator_codepoint_next(Iterator *it, char *c);
-bool text_iterator_codepoint_prev(Iterator *it, char *c);
+VIS_INTERNAL bool text_iterator_codepoint_next(Iterator *it, char *c);
+VIS_INTERNAL bool text_iterator_codepoint_prev(Iterator *it, char *c);
/**
* @}
* @defgroup iterator_char Character Iterators
* @{
*/
-bool text_iterator_char_next(Iterator*, char *c);
-bool text_iterator_char_prev(Iterator*, char *c);
+VIS_INTERNAL bool text_iterator_char_next(Iterator*, char *c);
+VIS_INTERNAL bool text_iterator_char_prev(Iterator*, char *c);
/**
* @}
* @defgroup mark Marks
@@ -299,14 +301,14 @@ bool text_iterator_char_prev(Iterator*, char *c);
* @param pos The position at which to store the mark.
* @return The mark or ``EMARK`` if an invalid position was given.
*/
-Mark text_mark_set(Text *txt, size_t pos);
+VIS_INTERNAL Mark text_mark_set(Text *txt, size_t pos);
/**
* Lookup a mark.
* @param txt The text instance to modify.
* @param mark The mark to look up.
* @return The byte position or ``EPOS`` for an invalid mark.
*/
-size_t text_mark_get(const Text *txt, Mark mark);
+VIS_INTERNAL size_t text_mark_get(const Text *txt, Mark mark);
/**
* @}
* @defgroup save Text Saving
@@ -363,7 +365,7 @@ typedef struct {
/**
* Marks the current text revision as saved.
*/
-void text_mark_current_revision(Text*);
+VIS_INTERNAL void text_mark_current_revision(Text*);
/**
* Setup a sequence of write operations.
@@ -376,12 +378,12 @@ void text_mark_current_revision(Text*);
* ``text_save_cancel`` to release the underlying resources.
* @endrst
*/
-bool text_save_begin(TextSave*);
+VIS_INTERNAL bool text_save_begin(TextSave*);
/**
* Write file range.
* @return The number of bytes written or ``-1`` in case of an error.
*/
-ssize_t text_save_write_range(TextSave*, const Filerange*);
+VIS_INTERNAL ssize_t text_save_write_range(TextSave*, const Filerange*);
/**
* Commit changes to disk.
* @return Whether changes have been saved.
@@ -390,7 +392,7 @@ ssize_t text_save_write_range(TextSave*, const Filerange*);
* pointer which must no longer be used.
* @endrst
*/
-bool text_save_commit(TextSave*);
+VIS_INTERNAL bool text_save_commit(TextSave*);
/**
* Abort a save operation.
* @rst
@@ -399,12 +401,12 @@ bool text_save_commit(TextSave*);
* frees the given ``TextSave`` pointer which must no longer be used.
* @endrst
*/
-void text_save_cancel(TextSave*);
+VIS_INTERNAL void text_save_cancel(TextSave*);
/**
* Write file range to file descriptor.
* @return The number of bytes written or ``-1`` in case of an error.
*/
-ssize_t text_write_range(const Text*, const Filerange*, int fd);
+VIS_INTERNAL ssize_t text_write_range(const Text*, const Filerange*, int fd);
/**
* @}
* @defgroup misc Miscellaneous
@@ -414,13 +416,13 @@ ssize_t text_write_range(const Text*, const Filerange*, int fd);
* Check whether ``ptr`` is part of a memory mapped region associated with
* this text instance.
*/
-bool text_mmaped(const Text*, const char *ptr);
+VIS_INTERNAL bool text_mmaped(const Text*, const char *ptr);
/**
* Write complete buffer to file descriptor.
* @return The number of bytes written or ``-1`` in case of an error.
*/
-ssize_t write_all(int fd, const char *buf, size_t count);
+VIS_INTERNAL ssize_t write_all(int fd, const char *buf, size_t count);
/** @} */
#endif
diff --git a/ui.h b/ui.h
index c4d81db..6ed0587 100644
--- a/ui.h
+++ b/ui.h
@@ -103,36 +103,36 @@ typedef struct {
#include "vis.h"
#include "text.h"
-bool ui_terminal_init(Ui*);
-int ui_terminal_colors(void);
-void ui_terminal_free(Ui*);
-void ui_terminal_restore(Ui*);
-void ui_terminal_resume(Ui*);
-void ui_terminal_save(Ui*, bool fscr);
-void ui_terminal_suspend(Ui*);
-
-__attribute__((noreturn)) void ui_die(Ui *, const char *, va_list);
-bool ui_init(Ui *, Vis *);
-void ui_arrange(Ui*, enum UiLayout);
-void ui_draw(Ui*);
-void ui_info_hide(Ui *);
-void ui_info_show(Ui *, const char *, va_list);
-void ui_redraw(Ui*);
-void ui_resize(Ui*);
-
-bool ui_window_init(Ui *, Win *, enum UiOption);
-void ui_window_focus(Win *);
+VIS_INTERNAL bool ui_terminal_init(Ui*);
+VIS_INTERNAL int ui_terminal_colors(void);
+VIS_INTERNAL void ui_terminal_free(Ui*);
+VIS_INTERNAL void ui_terminal_restore(Ui*);
+VIS_INTERNAL void ui_terminal_resume(Ui*);
+VIS_INTERNAL void ui_terminal_save(Ui*, bool fscr);
+VIS_INTERNAL void ui_terminal_suspend(Ui*);
+
+VIS_INTERNAL __attribute__((noreturn)) void ui_die(Ui *, const char *, va_list);
+VIS_INTERNAL bool ui_init(Ui *, Vis *);
+VIS_INTERNAL void ui_arrange(Ui*, enum UiLayout);
+VIS_INTERNAL void ui_draw(Ui*);
+VIS_INTERNAL void ui_info_hide(Ui *);
+VIS_INTERNAL void ui_info_show(Ui *, const char *, va_list);
+VIS_INTERNAL void ui_redraw(Ui*);
+VIS_INTERNAL void ui_resize(Ui*);
+
+VIS_INTERNAL bool ui_window_init(Ui *, Win *, enum UiOption);
+VIS_INTERNAL void ui_window_focus(Win *);
/* removes a window from the list of open windows */
-void ui_window_release(Ui *, Win *);
-void ui_window_swap(Win *, Win *);
+VIS_INTERNAL void ui_window_release(Ui *, Win *);
+VIS_INTERNAL void ui_window_swap(Win *, Win *);
-bool ui_getkey(Ui *, TermKeyKey *);
+VIS_INTERNAL bool ui_getkey(Ui *, TermKeyKey *);
-bool ui_style_define(Win *win, int id, const char *style);
-void ui_window_style_set(Ui *ui, int win_id, Cell *cell, enum UiStyle id, bool keep_non_default);
-bool ui_window_style_set_pos(Win *win, int x, int y, enum UiStyle id, bool keep_non_default);
+VIS_INTERNAL bool ui_style_define(Win *win, int id, const char *style);
+VIS_INTERNAL void ui_window_style_set(Ui *ui, int win_id, Cell *cell, enum UiStyle id, bool keep_non_default);
+VIS_INTERNAL bool ui_window_style_set_pos(Win *win, int x, int y, enum UiStyle id, bool keep_non_default);
-void ui_window_options_set(Win *win, enum UiOption options);
-void ui_window_status(Win *win, const char *status);
+VIS_INTERNAL void ui_window_options_set(Win *win, enum UiOption options);
+VIS_INTERNAL void ui_window_status(Win *win, const char *status);
#endif
diff --git a/util.h b/util.h
index d84846a..8b39c1e 100644
--- a/util.h
+++ b/util.h
@@ -1,8 +1,13 @@
#ifndef UTIL_H
#define UTIL_H
-#include <stdint.h>
+#ifndef VIS_INTERNAL
+ #define VIS_INTERNAL
+#endif
+
#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
#define LENGTH(x) ((int)(sizeof (x) / sizeof *(x)))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
diff --git a/view.h b/view.h
index d481d65..4972fa0 100644
--- a/view.h
+++ b/view.h
@@ -81,9 +81,9 @@ typedef struct View {
* @defgroup view_life View Lifecycle
* @{
*/
-bool view_init(struct Win*, Text*);
-void view_free(View*);
-void view_reload(View*, Text*);
+VIS_INTERNAL bool view_init(struct Win*, Text*);
+VIS_INTERNAL void view_free(View*);
+VIS_INTERNAL void view_reload(View*, Text*);
/**
* @}
* @defgroup view_viewport View Viewport
@@ -100,34 +100,34 @@ void view_reload(View*, Text*);
* @param col Will be updated with zero based window column on which ``pos`` resides.
* @return Whether ``pos`` is visible. If not, the pointer arguments are left unmodified.
*/
-bool view_coord_get(View *view, size_t pos, Line **line, int *row, int *col);
+VIS_INTERNAL bool view_coord_get(View *view, size_t pos, Line **line, int *row, int *col);
/** Get position at the start of the ``n``-th window line, counting from 1. */
-size_t view_screenline_goto(View*, int n);
-size_t view_slide_up(View*, int lines);
-size_t view_slide_down(View*, int lines);
-size_t view_scroll_up(View*, int lines);
-size_t view_scroll_down(View*, int lines);
-size_t view_scroll_page_up(View*);
-size_t view_scroll_page_down(View*);
-size_t view_scroll_halfpage_up(View*);
-size_t view_scroll_halfpage_down(View*);
-void view_redraw_top(View*);
-void view_redraw_center(View*);
-void view_redraw_bottom(View*);
-void view_scroll_to(View*, size_t pos);
+VIS_INTERNAL size_t view_screenline_goto(View*, int n);
+VIS_INTERNAL size_t view_slide_up(View*, int lines);
+VIS_INTERNAL size_t view_slide_down(View*, int lines);
+VIS_INTERNAL size_t view_scroll_up(View*, int lines);
+VIS_INTERNAL size_t view_scroll_down(View*, int lines);
+VIS_INTERNAL size_t view_scroll_page_up(View*);
+VIS_INTERNAL size_t view_scroll_page_down(View*);
+VIS_INTERNAL size_t view_scroll_halfpage_up(View*);
+VIS_INTERNAL size_t view_scroll_halfpage_down(View*);
+VIS_INTERNAL void view_redraw_top(View*);
+VIS_INTERNAL void view_redraw_center(View*);
+VIS_INTERNAL void view_redraw_bottom(View*);
+VIS_INTERNAL void view_scroll_to(View*, size_t pos);
/**
* @}
* @defgroup view_size View Sizing
* @{
*/
-bool view_resize(View*, int width, int height);
+VIS_INTERNAL bool view_resize(View*, int width, int height);
/**
* @}
* @defgroup view_draw View Drawing
* @{
*/
-void view_draw(View*);
-bool view_update(View*);
+VIS_INTERNAL void view_draw(View*);
+VIS_INTERNAL bool view_update(View*);
/**
* @}
@@ -141,7 +141,7 @@ bool view_update(View*);
* .. warning:: Fails if position is already covered by a selection.
* @endrst
*/
-Selection *view_selections_new(View*, size_t pos);
+VIS_INTERNAL Selection *view_selections_new(View*, size_t pos);
/**
* Create a new selection even if position is already covered by an
* existing selection.
@@ -150,14 +150,14 @@ Selection *view_selections_new(View*, size_t pos);
* disposed.
* @endrst
*/
-Selection *view_selections_new_force(View*, size_t pos);
+VIS_INTERNAL Selection *view_selections_new_force(View*, size_t pos);
/**
* Dispose an existing selection.
* @rst
* .. warning:: Not applicable for the last existing selection.
* @endrst
*/
-bool view_selections_dispose(Selection*);
+VIS_INTERNAL bool view_selections_dispose(Selection*);
/**
* Forcefully dispose an existing selection.
*
@@ -165,40 +165,40 @@ bool view_selections_dispose(Selection*);
* marked for destruction. As soon as a new selection is created this one
* will be disposed.
*/
-bool view_selections_dispose_force(Selection*);
+VIS_INTERNAL bool view_selections_dispose_force(Selection*);
/**
* Query state of primary selection.
*
* If the primary selection was marked for destruction, return it and
* clear destruction flag.
*/
-Selection *view_selection_disposed(View*);
+VIS_INTERNAL Selection *view_selection_disposed(View*);
/** Dispose all but the primary selection. */
-void view_selections_dispose_all(View*);
+VIS_INTERNAL void view_selections_dispose_all(View*);
/** Dispose all invalid and merge all overlapping selections. */
-void view_selections_normalize(View*);
+VIS_INTERNAL void view_selections_normalize(View*);
/**
* Replace currently active selections.
* @param view The view to manipulate.
* @param array The array of ``Filerange`` objects.
* @param anchored Whether *all* selection should be anchored.
*/
-void view_selections_set_all(View *view, Array *array, bool anchored);
+VIS_INTERNAL void view_selections_set_all(View *view, Array *array, bool anchored);
/** Get array containing a ``Fileranges`` for each selection. */
-Array view_selections_get_all(View*);
+VIS_INTERNAL Array view_selections_get_all(View*);
/**
* @}
* @defgroup view_navigate Selection Navigation
* @{
*/
-Selection *view_selections_primary_get(View*);
-void view_selections_primary_set(Selection*);
+VIS_INTERNAL Selection *view_selections_primary_get(View*);
+VIS_INTERNAL void view_selections_primary_set(Selection*);
/** Get first selection. */
-Selection *view_selections(View*);
+VIS_INTERNAL Selection *view_selections(View*);
/** Get immediate predecessor of selection. */
-Selection *view_selections_prev(Selection*);
+VIS_INTERNAL Selection *view_selections_prev(Selection*);
/** Get immediate successor of selection. */
-Selection *view_selections_next(Selection*);
+VIS_INTERNAL Selection *view_selections_next(Selection*);
/**
* Get selection index.
* @rst
@@ -207,55 +207,55 @@ Selection *view_selections_next(Selection*);
* to remain the same.
* @endrst
*/
-int view_selections_number(Selection*);
+VIS_INTERNAL int view_selections_number(Selection*);
/** Get maximal number of selections on a single line. */
-int view_selections_column_count(View*);
+VIS_INTERNAL int view_selections_column_count(View*);
/**
* Starting from the start of the text, get the `column`-th selection on a line.
* @param view The view to manipulate.
* @param column The zero based column index.
*/
-Selection *view_selections_column(View *view, int column);
+VIS_INTERNAL Selection *view_selections_column(View *view, int column);
/**
* Get the next `column`-th selection on a line.
* @param sel The selection to manipulate.
* @param column The zero based column index.
*/
-Selection *view_selections_column_next(Selection *sel, int column);
+VIS_INTERNAL Selection *view_selections_column_next(Selection *sel, int column);
/**
* @}
* @defgroup view_cover Selection Coverage
* @{
*/
/** Get an inclusive range of the selection cover. */
-Filerange view_selections_get(Selection*);
+VIS_INTERNAL Filerange view_selections_get(Selection*);
/** Set selection cover. Updates both cursor and anchor. */
-bool view_selections_set(Selection*, const Filerange*);
+VIS_INTERNAL bool view_selections_set(Selection*, const Filerange*);
/**
* Reduce selection to character currently covered by the cursor.
* @rst
* .. note:: Sets selection to non-anchored mode.
* @endrst
*/
-void view_selection_clear(Selection*);
+VIS_INTERNAL void view_selection_clear(Selection*);
/** Reduce *all* currently active selections. */
-void view_selections_clear_all(View*);
+VIS_INTERNAL void view_selections_clear_all(View*);
/**
* Flip selection orientation. Swap cursor and anchor.
* @rst
* .. note:: Has no effect on singleton selections.
* @endrst
*/
-void view_selections_flip(Selection*);
+VIS_INTERNAL void view_selections_flip(Selection*);
/**
* @}
* @defgroup view_props Selection Properties
* @{
*/
/** Get position of selection cursor. */
-size_t view_cursors_pos(Selection*);
+VIS_INTERNAL size_t view_cursors_pos(Selection*);
/** Get 1-based line number of selection cursor. */
-size_t view_cursors_line(Selection*);
+VIS_INTERNAL size_t view_cursors_line(Selection*);
/**
* Get 1-based column of selection cursor.
* @rst
@@ -263,7 +263,7 @@ size_t view_cursors_line(Selection*);
* position.
* @endrst
*/
-size_t view_cursors_col(Selection*);
+VIS_INTERNAL size_t view_cursors_col(Selection*);
/**
* @}
* @defgroup view_place Cursor Placement
@@ -283,7 +283,7 @@ size_t view_cursors_col(Selection*);
* of the window.
* @endrst
*/
-void view_cursors_to(Selection*, size_t pos);
+VIS_INTERNAL void view_cursors_to(Selection*, size_t pos);
/**
* Adjusts window viewport until the requested position becomes visible.
* @rst
@@ -293,7 +293,7 @@ void view_cursors_to(Selection*, size_t pos);
* short distances between current cursor position and destination.
* @endrst
*/
-void view_cursors_scroll_to(Selection*, size_t pos);
+VIS_INTERNAL void view_cursors_scroll_to(Selection*, size_t pos);
/**
* Place cursor on given (line, column) pair.
* @param s the selection to manipulate
@@ -304,52 +304,52 @@ void view_cursors_scroll_to(Selection*, size_t pos);
* `view_selection_to`.
* @endrst
*/
-void view_cursors_place(Selection *s, size_t line, size_t col);
+VIS_INTERNAL void view_cursors_place(Selection *s, size_t line, size_t col);
/**
* Place selection cursor on zero based window cell index.
* @rst
* .. warning:: Fails if the selection cursor is currently not visible.
* @endrst
*/
-int view_cursors_cell_set(Selection*, int cell);
+VIS_INTERNAL int view_cursors_cell_set(Selection*, int cell);
/**
* @}
* @defgroup view_motions View Motions
* @{
*/
-size_t view_line_down(Selection*);
-size_t view_line_up(Selection*);
-size_t view_screenline_down(Selection*);
-size_t view_screenline_up(Selection*);
-size_t view_screenline_begin(Selection*);
-size_t view_screenline_middle(Selection*);
-size_t view_screenline_end(Selection*);
+VIS_INTERNAL size_t view_line_down(Selection*);
+VIS_INTERNAL size_t view_line_up(Selection*);
+VIS_INTERNAL size_t view_screenline_down(Selection*);
+VIS_INTERNAL size_t view_screenline_up(Selection*);
+VIS_INTERNAL size_t view_screenline_begin(Selection*);
+VIS_INTERNAL size_t view_screenline_middle(Selection*);
+VIS_INTERNAL size_t view_screenline_end(Selection*);
/**
* @}
* @defgroup view_primary Primary Selection
* @{
*/
/** Get cursor position of primary selection. */
-size_t view_cursor_get(View*);
+VIS_INTERNAL size_t view_cursor_get(View*);
/**
* @}
* @defgroup view_save Selection State
* @{
*/
-Filerange view_regions_restore(View*, SelectionRegion*);
-bool view_regions_save(View*, Filerange*, SelectionRegion*);
+VIS_INTERNAL Filerange view_regions_restore(View*, SelectionRegion*);
+VIS_INTERNAL bool view_regions_save(View*, Filerange*, SelectionRegion*);
/**
* @}
* @defgroup view_style View Styling
* @{
*/
-void win_options_set(struct Win *, enum UiOption);
-bool view_breakat_set(View*, const char *breakat);
+VIS_INTERNAL void win_options_set(struct Win *, enum UiOption);
+VIS_INTERNAL bool view_breakat_set(View*, const char *breakat);
/** Set how many spaces are used to display a tab `\t` character. */
-void view_tabwidth_set(View*, int tabwidth);
+VIS_INTERNAL void view_tabwidth_set(View*, int tabwidth);
/** Apply a style to a text range. */
-void win_style(struct Win*, enum UiStyle, size_t start, size_t end, bool keep_non_default);
+VIS_INTERNAL void win_style(struct Win*, enum UiStyle, size_t start, size_t end, bool keep_non_default);
/** @} */
diff --git a/vis-core.h b/vis-core.h
index fb1e50d..8091305 100644
--- a/vis-core.h
+++ b/vis-core.h
@@ -2,6 +2,9 @@
#define VIS_CORE_H
#include <setjmp.h>
+
+#include "util.h"
+
#include "vis.h"
#include "sam.h"
#include "vis-lua.h"
@@ -10,7 +13,6 @@
#include "map.h"
#include "array.h"
#include "buffer.h"
-#include "util.h"
/* a mode contains a set of key bindings which are currently valid.
*
@@ -239,7 +241,7 @@ enum VisEvents {
VIS_EVENT_UI_DRAW,
};
-bool vis_event_emit(Vis*, enum VisEvents, ...);
+VIS_INTERNAL bool vis_event_emit(Vis*, enum VisEvents, ...);
typedef struct {
char name;
@@ -257,46 +259,46 @@ extern const TextObject vis_textobjects[VIS_TEXTOBJECT_INVALID];
extern const MarkDef vis_marks[VIS_MARK_a];
extern const RegisterDef vis_registers[VIS_REG_a];
-void macro_operator_stop(Vis *vis);
-void macro_operator_record(Vis *vis);
+VIS_INTERNAL void macro_operator_stop(Vis *vis);
+VIS_INTERNAL void macro_operator_record(Vis *vis);
-void vis_do(Vis *vis);
-void action_reset(Action*);
-size_t vis_text_insert_nl(Vis*, Text*, size_t pos);
+VIS_INTERNAL void vis_do(Vis *vis);
+VIS_INTERNAL void action_reset(Action*);
+VIS_INTERNAL size_t vis_text_insert_nl(Vis*, Text*, size_t pos);
-Mode *mode_get(Vis*, enum VisMode);
-void mode_set(Vis *vis, Mode *new_mode);
-Macro *macro_get(Vis *vis, enum VisRegister);
+VIS_INTERNAL Mode *mode_get(Vis*, enum VisMode);
+VIS_INTERNAL void mode_set(Vis *vis, Mode *new_mode);
+VIS_INTERNAL Macro *macro_get(Vis *vis, enum VisRegister);
-Win *window_new_file(Vis*, File*, enum UiOption);
-void window_selection_save(Win *win);
-void window_status_update(Vis *vis, Win *win);
+VIS_INTERNAL Win *window_new_file(Vis*, File*, enum UiOption);
+VIS_INTERNAL void window_selection_save(Win *win);
+VIS_INTERNAL void window_status_update(Vis *vis, Win *win);
-char *absolute_path(const char *path);
+VIS_INTERNAL char *absolute_path(const char *path);
-const char *file_name_get(File*);
-void file_name_set(File*, const char *name);
+VIS_INTERNAL const char *file_name_get(File*);
+VIS_INTERNAL void file_name_set(File*, const char *name);
-bool register_init(Register*);
-void register_release(Register*);
+VIS_INTERNAL bool register_init(Register*);
+VIS_INTERNAL void register_release(Register*);
-void mark_init(Array*);
-void mark_release(Array*);
+VIS_INTERNAL void mark_init(Array*);
+VIS_INTERNAL void mark_release(Array*);
-void marklist_init(MarkList*, size_t max);
-void marklist_release(MarkList*);
+VIS_INTERNAL void marklist_init(MarkList*, size_t max);
+VIS_INTERNAL void marklist_release(MarkList*);
-const char *register_get(Vis*, Register*, size_t *len);
-const char *register_slot_get(Vis*, Register*, size_t slot, size_t *len);
+VIS_INTERNAL const char *register_get(Vis*, Register*, size_t *len);
+VIS_INTERNAL const char *register_slot_get(Vis*, Register*, size_t slot, size_t *len);
-bool register_put0(Vis*, Register*, const char *data);
-bool register_put(Vis*, Register*, const char *data, size_t len);
-bool register_slot_put(Vis*, Register*, size_t slot, const char *data, size_t len);
+VIS_INTERNAL bool register_put0(Vis*, Register*, const char *data);
+VIS_INTERNAL bool register_put(Vis*, Register*, const char *data, size_t len);
+VIS_INTERNAL bool register_slot_put(Vis*, Register*, size_t slot, const char *data, size_t len);
-bool register_put_range(Vis*, Register*, Text*, Filerange*);
-bool register_slot_put_range(Vis*, Register*, size_t slot, Text*, Filerange*);
+VIS_INTERNAL bool register_put_range(Vis*, Register*, Text*, Filerange*);
+VIS_INTERNAL bool register_slot_put_range(Vis*, Register*, size_t slot, Text*, Filerange*);
-size_t vis_register_count(Vis*, Register*);
-bool register_resize(Register*, size_t count);
+VIS_INTERNAL size_t vis_register_count(Vis*, Register*);
+VIS_INTERNAL bool register_resize(Register*, size_t count);
#endif
diff --git a/vis-lua.c b/vis-lua.c
index fa7ef35..6e74e4f 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -21,10 +21,11 @@
#include <sys/types.h>
#include <pwd.h>
+#include "util.h"
+
#include "vis-lua.h"
#include "vis-core.h"
#include "text-motions.h"
-#include "util.h"
#ifndef VIS_PATH
#define VIS_PATH "/usr/local/share/vis"
diff --git a/vis-lua.h b/vis-lua.h
index 76e7029..db969de 100644
--- a/vis-lua.h
+++ b/vis-lua.h
@@ -15,20 +15,20 @@ typedef void* lua_CFunction;
#include "vis-subprocess.h"
/* add a directory to consider when loading lua files */
-bool vis_lua_path_add(Vis*, const char *path);
+VIS_INTERNAL bool vis_lua_path_add(Vis*, const char *path);
/* get semicolon separated list of paths to load lua files
* (*lpath = package.path) and Lua C modules (*cpath = package.cpath)
* both these pointers need to be free(3)-ed by the caller */
-bool vis_lua_paths_get(Vis*, char **lpath, char **cpath);
+VIS_INTERNAL bool vis_lua_paths_get(Vis*, char **lpath, char **cpath);
/* various event handlers, triggered by the vis core */
#if !CONFIG_LUA
#define vis_event_mode_insert_input vis_insert_key
#define vis_event_mode_replace_input vis_replace_key
#else
-void vis_event_mode_insert_input(Vis*, const char *key, size_t len);
-void vis_event_mode_replace_input(Vis*, const char *key, size_t len);
+VIS_INTERNAL void vis_event_mode_insert_input(Vis*, const char *key, size_t len);
+VIS_INTERNAL void vis_event_mode_replace_input(Vis*, const char *key, size_t len);
#endif
-void vis_lua_process_response(Vis *, const char *, char *, size_t, ResponseType);
+VIS_INTERNAL void vis_lua_process_response(Vis *, const char *, char *, size_t, ResponseType);
#endif
diff --git a/vis-subprocess.c b/vis-subprocess.c
index 3223f10..b1d6a26 100644
--- a/vis-subprocess.c
+++ b/vis-subprocess.c
@@ -4,9 +4,11 @@
#include <errno.h>
#include <string.h>
#include <sys/wait.h>
+
+#include "util.h"
+
#include "vis-lua.h"
#include "vis-subprocess.h"
-#include "util.h"
/* Pool of information about currently running subprocesses */
static Process *process_pool;
diff --git a/vis-subprocess.h b/vis-subprocess.h
index 79a043e..05f4dfe 100644
--- a/vis-subprocess.h
+++ b/vis-subprocess.h
@@ -23,9 +23,9 @@ struct Process {
typedef enum { STDOUT, STDERR, SIGNAL, EXIT } ResponseType;
-Process *vis_process_communicate(Vis *, const char *command, const char *name,
- Invalidator **invalidator);
-int vis_process_before_tick(fd_set *);
-void vis_process_tick(Vis *, fd_set *);
-void vis_process_waitall(Vis *);
+VIS_INTERNAL Process *vis_process_communicate(Vis *, const char *command, const char *name,
+ Invalidator **invalidator);
+VIS_INTERNAL int vis_process_before_tick(fd_set *);
+VIS_INTERNAL void vis_process_tick(Vis *, fd_set *);
+VIS_INTERNAL void vis_process_waitall(Vis *);
#endif
diff --git a/vis.c b/vis.c
index 30d88b0..2d4aabc 100644
--- a/vis.c
+++ b/vis.c
@@ -20,11 +20,12 @@
#include <libgen.h>
#include <termkey.h>
+#include "util.h"
+
#include "vis.h"
#include "text-util.h"
#include "text-motions.h"
#include "text-objects.h"
-#include "util.h"
#include "vis-core.h"
#include "sam.h"
#include "ui.h"
diff --git a/vis.h b/vis.h
index 8e367ed..7237e04 100644
--- a/vis.h
+++ b/vis.h
@@ -1,6 +1,10 @@
#ifndef VIS_H
#define VIS_H
+#ifndef VIS_EXPORT
+ #define VIS_EXPORT
+#endif
+
#include <signal.h>
#include <stddef.h>
#include <stdbool.h>
@@ -103,21 +107,21 @@ typedef struct {
* Initializes a new editor instance.
* @param vis The editor instance.
*/
-bool vis_init(Vis*);
+VIS_EXPORT bool vis_init(Vis*);
/** Release all resources associated with this editor instance, terminates UI. */
-void vis_cleanup(Vis*);
+VIS_EXPORT void vis_cleanup(Vis*);
/**
* Enter main loop, start processing user input.
* @param vis The editor instance.
* @return The editor exit status code.
*/
-int vis_run(Vis*);
+VIS_EXPORT int vis_run(Vis*);
/**
* Terminate editing session, the given ``status`` will be the return value of `vis_run`.
* @param vis The editor instance.
* @param status The exit status.
*/
-void vis_exit(Vis *vis, int status);
+VIS_EXPORT void vis_exit(Vis *vis, int status);
/**
* Emergency exit, print given message, perform minimal UI cleanup and exit process.
* @param vis The editor instance.
@@ -126,7 +130,7 @@ void vis_exit(Vis *vis, int status);
* .. note:: This function does not return.
* @endrst
*/
-void vis_die(Vis *vis, const char *msg, ...) __attribute__((noreturn,format(printf, 2, 3)));
+VIS_EXPORT void vis_die(Vis *vis, const char *msg, ...) __attribute__((noreturn,format(printf, 2, 3)));
/**
* Inform the editor core that a signal occurred.
@@ -142,7 +146,7 @@ void vis_die(Vis *vis, const char *msg, ...) __attribute__((noreturn,format(prin
* specified in `sigaction(2)`.
* @endrst
*/
-bool vis_signal_handler(Vis *vis, int signum, const siginfo_t *siginfo, const void *context);
+VIS_EXPORT bool vis_signal_handler(Vis *vis, int signum, const siginfo_t *siginfo, const void *context);
/**
* Interrupt long running operation.
* @param vis The editor instance.
@@ -153,12 +157,12 @@ bool vis_signal_handler(Vis *vis, int signum, const siginfo_t *siginfo, const vo
* .. note:: It is invoked from `vis_signal_handler` when receiving ``SIGINT``.
* @endrst
*/
-void vis_interrupt(Vis*);
+VIS_EXPORT void vis_interrupt(Vis*);
/**
* Check whether interruption was requested.
* @param vis The editor instance.
*/
-bool vis_interrupt_requested(Vis*);
+VIS_EXPORT bool vis_interrupt_requested(Vis*);
/** @} */
/*
@@ -174,12 +178,12 @@ bool vis_interrupt_requested(Vis*);
* Draw user interface.
* @param vis The editor instance.
*/
-void vis_draw(Vis*);
+VIS_EXPORT void vis_draw(Vis*);
/**
* Completely redraw user interface.
* @param vis The editor instance.
*/
-void vis_redraw(Vis*);
+VIS_EXPORT void vis_redraw(Vis*);
/** @} */
/*
@@ -200,7 +204,7 @@ void vis_redraw(Vis*);
* the underlying File object is shared.
* @endrst
*/
-bool vis_window_new(Vis *vis, const char *filename);
+VIS_EXPORT bool vis_window_new(Vis *vis, const char *filename);
/**
* Create a new window associated with a file descriptor.
* @param vis The editor instance.
@@ -210,64 +214,64 @@ bool vis_window_new(Vis *vis, const char *filename);
* explicit filename will instead write to the file descriptor.
* @endrst
*/
-bool vis_window_new_fd(Vis *vis, int fd);
+VIS_EXPORT bool vis_window_new_fd(Vis *vis, int fd);
/**
* Reload the file currently displayed in the window from disk.
* @param win The window to reload.
*/
-bool vis_window_reload(Win*);
+VIS_EXPORT bool vis_window_reload(Win*);
/**
* Change the file currently displayed in the window.
* @param win The window to change.
* @param filename The new file to display.
*/
-bool vis_window_change_file(Win *win, const char *filename);
+VIS_EXPORT bool vis_window_change_file(Win *win, const char *filename);
/**
* Check whether closing the window would loose unsaved changes.
* @param win The window to check.
*/
-bool vis_window_closable(Win*);
+VIS_EXPORT bool vis_window_closable(Win*);
/**
* Close window, redraw user interface.
* @param win The window to close.
*/
-void vis_window_close(Win*);
+VIS_EXPORT void vis_window_close(Win*);
/**
* Split the window, shares the underlying file object.
* @param original The window to split.
*/
-bool vis_window_split(Win*);
+VIS_EXPORT bool vis_window_split(Win*);
/**
* Draw a specific window.
* @param win The window to draw.
*/
-void vis_window_draw(Win*);
+VIS_EXPORT void vis_window_draw(Win*);
/**
* Invalidate a window, forcing a redraw.
* @param win The window to invalidate.
*/
-void vis_window_invalidate(Win*);
+VIS_EXPORT void vis_window_invalidate(Win*);
/**
* Focus next window.
* @param vis The editor instance.
*/
-void vis_window_next(Vis*);
+VIS_EXPORT void vis_window_next(Vis*);
/**
* Focus previous window.
* @param vis The editor instance.
*/
-void vis_window_prev(Vis*);
+VIS_EXPORT void vis_window_prev(Vis*);
/**
* Change currently focused window, receiving user input.
* @param win The window to focus.
*/
-void vis_window_focus(Win*);
+VIS_EXPORT void vis_window_focus(Win*);
/**
* Swap location of two windows.
* @param win1 The first window.
* @param win2 The second window.
*/
-void vis_window_swap(Win *win1, Win *win2);
+VIS_EXPORT void vis_window_swap(Win *win1, Win *win2);
/** @} */
/*
@@ -287,7 +291,7 @@ void vis_window_swap(Win *win1, Win *win2);
* .. note:: The prompt is currently implemented as a single line height window.
* @endrst
*/
-void vis_prompt_show(Vis *vis, const char *title);
+VIS_EXPORT void vis_prompt_show(Vis *vis, const char *title);
/**
* Display a single line message.
@@ -297,14 +301,14 @@ void vis_prompt_show(Vis *vis, const char *title);
* .. note:: The message will automatically be hidden upon next input.
* @endrst
*/
-void vis_info_show(Vis *vis, const char *msg, ...) __attribute__((format(printf, 2, 3)));
+VIS_EXPORT void vis_info_show(Vis *vis, const char *msg, ...) __attribute__((format(printf, 2, 3)));
/**
* Display arbitrary long message in a dedicated window.
* @param vis The editor instance.
* @param msg The message to display.
*/
-void vis_message_show(Vis *vis, const char *msg);
+VIS_EXPORT void vis_message_show(Vis *vis, const char *msg);
/** @} */
/*
@@ -323,14 +327,14 @@ void vis_message_show(Vis *vis, const char *msg);
* @param data The data to insert.
* @param len The length of the data to insert.
*/
-void vis_insert(Vis *vis, size_t pos, const char *data, size_t len);
+VIS_EXPORT void vis_insert(Vis *vis, size_t pos, const char *data, size_t len);
/**
* Delete data from the file.
* @param vis The editor instance.
* @param pos The starting position of the deletion.
* @param len The length of the data to delete.
*/
-void vis_delete(Vis *vis, size_t pos, size_t len);
+VIS_EXPORT void vis_delete(Vis *vis, size_t pos, size_t len);
/**
* Replace data in the file.
* @param vis The editor instance.
@@ -338,14 +342,14 @@ void vis_delete(Vis *vis, size_t pos, size_t len);
* @param data The new data.
* @param len The length of the new data.
*/
-void vis_replace(Vis *vis, size_t pos, const char *data, size_t len);
+VIS_EXPORT void vis_replace(Vis *vis, size_t pos, const char *data, size_t len);
/**
* Perform insertion at all cursor positions.
* @param vis The editor instance.
* @param data The data to insert.
* @param len The length of the data.
*/
-void vis_insert_key(Vis *vis, const char *data, size_t len);
+VIS_EXPORT void vis_insert_key(Vis *vis, const char *data, size_t len);
/**
* Perform character substitution at all cursor positions.
* @param vis The editor instance.
@@ -355,7 +359,7 @@ void vis_insert_key(Vis *vis, const char *data, size_t len);
* .. note:: Does not replace new line characters.
* @endrst
*/
-void vis_replace_key(Vis *vis, const char *data, size_t len);
+VIS_EXPORT void vis_replace_key(Vis *vis, const char *data, size_t len);
/**
* Insert a tab at all cursor positions.
* @param vis The editor instance.
@@ -363,7 +367,7 @@ void vis_replace_key(Vis *vis, const char *data, size_t len);
* .. note:: Performs tab expansion according to current settings.
* @endrst
*/
-void vis_insert_tab(Vis*);
+VIS_EXPORT void vis_insert_tab(Vis*);
/**
* Inserts a new line character at every cursor position.
* @param vis The editor instance.
@@ -371,7 +375,7 @@ void vis_insert_tab(Vis*);
* .. note:: Performs auto indentation according to current settings.
* @endrst
*/
-void vis_insert_nl(Vis*);
+VIS_EXPORT void vis_insert_nl(Vis*);
/** @} */
@@ -406,13 +410,13 @@ enum VisMode {
* No events are emitted, if the specified mode is already active.
* @endrst
*/
-void vis_mode_switch(Vis *vis, enum VisMode mode);
+VIS_EXPORT void vis_mode_switch(Vis *vis, enum VisMode mode);
/**
* Translate human readable mode name to constant.
* @param vis The editor instance.
* @param name The name of the mode.
*/
-enum VisMode vis_mode_from(Vis *vis, const char *name);
+VIS_EXPORT enum VisMode vis_mode_from(Vis *vis, const char *name);
/** @} */
@@ -429,13 +433,13 @@ enum VisMode vis_mode_from(Vis *vis, const char *name);
* Create a new key binding.
* @param vis The editor instance.
*/
-KeyBinding *vis_binding_new(Vis*);
+VIS_EXPORT KeyBinding *vis_binding_new(Vis*);
/**
* Free a key binding.
* @param vis The editor instance.
* @param binding The key binding to free.
*/
-void vis_binding_free(Vis *vis, KeyBinding *binding);
+VIS_EXPORT void vis_binding_free(Vis *vis, KeyBinding *binding);
/**
* Set up a key binding.
@@ -448,7 +452,7 @@ void vis_binding_free(Vis *vis, KeyBinding *binding);
* .. note:: ``binding->key`` is always ignored in favor of ``key``.
* @endrst
*/
-bool vis_mode_map(Vis *vis, enum VisMode mode, bool force, const char *key, const KeyBinding *binding);
+VIS_EXPORT bool vis_mode_map(Vis *vis, enum VisMode mode, bool force, const char *key, const KeyBinding *binding);
/**
* Analogous to `vis_mode_map`, but window specific.
* @param win The window for the mapping.
@@ -457,21 +461,21 @@ bool vis_mode_map(Vis *vis, enum VisMode mode, bool force, const char *key, cons
* @param key The symbolic key to map.
* @param binding The binding to map.
*/
-bool vis_window_mode_map(Win *win, enum VisMode mode, bool force, const char *key, const KeyBinding *binding);
+VIS_EXPORT bool vis_window_mode_map(Win *win, enum VisMode mode, bool force, const char *key, const KeyBinding *binding);
/**
* Unmap a symbolic key in a given mode.
* @param vis The editor instance.
* @param mode The mode from which to unmap.
* @param key The symbolic key to unmap.
*/
-bool vis_mode_unmap(Vis *vis, enum VisMode mode, const char *key);
+VIS_EXPORT bool vis_mode_unmap(Vis *vis, enum VisMode mode, const char *key);
/**
* Analogous to `vis_mode_unmap`, but window specific.
* @param win The window from which to unmap.
* @param mode The mode from which to unmap.
* @param key The symbolic key to unmap.
*/
-bool vis_window_mode_unmap(Win *win, enum VisMode mode, const char *key);
+VIS_EXPORT bool vis_window_mode_unmap(Win *win, enum VisMode mode, const char *key);
/** @} */
/*
@@ -491,13 +495,13 @@ bool vis_window_mode_unmap(Win *win, enum VisMode mode, const char *key);
* @param func The function implementing the key action logic.
* @param arg Argument passed to function.
*/
-KeyAction *vis_action_new(Vis *vis, const char *name, const char *help, KeyActionFunction *func, Arg arg);
+VIS_EXPORT KeyAction *vis_action_new(Vis *vis, const char *name, const char *help, KeyActionFunction *func, Arg arg);
/**
* Free a key action.
* @param vis The editor instance.
* @param action The key action to free.
*/
-void vis_action_free(Vis *vis, KeyAction *action);
+VIS_EXPORT void vis_action_free(Vis *vis, KeyAction *action);
/**
* Register key action.
* @param vis The editor instance.
@@ -507,7 +511,7 @@ void vis_action_free(Vis *vis, KeyAction *action);
* in ``keyaction->name``.
* @endrst
*/
-bool vis_action_register(Vis *vis, const KeyAction *keyaction);
+VIS_EXPORT bool vis_action_register(Vis *vis, const KeyAction *keyaction);
/** @} */
@@ -527,12 +531,12 @@ bool vis_action_register(Vis *vis, const KeyAction *keyaction);
* @param key The key to translate.
* @param mapping The string to map the key to.
*/
-bool vis_keymap_add(Vis *vis, const char *key, const char *mapping);
+VIS_EXPORT bool vis_keymap_add(Vis *vis, const char *key, const char *mapping);
/**
* Temporarily disable the keymap for the next key press.
* @param vis The editor instance.
*/
-void vis_keymap_disable(Vis*);
+VIS_EXPORT void vis_keymap_disable(Vis*);
/** @} */
@@ -590,7 +594,7 @@ typedef size_t (VisOperatorFunction)(Vis *vis, Text *text, OperatorContext *cont
* @return Operator ID. Negative values indicate an error, positive ones can be
* used with `vis_operator`.
*/
-int vis_operator_register(Vis *vis, VisOperatorFunction *func, void *context);
+VIS_EXPORT int vis_operator_register(Vis *vis, VisOperatorFunction *func, void *context);
/**
* Set operator to execute.
@@ -612,19 +616,19 @@ int vis_operator_register(Vis *vis, VisOperatorFunction *func, void *context);
* - `VIS_OP_MODESWITCH` an ``enum VisMode`` indicating the mode to switch to.
* - `VIS_OP_REPLACE` a char pointer referring to the replacement character.
*/
-bool vis_operator(Vis *vis, enum VisOperator op, ...);
+VIS_EXPORT bool vis_operator(Vis *vis, enum VisOperator op, ...);
/**
* Repeat last operator, possibly with a new count if one was provided in the meantime.
* @param vis The editor instance.
*/
-void vis_repeat(Vis*);
+VIS_EXPORT void vis_repeat(Vis*);
/**
* Cancel pending operator, reset count, motion, text object, register etc.
* @param vis The editor instance.
*/
-void vis_cancel(Vis*);
+VIS_EXPORT void vis_cancel(Vis*);
/** @} */
@@ -736,7 +740,7 @@ enum VisMotion {
*
* The character to search for as ``const char *``.
*/
-bool vis_motion(Vis *vis, enum VisMotion motion, ...);
+VIS_EXPORT bool vis_motion(Vis *vis, enum VisMotion motion, ...);
enum VisMotionType {
VIS_MOTIONTYPE_LINEWISE = 1 << 0,
@@ -748,7 +752,7 @@ enum VisMotionType {
* @param vis The editor instance.
* @param type The motion type (line-wise or character-wise).
*/
-void vis_motion_type(Vis *vis, enum VisMotionType type);
+VIS_EXPORT void vis_motion_type(Vis *vis, enum VisMotionType type);
/**
* Motions take a starting position and transform it to an end position.
@@ -771,7 +775,7 @@ typedef size_t (VisMotionFunction)(Vis *vis, Win *win, void *context, size_t pos
* @return Motion ID. Negative values indicate an error, positive ones can be
* used with `vis_motion`.
*/
-int vis_motion_register(Vis *vis, void *context, VisMotionFunction *func);
+VIS_EXPORT int vis_motion_register(Vis *vis, void *context, VisMotionFunction *func);
/** @} */
@@ -793,7 +797,7 @@ int vis_motion_register(Vis *vis, void *context, VisMotionFunction *func);
* @param vis The editor instance.
* @param new_shell The new shell to set.
*/
-void vis_shell_set(Vis *vis, const char *new_shell);
+VIS_EXPORT void vis_shell_set(Vis *vis, const char *new_shell);
typedef struct {
Vis *vis;
@@ -806,13 +810,13 @@ typedef struct {
* @param vis The editor instance.
* @param def The default count if none is specified.
*/
-VisCountIterator vis_count_iterator_get(Vis *vis, int def);
+VIS_EXPORT VisCountIterator vis_count_iterator_get(Vis *vis, int def);
/**
* Get iterator initialized with a count value.
* @param vis The editor instance.
* @param count The count value to initialize with.
*/
-VisCountIterator vis_count_iterator_init(Vis *vis, int count);
+VIS_EXPORT VisCountIterator vis_count_iterator_init(Vis *vis, int count);
/**
* Increment iterator counter.
* @param iter Pointer to the iterator.
@@ -822,7 +826,7 @@ VisCountIterator vis_count_iterator_init(Vis *vis, int count);
* `interrupted <vis_interrupt>`_ in the meantime.
* @endrst
*/
-bool vis_count_iterator_next(VisCountIterator *iter);
+VIS_EXPORT bool vis_count_iterator_next(VisCountIterator *iter);
/** @} */
@@ -889,14 +893,14 @@ typedef Filerange (VisTextObjectFunction)(Vis *vis, Win *win, void *context, siz
* @return Text object ID. Negative values indicate an error, positive ones can be
* used with `vis_textobject`.
*/
-int vis_textobject_register(Vis *vis, int type, void *data, VisTextObjectFunction *func);
+VIS_EXPORT int vis_textobject_register(Vis *vis, int type, void *data, VisTextObjectFunction *func);
/**
* Set text object to use.
* @param vis The editor instance.
* @param textobj The text object to set.
*/
-bool vis_textobject(Vis *vis, enum VisTextObject textobj);
+VIS_EXPORT bool vis_textobject(Vis *vis, enum VisTextObject textobj);
/** @} */
@@ -928,13 +932,13 @@ enum VisMark {
* @param vis The editor instance.
* @param mark The character representing the mark.
*/
-enum VisMark vis_mark_from(Vis *vis, char mark);
+VIS_EXPORT enum VisMark vis_mark_from(Vis *vis, char mark);
/**
* Translate between mark constant and single character mark name.
* @param vis The editor instance.
* @param mark The mark constant.
*/
-char vis_mark_to(Vis *vis, enum VisMark mark);
+VIS_EXPORT char vis_mark_to(Vis *vis, enum VisMark mark);
/**
* Specify mark to use.
* @param vis The editor instance.
@@ -943,12 +947,12 @@ char vis_mark_to(Vis *vis, enum VisMark mark);
* .. note:: If none is specified `VIS_MARK_DEFAULT` will be used.
* @endrst
*/
-void vis_mark(Vis *vis, enum VisMark mark);
+VIS_EXPORT void vis_mark(Vis *vis, enum VisMark mark);
/**
* Get the currently used mark.
* @param vis The editor instance.
*/
-enum VisMark vis_mark_used(Vis*);
+VIS_EXPORT enum VisMark vis_mark_used(Vis*);
/**
* Store a set of ``Filerange``s in a mark.
*
@@ -956,7 +960,7 @@ enum VisMark vis_mark_used(Vis*);
* @param id The mark ID to use.
* @param sel The array containing the file ranges.
*/
-void vis_mark_set(Win *win, enum VisMark id, Array *sel);
+VIS_EXPORT void vis_mark_set(Win *win, enum VisMark id, Array *sel);
/**
* Get an array of file ranges stored in the mark.
* @param win The window whose mark to retrieve.
@@ -967,7 +971,7 @@ void vis_mark_set(Win *win, enum VisMark id, Array *sel);
* ``array_release``.
* @endrst
*/
-Array vis_mark_get(Win *win, enum VisMark id);
+VIS_EXPORT Array vis_mark_get(Win *win, enum VisMark id);
/**
* Normalize an Array of Fileranges.
* @param array The array of file ranges to normalize.
@@ -975,22 +979,22 @@ Array vis_mark_get(Win *win, enum VisMark id);
* Removes invalid ranges, merges overlapping ones and sorts
* according to the start position.
*/
-void vis_mark_normalize(Array *array);
+VIS_EXPORT void vis_mark_normalize(Array *array);
/**
* Add selections of focused window to jump list.
* @param vis The editor instance.
*/
-bool vis_jumplist_save(Vis*);
+VIS_EXPORT bool vis_jumplist_save(Vis*);
/**
* Navigate jump list backwards.
* @param vis The editor instance.
*/
-bool vis_jumplist_prev(Vis*);
+VIS_EXPORT bool vis_jumplist_prev(Vis*);
/**
* Navigate jump list forwards.
* @param vis The editor instance.
*/
-bool vis_jumplist_next(Vis*);
+VIS_EXPORT bool vis_jumplist_next(Vis*);
/** @} */
/*
@@ -1048,13 +1052,13 @@ enum VisRegister {
* @param vis The editor instance.
* @param reg The character representing the register.
*/
-enum VisRegister vis_register_from(Vis *vis, char reg);
+VIS_EXPORT enum VisRegister vis_register_from(Vis *vis, char reg);
/**
* Translate between register constant and single character register name.
* @param vis The editor instance.
* @param reg The register constant.
*/
-char vis_register_to(Vis *vis, enum VisRegister reg);
+VIS_EXPORT char vis_register_to(Vis *vis, enum VisRegister reg);
/**
* Specify register to use.
* @param vis The editor instance.
@@ -1063,12 +1067,12 @@ char vis_register_to(Vis *vis, enum VisRegister reg);
* .. note:: If none is specified `VIS_REG_DEFAULT` will be used.
* @endrst
*/
-void vis_register(Vis *vis, enum VisRegister reg);
+VIS_EXPORT void vis_register(Vis *vis, enum VisRegister reg);
/**
* Get the currently used register.
* @param vis The editor instance.
*/
-enum VisRegister vis_register_used(Vis*);
+VIS_EXPORT enum VisRegister vis_register_used(Vis*);
/**
* Get register content.
* @param vis The editor instance.
@@ -1079,14 +1083,14 @@ enum VisRegister vis_register_used(Vis*);
* ``array_release``.
* @endrst
*/
-Array vis_register_get(Vis *vis, enum VisRegister id);
+VIS_EXPORT Array vis_register_get(Vis *vis, enum VisRegister id);
/**
* Set register content.
* @param vis The editor instance.
* @param id The register ID to set.
* @param data The array comprised of ``TextString`` structs.
*/
-bool vis_register_set(Vis *vis, enum VisRegister id, Array *data);
+VIS_EXPORT bool vis_register_set(Vis *vis, enum VisRegister id, Array *data);
/** @} */
/*
@@ -1106,17 +1110,17 @@ bool vis_register_set(Vis *vis, enum VisRegister id, Array *data);
* .. note:: Fails if a recording is already ongoing.
* @endrst
*/
-bool vis_macro_record(Vis *vis, enum VisRegister reg);
+VIS_EXPORT bool vis_macro_record(Vis *vis, enum VisRegister reg);
/**
* Stop recording, fails if there is nothing to stop.
* @param vis The editor instance.
*/
-bool vis_macro_record_stop(Vis*);
+VIS_EXPORT bool vis_macro_record_stop(Vis*);
/**
* Check whether a recording is currently ongoing.
* @param vis The editor instance.
*/
-bool vis_macro_recording(Vis*);
+VIS_EXPORT bool vis_macro_recording(Vis*);
/**
* Replay a macro.
* @param vis The editor instance.
@@ -1125,7 +1129,7 @@ bool vis_macro_recording(Vis*);
* .. note:: A macro currently being recorded can not be replayed.
* @endrst
*/
-bool vis_macro_replay(Vis *vis, enum VisRegister reg);
+VIS_EXPORT bool vis_macro_replay(Vis *vis, enum VisRegister reg);
/** @} */
@@ -1144,7 +1148,7 @@ bool vis_macro_replay(Vis *vis, enum VisRegister reg);
* @param vis The editor instance.
* @param cmd The command string to execute.
*/
-bool vis_cmd(Vis *vis, const char *cmd);
+VIS_EXPORT bool vis_cmd(Vis *vis, const char *cmd);
/** Command handler function. */
typedef bool (VisCommandFunction)(Vis*, Win*, void *data, bool force,
@@ -1160,14 +1164,14 @@ typedef bool (VisCommandFunction)(Vis*, Win*, void *data, bool force,
* .. note:: Any unique prefix of the command name will invoke the command.
* @endrst
*/
-bool vis_cmd_register(Vis *vis, const char *name, const char *help, void *context, VisCommandFunction *func);
+VIS_EXPORT bool vis_cmd_register(Vis *vis, const char *name, const char *help, void *context, VisCommandFunction *func);
/**
* Unregister ``:``-command.
* @param vis The editor instance.
* @param name The name of the command to unregister.
*/
-bool vis_cmd_unregister(Vis *vis, const char *name);
+VIS_EXPORT bool vis_cmd_unregister(Vis *vis, const char *name);
/** @} */
@@ -1215,8 +1219,8 @@ typedef bool (VisOptionFunction)(Vis *vis, Win *win, void *context, bool force,
* .. note:: Fails if any of the given option names is already registered.
* @endrst
*/
-bool vis_option_register(Vis *vis, const char *names[], enum VisOption option_flags,
- VisOptionFunction *func, void *context, const char *help);
+VIS_EXPORT bool vis_option_register(Vis *vis, const char *names[], enum VisOption option_flags,
+ VisOptionFunction *func, void *context, const char *help);
/**
* Unregister an existing ``:set`` option.
* @param vis The editor instance.
@@ -1225,14 +1229,14 @@ bool vis_option_register(Vis *vis, const char *names[], enum VisOption option_fl
* .. note:: Also unregisters all aliases as given to `vis_option_register`.
* @endrst
*/
-bool vis_option_unregister(Vis *vis, const char *name);
+VIS_EXPORT bool vis_option_unregister(Vis *vis, const char *name);
/**
* Execute any kind (``:``, ``?``, ``/``) of prompt command
* @param vis The editor instance.
* @param cmd The command string.
*/
-bool vis_prompt_cmd(Vis *vis, const char *cmd);
+VIS_EXPORT bool vis_prompt_cmd(Vis *vis, const char *cmd);
/**
* Write newline separated list of available commands to ``buf``
@@ -1240,7 +1244,7 @@ bool vis_prompt_cmd(Vis *vis, const char *cmd);
* @param buf The buffer to write to.
* @param prefix Prefix to filter command list by.
*/
-void vis_print_cmds(Vis*, Buffer *buf, const char *prefix);
+VIS_EXPORT void vis_print_cmds(Vis*, Buffer *buf, const char *prefix);
/**
* Pipe a given file range to an external process.
@@ -1276,7 +1280,7 @@ void vis_print_cmds(Vis*, Buffer *buf, const char *prefix);
*
* @return The exit status of the forked process.
*/
-int vis_pipe(Vis *vis, File *file, Filerange *range, const char *argv[],
+VIS_EXPORT int vis_pipe(Vis *vis, File *file, Filerange *range, const char *argv[],
void *stdout_context, ssize_t (*read_stdout)(void *stdout_context, char *data, size_t len),
void *stderr_context, ssize_t (*read_stderr)(void *stderr_context, char *data, size_t len),
bool fullscreen);
@@ -1296,7 +1300,7 @@ int vis_pipe(Vis *vis, File *file, Filerange *range, const char *argv[],
* by the caller.
* @endrst
*/
-int vis_pipe_collect(Vis *vis, File *file, Filerange *range, const char *argv[], char **out, char **err, bool fullscreen);
+VIS_EXPORT int vis_pipe_collect(Vis *vis, File *file, Filerange *range, const char *argv[], char **out, char **err, bool fullscreen);
/**
* Pipe a buffer to an external process, return its exit status and capture
@@ -1312,7 +1316,7 @@ int vis_pipe_collect(Vis *vis, File *file, Filerange *range, const char *argv[],
* by the caller.
* @endrst
*/
-int vis_pipe_buf_collect(Vis *vis, const char *buf, const char *argv[], char **out, char **err, bool fullscreen);
+VIS_EXPORT int vis_pipe_buf_collect(Vis *vis, const char *buf, const char *argv[], char **out, char **err, bool fullscreen);
/** @} */
@@ -1333,13 +1337,13 @@ int vis_pipe_buf_collect(Vis *vis, const char *buf, const char *argv[], char **o
* Given the start of a symbolic key, returns a pointer to the start of the one
* immediately following it.
*/
-const char *vis_keys_next(Vis *vis, const char *keys);
+VIS_EXPORT const char *vis_keys_next(Vis *vis, const char *keys);
/**
* Convert next symbolic key to an Unicode code point, returns ``-1`` for unknown keys.
* @param vis The editor instance.
* @param keys The symbolic key string.
*/
-long vis_keys_codepoint(Vis *vis, const char *keys);
+VIS_EXPORT long vis_keys_codepoint(Vis *vis, const char *keys);
/**
* Convert next symbolic key to a UTF-8 sequence.
* @param vis The editor instance.
@@ -1350,13 +1354,13 @@ long vis_keys_codepoint(Vis *vis, const char *keys);
* .. note:: Guarantees that ``utf8`` is NUL terminated on success.
* @endrst
*/
-bool vis_keys_utf8(Vis *vis, const char *keys, char utf8[static UTFmax+1]);
+VIS_EXPORT bool vis_keys_utf8(Vis *vis, const char *keys, char utf8[static UTFmax+1]);
/**
* Process symbolic keys as if they were user originated input.
* @param vis The editor instance.
* @param keys The symbolic key string to feed.
*/
-void vis_keys_feed(Vis *vis, const char *keys);
+VIS_EXPORT void vis_keys_feed(Vis *vis, const char *keys);
/** @} */
/*
@@ -1379,7 +1383,7 @@ void vis_keys_feed(Vis *vis, const char *keys);
* .. warning:: The caller must free the regex object using `text_regex_free`.
* @endrst
*/
-Regex *vis_regex(Vis *vis, const char *pattern);
+VIS_EXPORT Regex *vis_regex(Vis *vis, const char *pattern);
/**
* Take an undo snapshot to which we can later revert.
@@ -1389,11 +1393,11 @@ Regex *vis_regex(Vis *vis, const char *pattern);
* .. note:: Does nothing when invoked while replaying a macro.
* @endrst
*/
-void vis_file_snapshot(Vis *vis, File *file);
+VIS_EXPORT void vis_file_snapshot(Vis *vis, File *file);
/** @} */
/* TODO: expose proper API to iterate through files etc */
-Text *vis_text(Vis*);
-View *vis_view(Vis*);
+VIS_EXPORT Text *vis_text(Vis*);
+VIS_EXPORT View *vis_view(Vis*);
#endif