I'm working on creating a double screen buffer in C to have greater control of the display on the terminal. In the meantime, more useful functions useful to that end. :)
Show/Hide cursor:
void hide_cursor()
{
printf("\e[?25l");
}
void show_cursor()
{
printf("\e[?25h");
}
Draw box-like characters on Linux Terminal:
ASCII characters change from 106 to 121.
printf("%c(0", 0x1b); // Border chars on
Get Terminal Dimensions:
#include <sys/ioctl.h>
#include <stdio.h>
struct winsize max;
int get_terminal_dimensions(int *rows, int *columns)
{
//Get dimensions of screen and pass them by value.
ioctl(0, TIOCGWINSZ , &max);
*columns = max.ws_col;
*rows = max.ws_row;
return 0;
}
No comments:
Post a Comment