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
|
||||
|
||||
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 "${CMAKE_C_FLAGS} -D_DEFAULT_SOURCE -D_XOPEN_SOURCE")
|
||||
|
||||
58
main.c
58
main.c
@@ -97,6 +97,30 @@ typedef struct 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
|
||||
* to buffers and screen state, probably.
|
||||
@@ -2369,6 +2393,8 @@ process_kcommand(int16_t c)
|
||||
void
|
||||
process_normal(int16_t c)
|
||||
{
|
||||
int cols = 0;
|
||||
int rows = 0;
|
||||
int reps = 0;
|
||||
|
||||
/* C-u handling – must be the very first thing */
|
||||
@@ -2425,6 +2451,12 @@ process_normal(int16_t c)
|
||||
case CTRL_KEY('g'):
|
||||
break;
|
||||
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();
|
||||
break;
|
||||
case CTRL_KEY('s'):
|
||||
@@ -2518,7 +2550,7 @@ process_escape(int16_t c)
|
||||
case BACKSPACE:
|
||||
reps = uarg_get();
|
||||
|
||||
while (--reps) {
|
||||
while (reps--) {
|
||||
delete_prev_word();
|
||||
}
|
||||
break;
|
||||
@@ -3053,10 +3085,12 @@ install_signal_handlers(void)
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *arg;
|
||||
char *fname = NULL;
|
||||
char *lnarg = NULL;
|
||||
int lineno = 0;
|
||||
int opt;
|
||||
int debug = 0;
|
||||
int jump = 0;
|
||||
|
||||
install_signal_handlers();
|
||||
|
||||
@@ -3083,23 +3117,31 @@ main(int argc, char *argv[])
|
||||
init_editor();
|
||||
|
||||
if (argc > 0) {
|
||||
open_file(argv[0]);
|
||||
fname = argv[0];
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
arg = argv[1];
|
||||
if (arg[0] == '+') {
|
||||
arg++;
|
||||
lnarg = argv[0];
|
||||
fname = argv[1];
|
||||
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");
|
||||
if (jump) {
|
||||
if (lineno < 1) {
|
||||
editor_set_status("Invalid line number %s", arg);
|
||||
editor_set_status("Invalid line number %s", lnarg);
|
||||
} else {
|
||||
jump_to_position(0, lineno - 1);
|
||||
}
|
||||
}
|
||||
|
||||
display_clear(NULL);
|
||||
loop();
|
||||
|
||||
Reference in New Issue
Block a user