+/Femto
toy text editor
git clone https://git.julia.blue/+/Femto
bc37ee9
master
1#ifndef TERMINAL_H 2#define TERMINAL_H 3 4#include <ctype.h> 5#include <errno.h> 6#include <stdio.h> 7#include <stdlib.h> 8#include <sys/ioctl.h> 9#include <termios.h> 10#include <unistd.h> 11 12#include "editor.h" 13 14/** 15* Exits the program, printing a human readable error message. 16* To actually see these messages you have to disable smcup and rmcup in 17* enableRawMode(). 18*/ 19void die (const char * s ); 20 21/** 22* Prints raw byte values of characters from stdin (blocking). 23*/ 24void debugRead (); 25 26/** 27* Messes with terminal settings to disable unwanted stuff like echoing. 28*/ 29void enableRawMode (); 30 31/** 32* Resets terminal to normal settings and clears the screen (called on exit). 33*/ 34void disableRawMode (); 35 36/** 37* Queries terminal for cursor x and y. 38* @return exit status 39*/ 40int getCursorPosition (int * x ,int * y ); 41 42/** 43* Queries terminal for width and height. 44* @return exit status 45*/ 46int getWindowSize (int * rows ,int * cols ); 47 48void clearScreen (); 49 50/** 51* Reads keypress and if needed parses escape sequences for special keys like 52* arrows, backspace, etc. (blocking). 53* @return keycode as int instead of char to allow for enum of special 54* keys 55*/ 56int readKey (); 57 58#endif