if(key >= ' ' && key <= '~') { // Insert character
int c = cursor_position;
char t = pattern[c], u;
- if(t) {
- while(t) {
- c++;
- u = pattern[c];
- pattern[c] = t;
- t = u;
- }
- pattern[cursor_position++] = key;
- } else {
- pattern[cursor_position++] = key;
- pattern[cursor_position] = '\0';
+ while(t) {
+ c++;
+ u = pattern[c];
+ pattern[c] = t;
+ t = u;
}
+ c++;
+ pattern[c] = '\0';
+ pattern[cursor_position++] = key;
}
else if(key == KEY_BACKSPACE || key == '\b' || key == '\7f') {