aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-01-25 20:29:35 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-01-25 20:29:35 -0800
commitc5f6e30042fe45dc5c2d3b1ce8db6da468e48bbd (patch)
tree460d4baf97ec1fa867d89f714ed5f6779c83b3d3 /src
parent1ee25077b8cc720f18f8d647414ba83de236cd38 (diff)
downloadteliva-c5f6e30042fe45dc5c2d3b1ce8db6da468e48bbd.tar.gz
start supporting non-code "buffers"
First step: when a "definition" starts with "doc:" it's not a definition, just a buffer. Stop trying to interpret it as Lua.
Diffstat (limited to 'src')
-rw-r--r--src/teliva.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/teliva.c b/src/teliva.c
index 39a1d76..d1d3f22 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -632,6 +632,10 @@ void draw_callers_of_current_definition(lua_State* L) {
assert(oldtop == lua_gettop(L));
}
+static int starts_with(const char* s, const char* pre) {
+ return strncmp(pre, s, strlen(pre)) == 0;
+}
+
extern int load_editor_buffer_to_current_definition_in_image(lua_State* L);
extern int resumeEdit(lua_State* L);
extern int editFrom(lua_State* L, char* filename, int rowoff, int coloff, int cy, int cx);
@@ -651,6 +655,7 @@ int restore_editor_view(lua_State* L) {
int cx = lua_tointeger(L, -1);
lua_settop(L, editor_state_index);
int back_to_big_picture = editFrom(L, "teliva_editor_buffer", rowoff, coloff, cy, cx);
+ if (starts_with(Current_definition, "doc:")) return back_to_big_picture;
// error handling
int oldtop = lua_gettop(L);
while (1) {
@@ -820,6 +825,7 @@ extern int load_editor_buffer_to_current_definition_in_image(lua_State* L) {
extern int edit(lua_State* L, char* filename);
static int edit_current_definition(lua_State* L) {
int back_to_big_picture = edit(L, "teliva_editor_buffer");
+ if (starts_with(Current_definition, "doc:")) return back_to_big_picture;
// error handling
int oldtop = lua_gettop(L);
while (1) {