ze
Loading...
Searching...
No Matches
Files | Functions
Collaboration diagram for Input:

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.
 

Detailed Description

Function Documentation

◆ editorMoveCursor()

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.

Parameters
[in]keyOne of ARROW_LEFT, ARROW_RIGHT, ARROW_UP, ARROW_DOWN.
Postcondition
Cursor position is updated; no modifications to buffer contents.
See also
editorMoveCursor() (Scheme binding), editorInsertNewline()

◆ editorProcessKeypress()

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.

Postcondition
Editor state may change; screen will be refreshed by the main loop.
See also
editorReadKey(), pluginsHandleKey(), editorRefreshScreen()

◆ editorPrompt()

char * editorPrompt ( char *  prompt,
void(*)(char *, int)  callback 
)

Display a prompt and capture input with optional incremental callback.

Parameters
promptprintf-style prompt format including one s for current buffer
callbackOptional callback receiving (buffer, last_key)
Returns
Newly allocated string or NULL if cancelled

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.

Postcondition
Status message is cleared on completion; screen is refreshed during input.
See also
editorFind(), editorOpen(), editorSave(), editorSetStatusMessage()