Update menu.c

This commit is contained in:
peko 2022-06-19 16:27:05 +05:30 committed by GitHub
parent 3ef8a29933
commit 2f07cb36ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -412,6 +412,7 @@ refresh:
term_double_buffer_flush();
int c = getchar();
size_t buffer_len = strlen(buffer);
switch (c) {
case GETCHAR_CURSOR_DOWN:
cursor_offset = get_next_line(cursor_offset, buffer);
@ -425,7 +426,7 @@ refresh:
}
break;
case GETCHAR_CURSOR_RIGHT:
if (cursor_offset < strlen(buffer)) {
if (cursor_offset < buffer_len) {
cursor_offset++;
}
break;
@ -458,9 +459,9 @@ refresh:
editor_no_term_reset ? editor_no_term_reset = false : reset_term();
return NULL;
default:
if (strlen(buffer) < EDITOR_MAX_BUFFER_SIZE - 1) {
if (buffer_len < EDITOR_MAX_BUFFER_SIZE - 1) {
if (isprint(c) || c == '\n') {
for (size_t i = strlen(buffer); ; i--) {
for (size_t i = buffer_len; ; i--) {
buffer[i+1] = buffer[i];
if (i == cursor_offset)
break;