diff options
author | skullY <skullydazed@gmail.com> | 2019-08-30 11:19:03 -0700 |
---|---|---|
committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-08-30 15:01:52 -0700 |
commit | b624f32f944acdc59dcb130674c09090c5c404cb (patch) | |
tree | bc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /quantum/process_keycode/process_terminal.c | |
parent | 61af76a10d00aba185b8338604171de490a13e3b (diff) | |
download | qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.zip |
clang-format changes
Diffstat (limited to 'quantum/process_keycode/process_terminal.c')
-rw-r--r-- | quantum/process_keycode/process_terminal.c | 271 |
1 files changed, 122 insertions, 149 deletions
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c index e791deffc..f48f3d702 100644 --- a/quantum/process_keycode/process_terminal.c +++ b/quantum/process_keycode/process_terminal.c | |||
@@ -21,62 +21,45 @@ | |||
21 | #include <math.h> | 21 | #include <math.h> |
22 | 22 | ||
23 | #ifndef CMD_BUFF_SIZE | 23 | #ifndef CMD_BUFF_SIZE |
24 | #define CMD_BUFF_SIZE 5 | 24 | # define CMD_BUFF_SIZE 5 |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | |||
28 | bool terminal_enabled = false; | 27 | bool terminal_enabled = false; |
29 | char buffer[80] = ""; | 28 | char buffer[80] = ""; |
30 | char cmd_buffer[CMD_BUFF_SIZE][80]; | 29 | char cmd_buffer[CMD_BUFF_SIZE][80]; |
31 | bool cmd_buffer_enabled = true; //replace with ifdef? | 30 | bool cmd_buffer_enabled = true; // replace with ifdef? |
32 | char newline[2] = "\n"; | 31 | char newline[2] = "\n"; |
33 | char arguments[6][20]; | 32 | char arguments[6][20]; |
34 | bool firstTime = true; | 33 | bool firstTime = true; |
35 | 34 | ||
36 | short int current_cmd_buffer_pos = 0; //used for up/down arrows - keeps track of where you are in the command buffer | 35 | short int current_cmd_buffer_pos = 0; // used for up/down arrows - keeps track of where you are in the command buffer |
37 | 36 | ||
38 | __attribute__ ((weak)) | 37 | __attribute__((weak)) const char terminal_prompt[8] = "> "; |
39 | const char terminal_prompt[8] = "> "; | ||
40 | 38 | ||
41 | #ifdef AUDIO_ENABLE | 39 | #ifdef AUDIO_ENABLE |
42 | #ifndef TERMINAL_SONG | 40 | # ifndef TERMINAL_SONG |
43 | #define TERMINAL_SONG SONG(TERMINAL_SOUND) | 41 | # define TERMINAL_SONG SONG(TERMINAL_SOUND) |
44 | #endif | 42 | # endif |
45 | float terminal_song[][2] = TERMINAL_SONG; | 43 | float terminal_song[][2] = TERMINAL_SONG; |
46 | #define TERMINAL_BELL() PLAY_SONG(terminal_song) | 44 | # define TERMINAL_BELL() PLAY_SONG(terminal_song) |
47 | #else | 45 | #else |
48 | #define TERMINAL_BELL() | 46 | # define TERMINAL_BELL() |
49 | #endif | 47 | #endif |
50 | 48 | ||
51 | __attribute__ ((weak)) | 49 | __attribute__((weak)) const char keycode_to_ascii_lut[58] = {0, 0, 0, 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0, 0, 0, '\t', ' ', '-', '=', '[', ']', '\\', 0, ';', '\'', '`', ',', '.', '/'}; |
52 | const char keycode_to_ascii_lut[58] = { | 50 | |
53 | 0, 0, 0, 0, | 51 | __attribute__((weak)) const char shifted_keycode_to_ascii_lut[58] = {0, 0, 0, 0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', 0, 0, 0, '\t', ' ', '_', '+', '{', '}', '|', 0, ':', '\'', '~', '<', '>', '?'}; |
54 | 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', | ||
55 | 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', | ||
56 | '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0, 0, 0, '\t', | ||
57 | ' ', '-', '=', '[', ']', '\\', 0, ';', '\'', '`', ',', '.', '/' | ||
58 | }; | ||
59 | |||
60 | __attribute__ ((weak)) | ||
61 | const char shifted_keycode_to_ascii_lut[58] = { | ||
62 | 0, 0, 0, 0, | ||
63 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', | ||
64 | 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', | ||
65 | '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', 0, 0, 0, '\t', | ||
66 | ' ', '_', '+', '{', '}', '|', 0, ':', '\'', '~', '<', '>', '?' | ||
67 | }; | ||
68 | 52 | ||
69 | struct stringcase { | 53 | struct stringcase { |
70 | char* string; | 54 | char *string; |
71 | void (*func)(void); | 55 | void (*func)(void); |
72 | } typedef stringcase; | 56 | } typedef stringcase; |
73 | 57 | ||
74 | void enable_terminal(void) { | 58 | void enable_terminal(void) { |
75 | terminal_enabled = true; | 59 | terminal_enabled = true; |
76 | strcpy(buffer, ""); | 60 | strcpy(buffer, ""); |
77 | memset(cmd_buffer,0,CMD_BUFF_SIZE * 80); | 61 | memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80); |
78 | for (int i = 0; i < 6; i++) | 62 | for (int i = 0; i < 6; i++) strcpy(arguments[i], ""); |
79 | strcpy(arguments[i], ""); | ||
80 | // select all text to start over | 63 | // select all text to start over |
81 | // SEND_STRING(SS_LCTRL("a")); | 64 | // SEND_STRING(SS_LCTRL("a")); |
82 | send_string(terminal_prompt); | 65 | send_string(terminal_prompt); |
@@ -88,41 +71,41 @@ void disable_terminal(void) { | |||
88 | } | 71 | } |
89 | 72 | ||
90 | void push_to_cmd_buffer(void) { | 73 | void push_to_cmd_buffer(void) { |
91 | if (cmd_buffer_enabled) { | 74 | if (cmd_buffer_enabled) { |
92 | if (cmd_buffer == NULL) { | 75 | if (cmd_buffer == NULL) { |
93 | return; | 76 | return; |
94 | } else { | 77 | } else { |
95 | if (firstTime) { | 78 | if (firstTime) { |
96 | firstTime = false; | 79 | firstTime = false; |
97 | strcpy(cmd_buffer[0],buffer); | 80 | strcpy(cmd_buffer[0], buffer); |
98 | return; | 81 | return; |
99 | } | 82 | } |
100 | 83 | ||
101 | for (int i= CMD_BUFF_SIZE - 1;i > 0 ;--i) { | 84 | for (int i = CMD_BUFF_SIZE - 1; i > 0; --i) { |
102 | strncpy(cmd_buffer[i],cmd_buffer[i-1],80); | 85 | strncpy(cmd_buffer[i], cmd_buffer[i - 1], 80); |
103 | } | 86 | } |
104 | 87 | ||
105 | strcpy(cmd_buffer[0],buffer); | 88 | strcpy(cmd_buffer[0], buffer); |
106 | 89 | ||
107 | return; | 90 | return; |
91 | } | ||
108 | } | 92 | } |
109 | } | ||
110 | } | 93 | } |
111 | 94 | ||
112 | void terminal_about(void) { | 95 | void terminal_about(void) { |
113 | SEND_STRING("QMK Firmware\n"); | 96 | SEND_STRING("QMK Firmware\n"); |
114 | SEND_STRING(" v"); | 97 | SEND_STRING(" v"); |
115 | SEND_STRING(QMK_VERSION); | 98 | SEND_STRING(QMK_VERSION); |
116 | SEND_STRING("\n"SS_TAP(X_HOME)" Built: "); | 99 | SEND_STRING("\n" SS_TAP(X_HOME) " Built: "); |
117 | SEND_STRING(QMK_BUILDDATE); | 100 | SEND_STRING(QMK_BUILDDATE); |
118 | send_string(newline); | 101 | send_string(newline); |
119 | #ifdef TERMINAL_HELP | 102 | #ifdef TERMINAL_HELP |
120 | if (strlen(arguments[1]) != 0) { | 103 | if (strlen(arguments[1]) != 0) { |
121 | SEND_STRING("You entered: "); | 104 | SEND_STRING("You entered: "); |
122 | send_string(arguments[1]); | 105 | send_string(arguments[1]); |
123 | send_string(newline); | 106 | send_string(newline); |
124 | } | 107 | } |
125 | #endif | 108 | #endif |
126 | } | 109 | } |
127 | 110 | ||
128 | void terminal_help(void); | 111 | void terminal_help(void); |
@@ -131,11 +114,11 @@ extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; | |||
131 | 114 | ||
132 | void terminal_keycode(void) { | 115 | void terminal_keycode(void) { |
133 | if (strlen(arguments[1]) != 0 && strlen(arguments[2]) != 0 && strlen(arguments[3]) != 0) { | 116 | if (strlen(arguments[1]) != 0 && strlen(arguments[2]) != 0 && strlen(arguments[3]) != 0) { |
134 | char keycode_dec[5]; | 117 | char keycode_dec[5]; |
135 | char keycode_hex[5]; | 118 | char keycode_hex[5]; |
136 | uint16_t layer = strtol(arguments[1], (char **)NULL, 10); | 119 | uint16_t layer = strtol(arguments[1], (char **)NULL, 10); |
137 | uint16_t row = strtol(arguments[2], (char **)NULL, 10); | 120 | uint16_t row = strtol(arguments[2], (char **)NULL, 10); |
138 | uint16_t col = strtol(arguments[3], (char **)NULL, 10); | 121 | uint16_t col = strtol(arguments[3], (char **)NULL, 10); |
139 | uint16_t keycode = pgm_read_word(&keymaps[layer][row][col]); | 122 | uint16_t keycode = pgm_read_word(&keymaps[layer][row][col]); |
140 | itoa(keycode, keycode_dec, 10); | 123 | itoa(keycode, keycode_dec, 10); |
141 | itoa(keycode, keycode_hex, 16); | 124 | itoa(keycode, keycode_hex, 16); |
@@ -145,9 +128,9 @@ void terminal_keycode(void) { | |||
145 | send_string(keycode_dec); | 128 | send_string(keycode_dec); |
146 | SEND_STRING(")\n"); | 129 | SEND_STRING(")\n"); |
147 | } else { | 130 | } else { |
148 | #ifdef TERMINAL_HELP | 131 | #ifdef TERMINAL_HELP |
149 | SEND_STRING("usage: keycode <layer> <row> <col>\n"); | 132 | SEND_STRING("usage: keycode <layer> <row> <col>\n"); |
150 | #endif | 133 | #endif |
151 | } | 134 | } |
152 | } | 135 | } |
153 | 136 | ||
@@ -157,53 +140,44 @@ void terminal_keymap(void) { | |||
157 | for (int r = 0; r < MATRIX_ROWS; r++) { | 140 | for (int r = 0; r < MATRIX_ROWS; r++) { |
158 | for (int c = 0; c < MATRIX_COLS; c++) { | 141 | for (int c = 0; c < MATRIX_COLS; c++) { |
159 | uint16_t keycode = pgm_read_word(&keymaps[layer][r][c]); | 142 | uint16_t keycode = pgm_read_word(&keymaps[layer][r][c]); |
160 | char keycode_s[8]; | 143 | char keycode_s[8]; |
161 | sprintf(keycode_s, "0x%04x,", keycode); | 144 | sprintf(keycode_s, "0x%04x,", keycode); |
162 | send_string(keycode_s); | 145 | send_string(keycode_s); |
163 | } | 146 | } |
164 | send_string(newline); | 147 | send_string(newline); |
165 | } | 148 | } |
166 | } else { | 149 | } else { |
167 | #ifdef TERMINAL_HELP | 150 | #ifdef TERMINAL_HELP |
168 | SEND_STRING("usage: keymap <layer>\n"); | 151 | SEND_STRING("usage: keymap <layer>\n"); |
169 | #endif | 152 | #endif |
170 | } | 153 | } |
171 | } | 154 | } |
172 | 155 | ||
173 | void print_cmd_buff(void) { | 156 | void print_cmd_buff(void) { |
174 | /* without the below wait, a race condition can occur wherein the | 157 | /* without the below wait, a race condition can occur wherein the |
175 | buffer can be printed before it has been fully moved */ | 158 | buffer can be printed before it has been fully moved */ |
176 | wait_ms(250); | 159 | wait_ms(250); |
177 | for(int i=0;i<CMD_BUFF_SIZE;i++){ | 160 | for (int i = 0; i < CMD_BUFF_SIZE; i++) { |
178 | char tmpChar = ' '; | 161 | char tmpChar = ' '; |
179 | itoa(i ,&tmpChar,10); | 162 | itoa(i, &tmpChar, 10); |
180 | const char * tmpCnstCharStr = &tmpChar; //because sned_string wont take a normal char * | 163 | const char *tmpCnstCharStr = &tmpChar; // because sned_string wont take a normal char * |
181 | send_string(tmpCnstCharStr); | 164 | send_string(tmpCnstCharStr); |
182 | SEND_STRING(". "); | 165 | SEND_STRING(". "); |
183 | send_string(cmd_buffer[i]); | 166 | send_string(cmd_buffer[i]); |
184 | SEND_STRING("\n"); | 167 | SEND_STRING("\n"); |
185 | } | 168 | } |
186 | } | 169 | } |
187 | 170 | ||
188 | |||
189 | void flush_cmd_buffer(void) { | 171 | void flush_cmd_buffer(void) { |
190 | memset(cmd_buffer,0,CMD_BUFF_SIZE * 80); | 172 | memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80); |
191 | SEND_STRING("Buffer Cleared!\n"); | 173 | SEND_STRING("Buffer Cleared!\n"); |
192 | } | 174 | } |
193 | 175 | ||
194 | stringcase terminal_cases[] = { | 176 | stringcase terminal_cases[] = {{"about", terminal_about}, {"help", terminal_help}, {"keycode", terminal_keycode}, {"keymap", terminal_keymap}, {"flush-buffer", flush_cmd_buffer}, {"print-buffer", print_cmd_buff}, {"exit", disable_terminal}}; |
195 | { "about", terminal_about }, | ||
196 | { "help", terminal_help }, | ||
197 | { "keycode", terminal_keycode }, | ||
198 | { "keymap", terminal_keymap }, | ||
199 | { "flush-buffer" , flush_cmd_buffer}, | ||
200 | { "print-buffer" , print_cmd_buff}, | ||
201 | { "exit", disable_terminal } | ||
202 | }; | ||
203 | 177 | ||
204 | void terminal_help(void) { | 178 | void terminal_help(void) { |
205 | SEND_STRING("commands available:\n "); | 179 | SEND_STRING("commands available:\n "); |
206 | for( stringcase* case_p = terminal_cases; case_p != terminal_cases + sizeof( terminal_cases ) / sizeof( terminal_cases[0] ); case_p++ ) { | 180 | for (stringcase *case_p = terminal_cases; case_p != terminal_cases + sizeof(terminal_cases) / sizeof(terminal_cases[0]); case_p++) { |
207 | send_string(case_p->string); | 181 | send_string(case_p->string); |
208 | SEND_STRING(" "); | 182 | SEND_STRING(" "); |
209 | } | 183 | } |
@@ -211,7 +185,7 @@ void terminal_help(void) { | |||
211 | } | 185 | } |
212 | 186 | ||
213 | void command_not_found(void) { | 187 | void command_not_found(void) { |
214 | wait_ms(50); //sometimes buffer isnt grabbed quick enough | 188 | wait_ms(50); // sometimes buffer isnt grabbed quick enough |
215 | SEND_STRING("command \""); | 189 | SEND_STRING("command \""); |
216 | send_string(buffer); | 190 | send_string(buffer); |
217 | SEND_STRING("\" not found\n"); | 191 | SEND_STRING("\" not found\n"); |
@@ -221,9 +195,9 @@ void process_terminal_command(void) { | |||
221 | // we capture return bc of the order of events, so we need to manually send a newline | 195 | // we capture return bc of the order of events, so we need to manually send a newline |
222 | send_string(newline); | 196 | send_string(newline); |
223 | 197 | ||
224 | char * pch; | 198 | char * pch; |
225 | uint8_t i = 0; | 199 | uint8_t i = 0; |
226 | pch = strtok(buffer, " "); | 200 | pch = strtok(buffer, " "); |
227 | while (pch != NULL) { | 201 | while (pch != NULL) { |
228 | strcpy(arguments[i], pch); | 202 | strcpy(arguments[i], pch); |
229 | pch = strtok(NULL, " "); | 203 | pch = strtok(NULL, " "); |
@@ -231,38 +205,32 @@ void process_terminal_command(void) { | |||
231 | } | 205 | } |
232 | 206 | ||
233 | bool command_found = false; | 207 | bool command_found = false; |
234 | for( stringcase* case_p = terminal_cases; case_p != terminal_cases + sizeof( terminal_cases ) / sizeof( terminal_cases[0] ); case_p++ ) { | 208 | for (stringcase *case_p = terminal_cases; case_p != terminal_cases + sizeof(terminal_cases) / sizeof(terminal_cases[0]); case_p++) { |
235 | if( 0 == strcmp( case_p->string, buffer ) ) { | 209 | if (0 == strcmp(case_p->string, buffer)) { |
236 | command_found = true; | 210 | command_found = true; |
237 | (*case_p->func)(); | 211 | (*case_p->func)(); |
238 | break; | 212 | break; |
239 | } | 213 | } |
240 | } | 214 | } |
241 | 215 | ||
242 | if (!command_found) | 216 | if (!command_found) command_not_found(); |
243 | command_not_found(); | ||
244 | 217 | ||
245 | if (terminal_enabled) { | 218 | if (terminal_enabled) { |
246 | strcpy(buffer, ""); | 219 | strcpy(buffer, ""); |
247 | for (int i = 0; i < 6; i++) | 220 | for (int i = 0; i < 6; i++) strcpy(arguments[i], ""); |
248 | strcpy(arguments[i], ""); | ||
249 | SEND_STRING(SS_TAP(X_HOME)); | 221 | SEND_STRING(SS_TAP(X_HOME)); |
250 | send_string(terminal_prompt); | 222 | send_string(terminal_prompt); |
251 | } | 223 | } |
252 | } | 224 | } |
253 | void check_pos(void) { | 225 | void check_pos(void) { |
254 | if (current_cmd_buffer_pos >= CMD_BUFF_SIZE) { //if over the top, move it back down to the top of the buffer so you can climb back down... | 226 | if (current_cmd_buffer_pos >= CMD_BUFF_SIZE) { // if over the top, move it back down to the top of the buffer so you can climb back down... |
255 | current_cmd_buffer_pos = CMD_BUFF_SIZE - 1; | 227 | current_cmd_buffer_pos = CMD_BUFF_SIZE - 1; |
256 | } else if (current_cmd_buffer_pos < 0) { //...and if you fall under the bottom of the buffer, reset back to 0 so you can climb back up | 228 | } else if (current_cmd_buffer_pos < 0) { //...and if you fall under the bottom of the buffer, reset back to 0 so you can climb back up |
257 | current_cmd_buffer_pos = 0; | 229 | current_cmd_buffer_pos = 0; |
258 | } | 230 | } |
259 | } | 231 | } |
260 | 232 | ||
261 | |||
262 | |||
263 | |||
264 | bool process_terminal(uint16_t keycode, keyrecord_t *record) { | 233 | bool process_terminal(uint16_t keycode, keyrecord_t *record) { |
265 | |||
266 | if (keycode == TERM_ON && record->event.pressed) { | 234 | if (keycode == TERM_ON && record->event.pressed) { |
267 | enable_terminal(); | 235 | enable_terminal(); |
268 | return false; | 236 | return false; |
@@ -280,59 +248,66 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) { | |||
280 | 248 | ||
281 | if (keycode < 256) { | 249 | if (keycode < 256) { |
282 | uint8_t str_len; | 250 | uint8_t str_len; |
283 | char char_to_add; | 251 | char char_to_add; |
284 | switch (keycode) { | 252 | switch (keycode) { |
285 | case KC_ENTER: | 253 | case KC_ENTER: |
286 | case KC_KP_ENTER: | 254 | case KC_KP_ENTER: |
287 | push_to_cmd_buffer(); | 255 | push_to_cmd_buffer(); |
288 | current_cmd_buffer_pos = 0; | 256 | current_cmd_buffer_pos = 0; |
289 | process_terminal_command(); | 257 | process_terminal_command(); |
290 | return false; break; | 258 | return false; |
259 | break; | ||
291 | case KC_ESC: | 260 | case KC_ESC: |
292 | SEND_STRING("\n"); | 261 | SEND_STRING("\n"); |
293 | enable_terminal(); | 262 | enable_terminal(); |
294 | return false; break; | 263 | return false; |
264 | break; | ||
295 | case KC_BSPC: | 265 | case KC_BSPC: |
296 | str_len = strlen(buffer); | 266 | str_len = strlen(buffer); |
297 | if (str_len > 0) { | 267 | if (str_len > 0) { |
298 | buffer[str_len-1] = 0; | 268 | buffer[str_len - 1] = 0; |
299 | return true; | 269 | return true; |
300 | } else { | 270 | } else { |
301 | TERMINAL_BELL(); | 271 | TERMINAL_BELL(); |
302 | return false; | 272 | return false; |
303 | } break; | 273 | } |
274 | break; | ||
304 | case KC_LEFT: | 275 | case KC_LEFT: |
305 | return false; break; | 276 | return false; |
277 | break; | ||
306 | case KC_RIGHT: | 278 | case KC_RIGHT: |
307 | return false; break; | 279 | return false; |
308 | case KC_UP: // 0 = recent | 280 | break; |
309 | check_pos(); //check our current buffer position is valid | 281 | case KC_UP: // 0 = recent |
310 | if (current_cmd_buffer_pos <= CMD_BUFF_SIZE - 1) { //once we get to the top, dont do anything | 282 | check_pos(); // check our current buffer position is valid |
311 | str_len = strlen(buffer); | 283 | if (current_cmd_buffer_pos <= CMD_BUFF_SIZE - 1) { // once we get to the top, dont do anything |
312 | for(int i= 0;i < str_len ;++i) { | 284 | str_len = strlen(buffer); |
313 | send_string(SS_TAP(X_BSPACE)); //clear w/e is on the line already | 285 | for (int i = 0; i < str_len; ++i) { |
314 | //process_terminal(KC_BSPC,record); | 286 | send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already |
315 | } | 287 | // process_terminal(KC_BSPC,record); |
316 | strncpy(buffer,cmd_buffer[current_cmd_buffer_pos],80); | 288 | } |
289 | strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 80); | ||
317 | 290 | ||
318 | send_string(buffer); | 291 | send_string(buffer); |
319 | ++current_cmd_buffer_pos; //get ready to access the above cmd if up/down is pressed again | 292 | ++current_cmd_buffer_pos; // get ready to access the above cmd if up/down is pressed again |
320 | } | 293 | } |
321 | return false; break; | 294 | return false; |
295 | break; | ||
322 | case KC_DOWN: | 296 | case KC_DOWN: |
323 | check_pos(); | 297 | check_pos(); |
324 | if (current_cmd_buffer_pos >= 0) { //once we get to the bottom, dont do anything | 298 | if (current_cmd_buffer_pos >= 0) { // once we get to the bottom, dont do anything |
325 | str_len = strlen(buffer); | 299 | str_len = strlen(buffer); |
326 | for(int i= 0;i < str_len ;++i) { | 300 | for (int i = 0; i < str_len; ++i) { |
327 | send_string(SS_TAP(X_BSPACE)); //clear w/e is on the line already | 301 | send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already |
328 | //process_terminal(KC_BSPC,record); | 302 | // process_terminal(KC_BSPC,record); |
329 | } | 303 | } |
330 | strncpy(buffer,cmd_buffer[current_cmd_buffer_pos],79); | 304 | strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 79); |
331 | 305 | ||
332 | send_string(buffer); | 306 | send_string(buffer); |
333 | --current_cmd_buffer_pos; //get ready to access the above cmd if down/up is pressed again | 307 | --current_cmd_buffer_pos; // get ready to access the above cmd if down/up is pressed again |
334 | } | 308 | } |
335 | return false; break; | 309 | return false; |
310 | break; | ||
336 | default: | 311 | default: |
337 | if (keycode <= 58) { | 312 | if (keycode <= 58) { |
338 | char_to_add = 0; | 313 | char_to_add = 0; |
@@ -344,11 +319,9 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) { | |||
344 | if (char_to_add != 0) { | 319 | if (char_to_add != 0) { |
345 | strncat(buffer, &char_to_add, 1); | 320 | strncat(buffer, &char_to_add, 1); |
346 | } | 321 | } |
347 | } break; | 322 | } |
323 | break; | ||
348 | } | 324 | } |
349 | |||
350 | |||
351 | |||
352 | } | 325 | } |
353 | } | 326 | } |
354 | return true; | 327 | return true; |