fork a new editor widget for non-code

This commit is contained in:
Kartik K. Agaram 2022-01-02 16:55:23 -08:00
parent f6aaf2fd1d
commit a2081ee612
2 changed files with 49 additions and 2 deletions

View File

@ -1206,6 +1206,53 @@ int edit(lua_State* L, char* filename) {
return Back_to_big_picture;
}
static void editorNonCodeMenu(void) {
attrset(A_REVERSE);
for (int x = 0; x < COLS; ++x)
mvaddch(LINES-1, x, ' ');
attrset(A_NORMAL);
menu_column = 2;
draw_menu_item("^e", "back");
if (Previous_error != NULL) {
attron(A_BOLD);
draw_menu_item("^c", "abort");
attroff(A_BOLD);
}
draw_menu_item("^f", "find");
draw_menu_item("^h", "backspace");
draw_menu_item("^l", "end of line");
/* draw_menu_item("^/|^-|^_", "(un)comment line"); */
attroff(A_REVERSE);
mvaddstr(LINES-1, menu_column, " ^/");
attron(COLOR_PAIR(COLOR_PAIR_MENU_ALTERNATE));
addstr("|");
attroff(COLOR_PAIR(COLOR_PAIR_MENU_ALTERNATE));
addstr("^-");
attron(COLOR_PAIR(COLOR_PAIR_MENU_ALTERNATE));
addstr("|");
attroff(COLOR_PAIR(COLOR_PAIR_MENU_ALTERNATE));
addstr("^_ ");
menu_column += 10;
attron(A_REVERSE);
mvaddstr(LINES-1, menu_column, " (un)comment line ");
menu_column += 18;
attrset(A_NORMAL);
}
/* return true if user chose to back into the big picture view */
void editNonCode(char* filename) {
Quit = 0;
Back_to_big_picture = 0;
initEditor();
editorOpen(filename);
while(!Quit) {
E.cols = COLS-LINE_NUMBER_SPACE; /* update on resize */
editorRefreshScreen(editorNonCodeMenu);
int c = getch();
editorProcessKeypress2(c);
}
}
/* return true if user chose to back into the big picture view */
int editFrom(lua_State* L, char* filename, int rowoff, int coloff, int cy, int cx) {
Quit = 0;

View File

@ -875,6 +875,7 @@ static void load_note_from_editor_buffer(lua_State* L, int cursor) {
lua_pop(L, 2); /* table at cursor, teliva_program */
}
extern int editNonCode(char* filename);
static void recent_changes_view(lua_State* L) {
lua_getglobal(L, "teliva_program");
int history_array = lua_gettop(L);
@ -904,8 +905,7 @@ static void recent_changes_view(lua_State* L) {
case CTRL_E:
save_note_to_editor_buffer(L, cursor);
/* big picture hotkey unnecessarily available here */
/* TODO: go hotkey is misleading. edits will not be persisted until you return to recent changes */
edit(L, "teliva_editor_buffer");
editNonCode("teliva_editor_buffer");
load_note_from_editor_buffer(L, cursor);
save_tlv(L, Image_name);
break;