| 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); // Clear 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; |