summaryrefslogtreecommitdiff
path: root/libterm/term.h
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2016-05-10 22:42:11 +0100
committerFreeArtMan <dos21h@gmail.com>2016-05-10 22:42:11 +0100
commit44dedb90f005bb0de9bddbd592a5c78f28bc67d1 (patch)
tree274b9cea44df3f96a965c564e26cdac42d3af94f /libterm/term.h
parentbb426577c85f6d97cc28ab677e98e2b1f73eadac (diff)
downloadihe-44dedb90f005bb0de9bddbd592a5c78f28bc67d1.tar.gz
ihe-44dedb90f005bb0de9bddbd592a5c78f28bc67d1.zip
Replace cmd first part
Diffstat (limited to 'libterm/term.h')
-rw-r--r--libterm/term.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/libterm/term.h b/libterm/term.h
new file mode 100644
index 0000000..df3d7b1
--- /dev/null
+++ b/libterm/term.h
@@ -0,0 +1,70 @@
+#ifndef __LIBTERM_TERM_H
+#define __LIBTERM_TERM_H
+
+#include <termios.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+#include "screen_modes.h"
+#include "debug.h"
+
+enum TERM_KEY_ACTION {
+ KEY_NULL = 0, /* NULL */
+ CTRL_A = 1, /* Ctrl+a */
+ CTRL_B = 2, /* Ctrl-b */
+ CTRL_C = 3, /* Ctrl-c */
+ CTRL_D = 4, /* Ctrl-d */
+ CTRL_E = 5, /* Ctrl-e */
+ CTRL_F = 6, /* Ctrl-f */
+ CTRL_H = 8, /* Ctrl-h */
+ TAB = 9, /* Tab */
+ CTRL_K = 11, /* Ctrl+k */
+ CTRL_L = 12, /* Ctrl+l */
+ ENTER = 13, /* Enter */
+ CTRL_N = 14, /* Ctrl-n */
+ CTRL_P = 16, /* Ctrl-p */
+ CTRL_T = 20, /* Ctrl-t */
+ CTRL_U = 21, /* Ctrl+u */
+ CTRL_W = 23, /* Ctrl+w */
+ ESC = 27, /* Escape */
+ QMARK = 63, /* ? */
+ BACKSPACE = 127 /* Backspace */
+};
+
+
+#define TK_ENTER 13
+#define TK_ESC 27
+#define TK_BACKSPACE 8
+
+typedef struct term_screen
+{
+ int ifd, ofd;
+ struct termios orig_i, orig_o;
+ struct termios raw_i, raw_o;
+ screen_mode_e mode;
+} term_screen;
+
+int term_init( term_screen *ts );
+int term_set_speed( term_screen *ts, speed_t speed);
+int term_get_maxcol( term_screen *ts );
+int term_get_maxrow( term_screen *ts );
+int term_cur_get_c( term_screen *ts );
+int term_cur_get_r( term_screen *ts );
+int term_cur_set_c( term_screen *ts, unsigned int pc );
+int term_cur_set_r( term_screen *ts, unsigned int pr );
+int term_cur_set_cr( term_screen *ts, unsigned int pc , unsigned int pr );
+int term_clr_scr( term_screen *ts );
+int term_set_raw_mode( term_screen *ts );
+int term_mode_rows( term_screen *ts );
+int term_mode_columns( term_screen *ts );
+void term_set_orig_mode( term_screen *ts );
+
+#endif