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.
This commit is contained in:
Kartik K. Agaram 2022-01-25 20:29:35 -08:00
parent 1ee25077b8
commit c5f6e30042
1 changed files with 6 additions and 0 deletions

View File

@ -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) {