cmdfx 0.2.0
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
screen.h File Reference

Screen API for controlling other things around the terminal. More...

Go to the source code of this file.

Functions

const char * Window_getTitle ()
 Gets the title of the terminal window.
 
void Window_setTitle (const char *title)
 Sets the title of the terminal window.
 
void Window_getSize (int *width, int *height)
 Gets the size of the terminal window, and stores it in the width and height variables.
 
void Window_setSize (int width, int height)
 Sets the size of the terminal window.
 
void Screen_getSize (int *width, int *height)
 Gets the size of the screen, and stores it in the width and height variables.
 
void Screen_getMousePos (int *x, int *y)
 Gets the position of the mouse, and stores it in the x and y variables.
 
int Screen_isEchoEnabled ()
 Gets whether or not echoing is enabled.
 
int Screen_setEchoEnabled (int enabled)
 Sets whether or not echoing is enabled.
 
int Screen_isLineBuffered ()
 Gets whether or not line buffering is enabled.
 
int Screen_setLineBuffered (int enabled)
 Sets whether or not line buffering is enabled.
 
int Screen_isInTerminal ()
 Checks if the program is running in a terminal.
 
void Screen_ensureInTerminal ()
 Ensures that the program is running in a terminal.
 

Detailed Description

Screen API for controlling other things around the terminal.

Author
Gregory Mitchell (me@gm.nosp@m.itch.nosp@m.215.x.nosp@m.yz)
Version
0.1.0
Date
2025-01-24

Function Documentation

◆ Screen_ensureInTerminal()

void Screen_ensureInTerminal ( )

Ensures that the program is running in a terminal.

This method will check if the program is running in a terminal. If it is not, the program will exit and launch the program in a terminal.

◆ Screen_getMousePos()

void Screen_getMousePos ( int * x,
int * y )

Gets the position of the mouse, and stores it in the x and y variables.

This method gets the position of the mouse on the screen. The x and y variables will be updated with the x and y position of the mouse.

This method will require administrator privileges on Linux.

Parameters
xThe pointer to the x position of the mouse.
yThe pointer to the y position of the mouse.

◆ Screen_getSize()

void Screen_getSize ( int * width,
int * height )

Gets the size of the screen, and stores it in the width and height variables.

Parameters
widthThe pointer to the width of the screen.
heightThe pointer to the height of the screen.

◆ Screen_isEchoEnabled()

int Screen_isEchoEnabled ( )

Gets whether or not echoing is enabled.

This method gets whether or not echoing is enabled on the terminal. Echoing is when the terminal displays the characters that are typed. If this is off, the terminal will not display the characters when they are typed.

Returns
1 if echoing is enabled, 0 if it is not.

◆ Screen_isInTerminal()

int Screen_isInTerminal ( )

Checks if the program is running in a terminal.

This method checks if the program is running in a terminal. This is useful for determining if your setup is correct.`

Returns
1 if the program is running in a terminal, 0 if it is not.

◆ Screen_isLineBuffered()

int Screen_isLineBuffered ( )

Gets whether or not line buffering is enabled.

This method gets whether or not line buffering is enabled on the terminal. Line buffering is when the terminal waits for a newline character before sending the input to the program. This must be disabled in order to listen for individual key presses, otherwise events will only pass if the user presses enter.

Returns
1 if line buffering is enabled, 0 if it is not.

◆ Screen_setEchoEnabled()

int Screen_setEchoEnabled ( int enabled)

Sets whether or not echoing is enabled.

Parameters
enabled1 to enable echoing, 0 to disable echoing.
Returns
0 if successful, -1 if an error occurred.

◆ Screen_setLineBuffered()

int Screen_setLineBuffered ( int enabled)

Sets whether or not line buffering is enabled.

Parameters
enabled1 to enable line buffering, 0 to disable line buffering.
Returns
0 if successful, -1 if an error occurred.

◆ Window_getSize()

void Window_getSize ( int * width,
int * height )

Gets the size of the terminal window, and stores it in the width and height variables.

Parameters
widthThe pointer to the width of the terminal window.
heightThe pointer to the height of the terminal window.

◆ Window_getTitle()

const char * Window_getTitle ( )

Gets the title of the terminal window.

Returns
The title of the terminal window.

◆ Window_setSize()

void Window_setSize ( int width,
int height )

Sets the size of the terminal window.

Parameters
widthThe width of the terminal window.
heightThe height of the terminal window.

◆ Window_setTitle()

void Window_setTitle ( const char * title)

Sets the title of the terminal window.

Parameters
titleThe title to set.