Rev 3980 | Rev 4255 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3980 | Rev 4239 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | #include <stdio.h> |
32 | #include <stdio.h> |
33 | #include <stdlib.h> |
33 | #include <stdlib.h> |
34 | #include <string.h> |
34 | #include <string.h> |
35 | #include <io/stream.h> |
35 | #include <io/stream.h> |
36 | #include <console.h> |
36 | #include <console.h> |
- | 37 | #include <kbd/kbd.h> |
|
- | 38 | #include <kbd/keycode.h> |
|
37 | 39 | ||
38 | #include "config.h" |
40 | #include "config.h" |
39 | #include "util.h" |
41 | #include "util.h" |
40 | #include "scli.h" |
42 | #include "scli.h" |
41 | #include "input.h" |
43 | #include "input.h" |
Line 94... | Line 96... | ||
94 | return rc; |
96 | return rc; |
95 | } |
97 | } |
96 | 98 | ||
97 | static void read_line(char *buffer, int n) |
99 | static void read_line(char *buffer, int n) |
98 | { |
100 | { |
99 | char c; |
101 | kbd_event_t ev; |
100 | int chars; |
102 | int chars; |
101 | 103 | ||
102 | chars = 0; |
104 | chars = 0; |
103 | while (chars < n - 1) { |
105 | while (chars < n - 1) { |
104 | c = getchar(); |
106 | fflush(stdout); |
105 | if (c < 0) |
107 | if (kbd_get_event(&ev) < 0) |
106 | return; |
108 | return; |
107 | if (c == '\n') |
109 | if (ev.type == KE_RELEASE) |
- | 110 | continue; |
|
- | 111 | ||
- | 112 | if (ev.key == KC_ENTER || ev.key == KC_NENTER) |
|
108 | break; |
113 | break; |
109 | if (c == '\b') { |
114 | if (ev.key == KC_BACKSPACE) { |
110 | if (chars > 0) { |
115 | if (chars > 0) { |
111 | putchar('\b'); |
116 | putchar('\b'); |
112 | --chars; |
117 | --chars; |
113 | } |
118 | } |
114 | continue; |
119 | continue; |
115 | } |
120 | } |
116 | if (c >= ' ') { |
121 | if (ev.c >= ' ') { |
117 | putchar(c); |
122 | //putchar(ev.c); |
- | 123 | console_putchar(ev.c); |
|
118 | buffer[chars++] = c; |
124 | buffer[chars++] = ev.c; |
119 | } |
125 | } |
120 | } |
126 | } |
121 | putchar('\n'); |
127 | putchar('\n'); |
122 | buffer[chars] = '\0'; |
128 | buffer[chars] = '\0'; |
123 | } |
129 | } |