|
ze
|

Files | |
| file | input.c |
| Prompt and keypress handling implementations. | |
Functions | |
| char * | editorPrompt (char *prompt, void(*callback)(char *, int)) |
| Display a prompt and capture input with optional incremental callback. | |
| void | editorMoveCursor (char key) |
| Move the cursor one step in the given direction, clamped to content. | |
| void | editorProcessKeypress (void) |
| Decode a keypress and execute the corresponding editor action. | |
| void editorMoveCursor | ( | char | key | ) |
Move the cursor one step in the given direction, clamped to content.
Updates E.cx and E.cy according to key. When moving left from the beginning of a line, moves to the end of the previous line. When moving right past the end of a line, moves to the start of the next line. Ensures E.cx is not beyond the line length.
| [in] | key | One of ARROW_LEFT, ARROW_RIGHT, ARROW_UP, ARROW_DOWN. |
| void editorProcessKeypress | ( | void | ) |
Decode a keypress and execute the corresponding editor action.
Reads one key via editorReadKey(), dispatches plugin key handlers first, and falls back to built-in controls (insert/delete/newline/save/open/search/etc.). May modify the buffer, cursor, dirty state, and status message.
| char * editorPrompt | ( | char * | prompt, |
| void(*)(char *, int) | callback | ||
| ) |
Display a prompt and capture input with optional incremental callback.
| prompt | printf-style prompt format including one s for current buffer |
| callback | Optional callback receiving (buffer, last_key) |
Displays a prompt on the status line, appending the current input buffer, and reads keypresses until Enter (returns the input) or Escape (returns NULL). If a callback is provided, it is invoked after each keypress with the current buffer and the last key code, enabling live behaviors (e.g., search).
Allocation/ownership: returns a heap-allocated, NUL-terminated C string on success; caller must free(). On cancel (Escape), returns NULL.