/* SPDX-License-Identifier: GPL-3.0-or-later */ /* Insert two keys into a tiny terminal editor. Link ebitor. */ #include #include static byte readKey(void *cookie) { return inkey(); } int main(void) { char log[32] = ""; ebitor_Window window = { 32, 15, 0, 0, 0, 0 }; width(32); sg4term_init((char *) 0x0400, &window, readKey, NULL, (word *) 0x0112); Ebitor_init(log, sizeof(log), 32, 15, sg4term_clear, sg4term_locate, sg4term_getCursorPos, sg4term_print, sg4term_printPrefix, sg4term_clrtoeol, sg4term_scrollWindowUp, sg4term_scrollWindowDown, sg4term_waitEditorKey); Ebitor_setContentLength(0); Ebitor_locateCursorAtSavedPosition(); Ebitor_processKey('O'); Ebitor_processKey('K'); Ebitor_processKey(ebitor_KEY_ARROW_LEFT); /* Commit the inserted run and move left. */ Ebitor_saveCursorPosition(); unsigned count = Ebitor_getContentLength(); Ebitor_shutdown(); cls(255); log[count] = 0; /* Two characters fit comfortably in our buffer. */ printf("LOG: %s\n", log); return 0; }