Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d9c5a6696e | |||
| 5c2571eba7 | |||
| 9afd030b87 | |||
| 2f198e611e | |||
| e079726ced |
@@ -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.5.4")
|
set(KE_VERSION "1.5.6")
|
||||||
|
|
||||||
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")
|
||||||
|
|||||||
68
main.c
68
main.c
@@ -97,6 +97,30 @@ typedef struct erow {
|
|||||||
} erow;
|
} erow;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum undo_kind {
|
||||||
|
UNDO_INSERT = 1 << 0,
|
||||||
|
UNDO_UNKNOWN = 1 << 1,
|
||||||
|
} undo_kind;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct undo_node {
|
||||||
|
undo_kind op;
|
||||||
|
size_t row, col;
|
||||||
|
abuf text;
|
||||||
|
|
||||||
|
struct undo_node *next;
|
||||||
|
struct undo_node *parent;
|
||||||
|
|
||||||
|
} undo_node;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct undo_tree {
|
||||||
|
undo_node *root; /* the start of the undo sequence */
|
||||||
|
undo_node *current; /* where we are currently at */
|
||||||
|
undo_node *pending; /* the current undo operations being built */
|
||||||
|
} undo_tree;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* editor is the global editor state; it should be broken out
|
* editor is the global editor state; it should be broken out
|
||||||
* to buffers and screen state, probably.
|
* to buffers and screen state, probably.
|
||||||
@@ -2369,7 +2393,9 @@ process_kcommand(int16_t c)
|
|||||||
void
|
void
|
||||||
process_normal(int16_t c)
|
process_normal(int16_t c)
|
||||||
{
|
{
|
||||||
int reps = 0;
|
int cols = 0;
|
||||||
|
int rows = 0;
|
||||||
|
int reps = 0;
|
||||||
|
|
||||||
/* C-u handling – must be the very first thing */
|
/* C-u handling – must be the very first thing */
|
||||||
if (c == CTRL_KEY('u')) {
|
if (c == CTRL_KEY('u')) {
|
||||||
@@ -2425,6 +2451,12 @@ process_normal(int16_t c)
|
|||||||
case CTRL_KEY('g'):
|
case CTRL_KEY('g'):
|
||||||
break;
|
break;
|
||||||
case CTRL_KEY('l'):
|
case CTRL_KEY('l'):
|
||||||
|
if (get_winsz(&rows, &cols) == 0) {
|
||||||
|
editor.rows = rows;
|
||||||
|
editor.cols = cols;
|
||||||
|
} else {
|
||||||
|
editor_set_status("Couldn't update window size.");
|
||||||
|
}
|
||||||
display_refresh();
|
display_refresh();
|
||||||
break;
|
break;
|
||||||
case CTRL_KEY('s'):
|
case CTRL_KEY('s'):
|
||||||
@@ -2518,7 +2550,7 @@ process_escape(int16_t c)
|
|||||||
case BACKSPACE:
|
case BACKSPACE:
|
||||||
reps = uarg_get();
|
reps = uarg_get();
|
||||||
|
|
||||||
while (--reps) {
|
while (reps--) {
|
||||||
delete_prev_word();
|
delete_prev_word();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3053,10 +3085,12 @@ install_signal_handlers(void)
|
|||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *arg;
|
char *fname = NULL;
|
||||||
|
char *lnarg = NULL;
|
||||||
int lineno = 0;
|
int lineno = 0;
|
||||||
int opt;
|
int opt;
|
||||||
int debug = 0;
|
int debug = 0;
|
||||||
|
int jump = 0;
|
||||||
|
|
||||||
install_signal_handlers();
|
install_signal_handlers();
|
||||||
|
|
||||||
@@ -3083,22 +3117,30 @@ main(int argc, char *argv[])
|
|||||||
init_editor();
|
init_editor();
|
||||||
|
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
open_file(argv[0]);
|
fname = argv[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
arg = argv[1];
|
lnarg = argv[0];
|
||||||
if (arg[0] == '+') {
|
fname = argv[1];
|
||||||
arg++;
|
if (lnarg[0] == '+') {
|
||||||
|
lnarg++;
|
||||||
}
|
}
|
||||||
lineno = atoi(arg);
|
lineno = atoi(lnarg);
|
||||||
|
jump = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fname != NULL) {
|
||||||
|
open_file(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_set_status("C-k q to exit / C-k d to dump core");
|
editor_set_status("C-k q to exit / C-k d to dump core");
|
||||||
if (lineno < 1) {
|
if (jump) {
|
||||||
editor_set_status("Invalid line number %s", arg);
|
if (lineno < 1) {
|
||||||
} else {
|
editor_set_status("Invalid line number %s", lnarg);
|
||||||
jump_to_position(0, lineno - 1);
|
} else {
|
||||||
|
jump_to_position(0, lineno - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
display_clear(NULL);
|
display_clear(NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user