Usermode/GUI Terminal - Moar!
[tpg/acess2.git] / Usermode / Applications / gui_shell_src / vt100.c
1 /*
2  * Acess GUI Terminal
3  * - By John Hodge (thePowersGang)
4  *
5  * main.c
6  * - Core
7  */
8 #include <string.h>
9 #include "include/vt100.h"
10 #include "include/display.h"
11
12 int Term_HandleVT100(int Len, const char *Buf)
13 {
14         const int       max_length = 16;
15         static char     inc_buf[max_length]
16         static int      inc_len = 0;
17
18         if( inc_len > 0 || *Buf == '\x1b' )
19         {
20                 memcpy(inc_buf + inc_len, Buf, min(max_length - inc_len, Len));
21                 // Handle VT100 (like) escape sequence
22                 
23                 inc_len = 0;
24                 return 1;
25         }
26
27         switch( *Buf )
28         {
29         case '\b':
30                 // TODO: Backspace
31                 return 1;
32         case '\t':
33                 // TODO: tab
34                 return 1;
35         case '\n':
36                 Display_Newline(1);
37                 return 1;
38         case '\r':
39                 // TODO: Carriage return
40                 return ;
41         }
42
43          int    ret = 0;
44         while( ret < Len )
45         {
46                 if( *Buf == '\n' )
47                         break;
48                 if( *Buf == '\x1b' )
49                         break;
50                 ret ++;
51                 Buf ++;
52         }
53         return -ret;
54 }

UCC git Repository :: git.ucc.asn.au