|
conio_lt 0.2.0
A lite version of the 'conio.h' library for Unix-like systems.
|
conio_lt library is a lightweight adaptation of the <conio.h> library designed for Unix-like systems.
More...
#include <stdio.h>#include <stdint.h>#include <unistd.h>#include <fcntl.h>#include <termios.h>Go to the source code of this file.
Typedefs | |
| typedef unsigned int | cpos_t |
| An abbreviation from Cursor Position Type. | |
Functions | |
| void | gotoxy (const cpos_t __x, const cpos_t __y) |
| Moves the cursor to the specified coordinates on the terminal screen. | |
| void | clrscr (void) |
| Clears the terminal screen. | |
| void | rstscr (void) |
| Resets and clears the terminal screen. | |
| const int | ungetch (const int __c) |
| Pushes a character back onto the input stream. | |
| const int | getch (void) |
| Reads a single character from the standard input without echoing it. | |
| const int | getche (void) |
| Reads a single character from the standard input and then echoing it. | |
| const cpos_t | wherex (void) |
| Retrieves the current X-coordinate of the cursor on the terminal screen. | |
| const cpos_t | wherey (void) |
| Retrieves the current Y-coordinate of the cursor on the terminal screen. | |
| void | wherexy (cpos_t *__x, cpos_t *__y) |
| Retrieves the current X and Y coordinates of the cursor on the terminal screen. | |
| const int | putch (const int __chr) |
| Writes a character to the standard output. | |
| void | gotox (const cpos_t __x) |
| Sets the cursor position to the specified X-coordinate, maintaining the current Y-coordinate. | |
| void | gotoy (const cpos_t __y) |
| Sets the cursor position to the specified Y-coordinate, maintaining the current X-coordinate. | |
conio_lt library is a lightweight adaptation of the <conio.h> library designed for Unix-like systems.
This project aims to bring these functionalities to Unix-like systems and Borland C++, especially for legacy version of Borland C++.
| typedef unsigned int cpos_t |
An abbreviation from Cursor Position Type.
Custom type definition to represent the cursor position.
| void clrscr | ( | void | ) |
Clears the terminal screen.
This function clears the terminal screen by sending control sequences to the standard output using printf.
The function uses the following control sequences.
| Control sequence | Description |
|---|---|
"\033[0m" | Resets any text formatting or color attributes. |
"\033[1J" | Clears the screen from the cursor position to the end of the screen. |
"\033[H" | Moves the cursor to the top-left corner of the screen. |
By combining these control sequences in a single printf statement, the function achieves the effect of clearing the terminal screen.
| const int getch | ( | void | ) |
Reads a single character from the standard input without echoing it.
This function reads a single character from the standard input without echoing it.
| const int getche | ( | void | ) |
Reads a single character from the standard input and then echoing it.
This function reads a single character from the standard input and then echoing it.
| void gotox | ( | const cpos_t | __x | ) |
Sets the cursor position to the specified X-coordinate, maintaining the current Y-coordinate.
This function serves as an alias for gotoxy(x, wherey()). It allows for flexible cursor manipulation by allowing the user to set the X-coordinate while keeping the current Y-coordinate unchanged.
| __x | The desired X-coordinate to set the cursor to. |
Moves the cursor to the specified coordinates on the terminal screen.
This function moves the cursor on the terminal screen to the specified coordinates. It takes two integer parameters, __x and __y, representing the X and Y coordinates respectively.
| __x | The X-coordinate to move the cursor to. |
| __y | The Y-coordinate to move the cursor to. |
| void gotoy | ( | const cpos_t | __y | ) |
Sets the cursor position to the specified Y-coordinate, maintaining the current X-coordinate.
This function serves as an alias for gotoxy(wherex(), y). It provides flexibility in cursor positioning by allowing the user to set the Y-coordinate while keeping the current X-coordinate unchanged.
| __y | The desired Y-coordinate to set the cursor to. |
| const int putch | ( | const int | __chr | ) |
Writes a character to the standard output.
This function writes a character to the standard output. It takes an integer parameter __chr, representing the character to be written.
| __chr | The character to be written. |
| void rstscr | ( | void | ) |
Resets and clears the terminal screen.
This function resets any text formatting or color attributes, clears the entire terminal screen, and moves the cursor to the top-left corner. It achieves this effect by sending the appropriate control sequences to the standard output using printf.
The function uses the following control sequences.
| Control sequence | Description |
|---|---|
"\033[0m" | Resets any text formatting or color attributes. |
"\033c" | Resets and clears the entire terminal screen. |
By combining these control sequences in a single printf statement, the function achieves the effect of resetting and clearing the terminal screen.
| const int ungetch | ( | const int | __c | ) |
Pushes a character back onto the input stream.
This function pushes a character back onto the input stream. It takes an integer parameter __c, representing the character to be pushed back.
| __c | The character to be pushed back. |
EOF on failure.| const cpos_t wherex | ( | void | ) |
Retrieves the current X-coordinate of the cursor on the terminal screen.
This function retrieves the current X-coordinate of the cursor on the terminal screen. The returned coordinate value always positive value.
Retrieves the current X and Y coordinates of the cursor on the terminal screen.
This function stores the current X-coordinate in the variable pointed to by __x, and the Y-coordinate in the variable pointed to by __y.
To use this function, provide the addresses of variables for X and Y to store the coordinates.
| [in,out] | __x | Pointer to the variable where the X-coordinate will be stored. |
| [in,out] | __y | Pointer to the variable where the Y-coordinate will be stored. |
| const cpos_t wherey | ( | void | ) |
Retrieves the current Y-coordinate of the cursor on the terminal screen.
This function retrieves the current Y-coordinate of the cursor on the terminal screen. The returned coordinate value always positive value.