@@ -36,9 +36,19 @@ Bytes shift_code[] = {
36
36
"Keypad *" , "LAlt" , " "
37
37
};
38
38
39
+ Bytes commands [] = {
40
+ "help" ,
41
+ "reboot" ,
42
+ "clear" ,
43
+ "yes"
44
+ };
45
+ Size com_len = 4 ;
46
+
47
+ Bool shift_down = FALSE;
48
+ Bool ctrl_down = FALSE;
49
+ Char char_buffer [80 ] = {0 };
50
+ Size cb_len = 0 ;
39
51
40
- Bool shift_down = FALSE;
41
- Bool ctrl_down = FALSE;
42
52
43
53
IrsCall keyboard_callback () {
44
54
@@ -61,16 +71,41 @@ IrsCall keyboard_callback() {
61
71
return ;
62
72
}
63
73
else if (code == ENTER ) {
74
+ input (char_buffer );
64
75
tty_print ("\n" );
65
76
tty_print ("> " );
77
+ cb_len = 0 ;
66
78
return ;
67
79
}
68
80
else if (code == BACKSPACE ) {
69
81
tty_print ("\b" );
82
+
83
+ char_buffer [cb_len - 1 ] = '\0' ;
84
+ cb_len -- ;
85
+
70
86
return ;
71
87
}
72
88
else if (code == TAB ) {
73
- tty_print ("\t" );
89
+
90
+ Size len = strlen (char_buffer );
91
+ Size contained = 0 ;
92
+
93
+ for (Size icom = 0 ; icom < com_len ; icom ++ ) {
94
+ for (Size idx = 0 ; idx < len ; idx ++ ) {
95
+
96
+ if (* char_buffer == * (commands [icom ])) {
97
+ contained ++ ;
98
+ }
99
+ }
100
+ if (contained == len ) {
101
+ tty_print (commands [icom ] + len );
102
+ strcat (char_buffer , commands [icom ] + len );
103
+ cb_len = strlen (commands [icom ]);
104
+ contained = 0 ;
105
+ break ;
106
+ }
107
+
108
+ }
74
109
return ;
75
110
}
76
111
else if (code == LEFT ) {
@@ -109,11 +144,22 @@ IrsCall keyboard_callback() {
109
144
return ;
110
145
}
111
146
147
+ if (ctrl_down && code == 19 ) {
148
+ tty_print ("\n> Rebooting..." );
149
+ wait ();
150
+ reboot ();
151
+ return ;
152
+ }
153
+
112
154
if (shift_down ) {
113
155
tty_print (shift_code [code ]);
156
+ strncat (char_buffer , shift_code [code ], 1 );
157
+ cb_len ++ ;
114
158
}
115
159
else {
116
160
tty_print (nshift_code [code ]);
161
+ strncat (char_buffer , nshift_code [code ], 1 );
162
+ cb_len ++ ;
117
163
}
118
164
}
119
165
}
0 commit comments