Skip to main content

Cursor

int lt_set_cursor(int x, int y);
int lt_hide_cursor(void);
int lt_show_cursor(void);

The hardware cursor starts hidden after lt_init, the same as termbox2. lt_shutdown restores its visibility for the shell.

lt_set_cursor​

int lt_set_cursor(int x, int y);

Moves the hardware cursor to (x, y) and shows it. lt_present keeps the cursor parked there across frames.

Parameters​

NameTypeMeaning
xintcolumn, 0 at the left
yintrow, 0 at the top

Returns​

ValueWhen
LT_OKthe cursor is placed and visible
LT_ERR_OUT_OF_BOUNDSa negative coordinate
LT_ERR_NOT_INITbefore lt_init

Example​

lt_print(2, 1, LT_DEFAULT, LT_DEFAULT, "name: ");
lt_set_cursor(8, 1); /* the input point, cursor shown */
lt_present();

See also​

lt_hide_cursor, Screen and rendering.

lt_hide_cursor​

int lt_hide_cursor(void);

Hides the hardware cursor with DECTCEM. Calling it when the cursor is already hidden emits nothing.

Parameters​

None.

Returns​

ValueWhen
LT_OKthe cursor is hidden
LT_ERR_NOT_INITbefore lt_init

Example​

lt_hide_cursor(); /* leaving the text field */
lt_present();

See also​

lt_set_cursor.

lt_show_cursor​

int lt_show_cursor(void);

Shows the hardware cursor at its current position. termbox2 has no equivalent, so ported code usually calls lt_set_cursor instead.

Parameters​

None.

Returns​

ValueWhen
LT_OKthe cursor is visible
LT_ERR_NOT_INITbefore lt_init

Example​

lt_show_cursor(); /* back at the position lt_set_cursor last gave it */

See also​

lt_set_cursor.