CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Cursor and Screen

Typedefs

typedef enum ConEraseMode ConEraseMode
 Which portion of a line or screen to erase, relative to the current cursor position.
 

Enumerations

enum  ConEraseMode { CON_EraseToEnd , CON_EraseToStart , CON_EraseAll }
 Which portion of a line or screen to erase, relative to the current cursor position. More...
 

Functions

bool conSetCursor (ConStream *con, uint16 row, uint16 col)
 
bool conMoveCursor (ConStream *con, int16 drow, int16 dcol)
 
bool conGetCursor (ConStream *con, uint16 *row, uint16 *col)
 
bool conShowCursor (ConStream *con, bool show)
 
bool conSaveCursor (ConStream *con)
 
bool conRestoreCursor (ConStream *con)
 
bool conEraseLine (ConStream *con, ConEraseMode mode)
 
bool conEraseScreen (ConStream *con, ConEraseMode mode)
 
bool conScroll (ConStream *con, int16 lines)
 
bool conAltScreen (ConStream *con, bool enable)
 

Detailed Description

Enumeration Type Documentation

◆ ConEraseMode

Which portion of a line or screen to erase, relative to the current cursor position.

Enumerator
CON_EraseToEnd 

From the cursor to the end of the line/screen.

CON_EraseToStart 

From the start of the line/screen to the cursor.

CON_EraseAll 

The entire line/screen.

Definition at line 15 of file concursor.h.

Function Documentation

◆ conAltScreen()

bool conAltScreen ( ConStream *  con,
bool  enable 
)

Switches to (or back from) the terminal's alternate screen buffer, if available (see ConCaps::altscreen). Only ever available under VT – the legacy Windows console has no equivalent, so this always fails there.

Parameters
conDestination stream
enabletrue to switch to the alternate screen, false to switch back
Returns
true on success

◆ conEraseLine()

bool conEraseLine ( ConStream *  con,
ConEraseMode  mode 
)

Erases part or all of the current line. The cursor position does not change.

Parameters
conDestination stream
modeWhich portion of the line to erase
Returns
true on success

◆ conEraseScreen()

bool conEraseScreen ( ConStream *  con,
ConEraseMode  mode 
)

Erases part or all of the screen. The cursor position does not change.

Parameters
conDestination stream
modeWhich portion of the screen to erase
Returns
true on success

◆ conGetCursor()

bool conGetCursor ( ConStream *  con,
uint16 *  row,
uint16 *  col 
)

Reports the cursor's current absolute position.

Only available when ConCaps::cursorquery is true – querying position under VT would require sending a DSR request and reading the reply from stdin, racing with any other input consumer and potentially hanging against a terminal that never answers, so this module never attempts it. Use conSaveCursor()/conRestoreCursor() instead, which is what most callers actually need and works under VT too.

Parameters
conStream to query
rowReceives the 0-based row
colReceives the 0-based column
Returns
true on success; false if the stream cannot report its position

◆ conMoveCursor()

bool conMoveCursor ( ConStream *  con,
int16  drow,
int16  dcol 
)

Moves the cursor relative to its current position. Positive drow moves down, positive dcol moves right; either may be negative.

On a stream without ConCaps::cursorquery (most VT terminals), this still works even though conGetCursor() would fail – moving relative to the current position doesn't require knowing what that position is.

Parameters
conDestination stream
drowRows to move (negative moves up)
dcolColumns to move (negative moves left)
Returns
true on success

◆ conRestoreCursor()

bool conRestoreCursor ( ConStream *  con)

Restores the cursor position most recently saved with conSaveCursor(). A no-op returning false if nothing has been saved.

Parameters
conStream to restore
Returns
true on success

◆ conSaveCursor()

bool conSaveCursor ( ConStream *  con)

Saves the current cursor position for a later conRestoreCursor().

Only one position is remembered at a time; a second conSaveCursor() before a matching conRestoreCursor() overwrites the first.

Parameters
conStream whose cursor position to save
Returns
true on success

◆ conScroll()

bool conScroll ( ConStream *  con,
int16  lines 
)

Scrolls the screen content. Positive lines scrolls up, revealing blank lines at the bottom; negative scrolls down, revealing blank lines at the top. The cursor position does not change.

Parameters
conDestination stream
linesNumber of lines to scroll (negative scrolls down)
Returns
true on success

◆ conSetCursor()

bool conSetCursor ( ConStream *  con,
uint16  row,
uint16  col 
)

Moves the cursor to an absolute position.

A no-op returning false if the stream has no cursor capability (see ConCaps::cursor).

Parameters
conDestination stream
row0-based row
col0-based column
Returns
true on success

◆ conShowCursor()

bool conShowCursor ( ConStream *  con,
bool  show 
)

Shows or hides the cursor.

Parameters
conDestination stream
showtrue to show, false to hide
Returns
true on success