| 126 |
{ |
{ |
| 127 |
if (offset > 0) |
if (offset > 0) |
| 128 |
{ |
{ |
| 129 |
buffer[--offset] = '\0'; |
offset--; |
| 130 |
prints("\b \b"); |
if (buffer[offset] < 0 || buffer[offset] > 127) |
| 131 |
// clrtoeol (); |
{ |
| 132 |
|
prints("\033[D \033[D"); |
| 133 |
|
offset--; |
| 134 |
|
if (offset < 0) // should not happen |
| 135 |
|
{ |
| 136 |
|
log_error("Offset of buffer is negative\n"); |
| 137 |
|
offset = 0; |
| 138 |
|
} |
| 139 |
|
} |
| 140 |
|
buffer[offset] = '\0'; |
| 141 |
|
prints("\033[D \033[D"); |
| 142 |
iflush(); |
iflush(); |
| 143 |
} |
} |
| 144 |
continue; |
continue; |
| 149 |
} |
} |
| 150 |
if (c > 127 && c <= 255) |
if (c > 127 && c <= 255) |
| 151 |
{ |
{ |
| 152 |
|
if (!hz && offset + 2 > buffer_length) // No enough space for Chinese character |
| 153 |
|
{ |
| 154 |
|
igetch(1); // Cleanup remaining input |
| 155 |
|
outc('\a'); |
| 156 |
|
iflush(); |
| 157 |
|
continue; |
| 158 |
|
} |
| 159 |
hz = (!hz); |
hz = (!hz); |
| 160 |
} |
} |
| 161 |
if (offset >= buffer_length) |
if (offset >= buffer_length) |
| 162 |
{ |
{ |
| 163 |
outc('\a'); |
outc('\a'); |
| 164 |
|
iflush(); |
| 165 |
continue; |
continue; |
| 166 |
} |
} |
| 167 |
buffer[offset++] = (char)c; |
buffer[offset++] = (char)c; |
| 181 |
} |
} |
| 182 |
} |
} |
| 183 |
|
|
|
prints("\r\n"); |
|
|
iflush(); |
|
|
|
|
| 184 |
return offset; |
return offset; |
| 185 |
} |
} |
| 186 |
|
|
| 187 |
int str_input(char *buffer, int buffer_length, int echo_mode) |
int str_input(char *buffer, int buffer_length, int echo_mode) |
| 188 |
{ |
{ |
| 189 |
int offset; |
int len; |
| 190 |
|
|
| 191 |
memset(buffer, '\0', buffer_length); |
buffer[0] = '\0'; |
| 192 |
|
|
| 193 |
offset = _str_input(buffer, buffer_length, echo_mode); |
len = _str_input(buffer, buffer_length, echo_mode); |
| 194 |
|
|
| 195 |
return offset; |
prints("\r\n"); |
| 196 |
|
iflush(); |
| 197 |
|
|
| 198 |
|
return len; |
| 199 |
}; |
}; |
| 200 |
|
|
| 201 |
int get_data(int row, int col, char *prompt, char *buffer, int buffer_length, int echo_mode) |
int get_data(int row, int col, char *prompt, char *buffer, int buffer_length, int echo_mode) |