xbee_recv: fix frame data pointer
[protos/xbee-avr.git] / vt100.h
1 /*  
2  *  Copyright Droids Corporation (2007)
3  *  Olivier MATZ <zer0@droids-corp.org>
4  * 
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  *  Revision : $Id: vt100.h,v 1.1.2.2 2009-04-07 20:01:16 zer0 Exp $
20  *
21  *
22  */
23
24 #ifndef _VT100_H_
25 #define _VT100_H_
26
27 #define vt100_bell         "\007"
28 #define vt100_bs           "\010"
29 #define vt100_bs_clear     "\010 \010"
30 #define vt100_tab          "\011"
31 #define vt100_crnl         "\012\015"
32 #define vt100_clear_right  "\033[0K"
33 #define vt100_clear_left   "\033[1K"
34 #define vt100_clear_down   "\033[0J"
35 #define vt100_clear_up     "\033[1J"
36 #define vt100_clear_line   "\033[2K"
37 #define vt100_clear_screen "\033[2J"
38 #define vt100_up_arr       "\033\133\101"
39 #define vt100_down_arr     "\033\133\102"
40 #define vt100_right_arr    "\033\133\103"
41 #define vt100_left_arr     "\033\133\104"
42 #define vt100_multi_right  "\033\133%uC"
43 #define vt100_multi_left   "\033\133%uD"
44 #define vt100_suppr        "\033\133\063\176"
45 #define vt100_home         "\033M\033E"
46 #define vt100_word_left    "\033\142"
47 #define vt100_word_right   "\033\146"
48
49
50 /* Result of parsing : it must be synchronized with vt100_commands[]
51  * in vt100.c */
52 #define KEY_UP_ARR 0
53 #define KEY_DOWN_ARR 1
54 #define KEY_RIGHT_ARR 2
55 #define KEY_LEFT_ARR 3
56 #define KEY_BKSPACE 4
57 #define KEY_RETURN 5
58 #define KEY_CTRL_A 6
59 #define KEY_CTRL_E 7
60 #define KEY_CTRL_K 8
61 #define KEY_CTRL_Y 9
62 #define KEY_CTRL_C 10
63 #define KEY_CTRL_F 11
64 #define KEY_CTRL_B 12
65 #define KEY_SUPPR 13
66 #define KEY_TAB 14
67 #define KEY_CTRL_D 15
68 #define KEY_CTRL_L 16
69 #define KEY_RETURN2 17
70 #define KEY_META_BKSPACE 18
71 #define KEY_WLEFT 19
72 #define KEY_WRIGHT 20
73 #define KEY_HELP 21
74
75 extern const prog_char * vt100_commands[] PROGMEM;
76
77 enum vt100_parser_state {
78         VT100_INIT,
79         VT100_ESCAPE,
80         VT100_ESCAPE_CSI,
81 };
82
83 #define VT100_BUF_SIZE 8
84 struct vt100 {
85         uint8_t bufpos;
86         char buf[VT100_BUF_SIZE];
87         enum vt100_parser_state state;
88 };
89
90 /**
91  * Init
92  */
93 void vt100_init(struct vt100 *vt);
94
95 /**
96  * Input a new character. 
97  * Return -1 if the character is not part of a control sequence
98  * Return -2 if c is not the last char of a control sequence
99  * Else return the index in vt100_commands[]
100  */
101 int8_t vt100_parser(struct vt100 *vt, char c);
102
103 #endif