Code cleanups and editor fixups.
Some checks failed
Release / Bump Homebrew formula (push) Has been cancelled
Some checks failed
Release / Bump Homebrew formula (push) Has been cancelled
This commit is contained in:
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15)
|
|||||||
project(ke C) # Specify C language explicitly
|
project(ke C) # Specify C language explicitly
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
set(KE_VERSION "1.0.11")
|
set(KE_VERSION "1.0.12")
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wshadow -Werror -std=c99 -g")
|
set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wshadow -Werror -std=c99 -g")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_DEFAULT_SOURCE -D_XOPEN_SOURCE")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_DEFAULT_SOURCE -D_XOPEN_SOURCE")
|
||||||
|
|||||||
32
main.c
32
main.c
@@ -120,7 +120,6 @@ void editor_set_status(const char *fmt, ...);
|
|||||||
|
|
||||||
/* miscellaneous */
|
/* miscellaneous */
|
||||||
void die(const char *s);
|
void die(const char *s);
|
||||||
int iswspace(const char c);
|
|
||||||
int get_winsz(int *rows, int *cols);
|
int get_winsz(int *rows, int *cols);
|
||||||
void goto_line(void);
|
void goto_line(void);
|
||||||
int cursor_at_eol(void);
|
int cursor_at_eol(void);
|
||||||
@@ -469,11 +468,6 @@ die(const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
iswspace(const char c)
|
|
||||||
{
|
|
||||||
return isspace(c) || c == '\t';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_winsz uses the TIOCGWINSZ to get the window size.
|
* get_winsz uses the TIOCGWINSZ to get the window size.
|
||||||
@@ -540,15 +534,15 @@ find_next_word(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isalnum(editor.row[editor.cury].line[editor.curx])) {
|
if (isalnum(editor.row[editor.cury].line[editor.curx])) {
|
||||||
while (!iswspace(editor.row[editor.cury].line[editor.curx]) && !cursor_at_eol()) {
|
while (!isspace(editor.row[editor.cury].line[editor.curx]) && !cursor_at_eol()) {
|
||||||
move_cursor(ARROW_RIGHT);
|
move_cursor(ARROW_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iswspace(editor.row[editor.cury].line[editor.curx])) {
|
if (isspace(editor.row[editor.cury].line[editor.curx])) {
|
||||||
while (iswspace(editor.row[editor.cury].line[editor.curx])) {
|
while (isspace(editor.row[editor.cury].line[editor.curx])) {
|
||||||
move_cursor(ARROW_RIGHT);
|
move_cursor(ARROW_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,7 +560,7 @@ delete_next_word(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isalnum(editor.row[editor.cury].line[editor.curx])) {
|
if (isalnum(editor.row[editor.cury].line[editor.curx])) {
|
||||||
while (!iswspace(editor.row[editor.cury].line[editor.curx]) && !cursor_at_eol()) {
|
while (!isspace(editor.row[editor.cury].line[editor.curx]) && !cursor_at_eol()) {
|
||||||
move_cursor(ARROW_RIGHT);
|
move_cursor(ARROW_RIGHT);
|
||||||
deletech();
|
deletech();
|
||||||
}
|
}
|
||||||
@@ -574,8 +568,8 @@ delete_next_word(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iswspace(editor.row[editor.cury].line[editor.curx])) {
|
if (isspace(editor.row[editor.cury].line[editor.curx])) {
|
||||||
while (iswspace(editor.row[editor.cury].line[editor.curx])) {
|
while (isspace(editor.row[editor.cury].line[editor.curx])) {
|
||||||
move_cursor(ARROW_RIGHT);
|
move_cursor(ARROW_RIGHT);
|
||||||
deletech();
|
deletech();
|
||||||
}
|
}
|
||||||
@@ -594,7 +588,7 @@ find_prev_word(void)
|
|||||||
|
|
||||||
move_cursor(ARROW_LEFT);
|
move_cursor(ARROW_LEFT);
|
||||||
|
|
||||||
while (cursor_at_eol() || iswspace(editor.row[editor.cury].line[editor.curx])) {
|
while (cursor_at_eol() || isspace(editor.row[editor.cury].line[editor.curx])) {
|
||||||
if (editor.cury == 0 && editor.curx == 0) {
|
if (editor.cury == 0 && editor.curx == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -602,7 +596,7 @@ find_prev_word(void)
|
|||||||
move_cursor(ARROW_LEFT);
|
move_cursor(ARROW_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (editor.curx > 0 && !iswspace(editor.row[editor.cury].line[editor.curx - 1])) {
|
while (editor.curx > 0 && !isspace(editor.row[editor.cury].line[editor.curx - 1])) {
|
||||||
move_cursor(ARROW_LEFT);
|
move_cursor(ARROW_LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -620,7 +614,7 @@ delete_prev_word(void)
|
|||||||
if (editor.curx == 0) {
|
if (editor.curx == 0) {
|
||||||
deletech();
|
deletech();
|
||||||
} else {
|
} else {
|
||||||
if (!iswspace(editor.row[editor.cury].line[editor.curx - 1])) {
|
if (!isspace(editor.row[editor.cury].line[editor.curx - 1])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
deletech();
|
deletech();
|
||||||
@@ -628,7 +622,7 @@ delete_prev_word(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (editor.curx > 0) {
|
while (editor.curx > 0) {
|
||||||
if (iswspace(editor.row[editor.cury].line[editor.curx - 1])) {
|
if (isspace(editor.row[editor.cury].line[editor.curx - 1])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
deletech();
|
deletech();
|
||||||
@@ -1239,9 +1233,15 @@ process_kcommand(int16_t c)
|
|||||||
delete_row(editor.cury);
|
delete_row(editor.cury);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
|
if (editor.curx == 0 && cursor_at_eol()) {
|
||||||
|
delete_row(editor.cury);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while ((editor.row[editor.cury].size - editor.curx) > 0) {
|
while ((editor.row[editor.cury].size - editor.curx) > 0) {
|
||||||
process_normal(DEL_KEY);
|
process_normal(DEL_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
case CTRL_KEY('g'):
|
case CTRL_KEY('g'):
|
||||||
|
|||||||
Reference in New Issue
Block a user