Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bd68b809cd | |||
| f200a7bfcd | |||
| 58daeac6ad | |||
| 3ef6bab265 | |||
| 3800751bcf | |||
| 87272a669b | |||
| b77748f7c0 | |||
| c70b502006 | |||
| e14d620887 | |||
| db38266849 | |||
| 6d1b7f8e56 | |||
| 64647f77b0 | |||
| 2c3b2ae0f0 | |||
| a605e47458 | |||
| 40ee1e8d7b | |||
| 4464159301 | |||
| dc9fb58a41 | |||
| bbd682cec7 | |||
| ace25c5c65 | |||
| 09881706f2 | |||
| 2579bb01c8 | |||
| a528b3fc3e | |||
| faa70af9b7 | |||
| e1abaae6aa | |||
| 329b92f382 | |||
| 12553f301b | |||
| 75b19042b9 | |||
| 1a184b1a08 |
@@ -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.3.6")
|
set(KE_VERSION "1.5.2")
|
||||||
|
|
||||||
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")
|
||||||
|
|||||||
5
Makefile
5
Makefile
@@ -26,3 +26,8 @@ clean:
|
|||||||
.PHONY: test.txt
|
.PHONY: test.txt
|
||||||
test.txt:
|
test.txt:
|
||||||
cp test.txt.bak $@
|
cp test.txt.bak $@
|
||||||
|
|
||||||
|
.PHONY: gdb
|
||||||
|
gdb:
|
||||||
|
@test -f $(TARGET).pid || (echo "error: $(TARGET).pid not found" >&2; exit 1)
|
||||||
|
@gdb -p $$(cat $(TARGET).pid | tr -d ' \t\n\r') ./$(TARGET)
|
||||||
|
|||||||
@@ -19,3 +19,6 @@ Released under an ISC license.
|
|||||||
|
|
||||||
Started by following along with kilo:
|
Started by following along with kilo:
|
||||||
https://viewsourcecode.org/snaptoken/kilo/
|
https://viewsourcecode.org/snaptoken/kilo/
|
||||||
|
|
||||||
|
E.g., in the devlogs
|
||||||
|
https://log.wntrmute.dev/2020/02/20200207
|
||||||
|
|||||||
17
TODO
17
TODO
@@ -1,15 +1,18 @@
|
|||||||
[X] goto-line
|
[X] goto-line
|
||||||
[X] text-corruption bug
|
[X] text-corruption bug
|
||||||
[ ] alt-modifiers
|
[ ] alt-modifiers
|
||||||
[ ] refresh-screen
|
[x] refresh-screen
|
||||||
[ ] functions -> keymapping?
|
[ ] functions -> keymapping? (what did this even mean)
|
||||||
[X] rendering: need to skip over control characters like we do with tabs
|
[X] rendering: need to skip over control characters like we do with tabs
|
||||||
[X] control-d -> delete
|
[X] control-d -> delete
|
||||||
[ ] control-g -> exit buf prompt
|
[x] control-g -> exit buf prompt
|
||||||
[ ] load-file prompt on dirty buffer
|
[x] load-file prompt on dirty buffer
|
||||||
[ ] multiple files
|
[ ] multiple files
|
||||||
|
[x] utf-8
|
||||||
|
[x] kill ring
|
||||||
|
[x] mark/region
|
||||||
|
|
||||||
What would it take for ke to be your daily drives?
|
What would it take for ke to be your daily drives?
|
||||||
+ C-u
|
[x] C-u (repeat actions)
|
||||||
+ Alt nav (backspace, delete, f, b, etc)
|
[x] Alt nav (backspace, delete, f, b, etc)
|
||||||
|
[-] undo tree (C-k u/U)
|
||||||
|
|||||||
@@ -5,9 +5,15 @@
|
|||||||
installShellFiles,
|
installShellFiles,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
cmakeContent = builtins.readFile ./CMakeLists.txt;
|
||||||
|
cmakeLines = lib.splitString "\n" cmakeContent;
|
||||||
|
versionLine = lib.findFirst (l: builtins.match ".*set\\(KE_VERSION \".+\"\\).*" l != null) (throw "KE_VERSION not found in CMakeLists.txt") cmakeLines;
|
||||||
|
version = builtins.head (builtins.match ".*set\\(KE_VERSION \"(.+)\"\\).*" versionLine);
|
||||||
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = "ke";
|
pname = "ke";
|
||||||
version = "1.3.6";
|
inherit version;
|
||||||
|
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
|
|
||||||
|
|||||||
24
ke.1
24
ke.1
@@ -28,6 +28,12 @@ k-command mode can be exited with ESC or C-g.
|
|||||||
Delete from the cursor to the beginning of the line.
|
Delete from the cursor to the beginning of the line.
|
||||||
.It C-k SPACE
|
.It C-k SPACE
|
||||||
Toggle the mark.
|
Toggle the mark.
|
||||||
|
.It C-k -
|
||||||
|
If the mark is set, unindent the region.
|
||||||
|
.It C-k =
|
||||||
|
If the mark is set, indent the region.
|
||||||
|
.It C-k c
|
||||||
|
Clear (flush) the kill ring.
|
||||||
.It C-k d
|
.It C-k d
|
||||||
Delete from the cursor to the end of the line.
|
Delete from the cursor to the end of the line.
|
||||||
.It C-k C-d
|
.It C-k C-d
|
||||||
@@ -38,14 +44,25 @@ Edit a new file. Also C-k C-e.
|
|||||||
Incremental find.
|
Incremental find.
|
||||||
.It C-k g
|
.It C-k g
|
||||||
Go to a specific line.
|
Go to a specific line.
|
||||||
|
.It C-k j
|
||||||
|
Jump to the mark.
|
||||||
.It C-k l
|
.It C-k l
|
||||||
List the number of lines of code in a saved file.
|
List the number of lines of code in a saved file.
|
||||||
.It C-k m
|
.It C-k m
|
||||||
Run make(1).
|
Run make(1).
|
||||||
.It C-k q
|
.It C-k q
|
||||||
exit the editor. Also C-k C-q.
|
Exit the editor. If the file has unsaved changes,
|
||||||
|
a warning will be printed; a second C-k q will exit.
|
||||||
|
.It C-k C-q
|
||||||
|
Immediately exit the editor.
|
||||||
|
.It C-k C-r
|
||||||
|
Reload the current buffer from disk.
|
||||||
.It C-k s
|
.It C-k s
|
||||||
save the file, prompting for a filename if needed. Also C-k C-s.
|
Save the file, prompting for a filename if needed. Also C-k C-s.
|
||||||
|
.It C-k u
|
||||||
|
Undo changes.
|
||||||
|
.It C-k U
|
||||||
|
Redo changes.
|
||||||
.It C-k x
|
.It C-k x
|
||||||
save the file and exit. Also C-k C-x.
|
save the file and exit. Also C-k C-x.
|
||||||
.It C-k y
|
.It C-k y
|
||||||
@@ -61,6 +78,9 @@ In general, C-g cancels an operation.
|
|||||||
Refresh the display.
|
Refresh the display.
|
||||||
.It C-s
|
.It C-s
|
||||||
Incremental find.
|
Incremental find.
|
||||||
|
.It C-u
|
||||||
|
Universal argument. C-u followed by numbers will repeat an
|
||||||
|
operation n times.
|
||||||
.It C-w
|
.It C-w
|
||||||
Kill the region if the mark is set.
|
Kill the region if the mark is set.
|
||||||
.It C-y
|
.It C-y
|
||||||
|
|||||||
162
scratch.c
Normal file
162
scratch.c
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* scratch.c - ideas in progress
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define REFLOW_MARGIN 72
|
||||||
|
|
||||||
|
void
|
||||||
|
reflow_region(void)
|
||||||
|
{
|
||||||
|
int start_row, end_row, i, col, wlen, this_len;
|
||||||
|
struct erow *row;
|
||||||
|
struct abuf buf = ABUF_INIT;
|
||||||
|
struct abuf out = ABUF_INIT;
|
||||||
|
int in_paragraph = 0;
|
||||||
|
int indent_len = 0;
|
||||||
|
char indent[REFLOW_MARGIN + 1];
|
||||||
|
char word[REFLOW_MARGIN + 1];
|
||||||
|
char *e = NULL;
|
||||||
|
char *p = NULL;
|
||||||
|
char *s = NULL;
|
||||||
|
|
||||||
|
if (editor.mark_set) {
|
||||||
|
if (editor.mark_cury < editor.cury ||
|
||||||
|
(editor.mark_cury == editor.cury &&
|
||||||
|
editor.mark_curx < editor.curx)) {
|
||||||
|
start_row = editor.mark_cury;
|
||||||
|
end_row = editor.cury;
|
||||||
|
} else {
|
||||||
|
start_row = editor.cury;
|
||||||
|
end_row = editor.mark_cury;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
start_row = end_row = editor.cury;
|
||||||
|
while (start_row > 0 && editor.row[start_row - 1].size > 0) {
|
||||||
|
start_row--;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (end_row < editor.nrows - 1 &&
|
||||||
|
editor.row[end_row + 1].size > 0) {
|
||||||
|
end_row++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start_row >= editor.nrows) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end_row >= editor.nrows) {
|
||||||
|
end_row = editor.nrows - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = start_row; i <= end_row; i++) {
|
||||||
|
row = &editor.row[i];
|
||||||
|
|
||||||
|
if (row->size == 0) {
|
||||||
|
if (in_paragraph) {
|
||||||
|
ab_append(&buf, "\n", 1);
|
||||||
|
in_paragraph = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ab_append(&buf, "\n", 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_paragraph) {
|
||||||
|
indent_len = 0;
|
||||||
|
while (indent_len < row->size &&
|
||||||
|
(row->line[indent_len] == ' ' ||
|
||||||
|
row->line[indent_len] == '\t')) {
|
||||||
|
indent[indent_len] = row->line[indent_len], indent_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
indent[indent_len] = '\0';
|
||||||
|
in_paragraph = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ab_append(&buf, row->line + indent_len, row->size - indent_len);
|
||||||
|
ab_append(&buf, " ", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_paragraph) {
|
||||||
|
ab_append(&buf, "\n", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
p = buf.b;
|
||||||
|
col = 0;
|
||||||
|
|
||||||
|
while (p != NULL && *p != '\0') {
|
||||||
|
while (*p && isspace((unsigned char)*p) &&
|
||||||
|
*p != '\n') {
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*p == '\0') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlen = 0;
|
||||||
|
while (*p && !isspace((unsigned char)*p)) {
|
||||||
|
if (wlen < REFLOW_MARGIN)
|
||||||
|
word[wlen++] = *p;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
word[wlen] = '\0';
|
||||||
|
|
||||||
|
if (*p == '\n' && (p[1] == '\n' || p[1] == '\0')) {
|
||||||
|
ab_append(&out, "\n", 1); /* flush */
|
||||||
|
col = 0;
|
||||||
|
p++; /* consume the extra \n */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this_len = wlen;
|
||||||
|
if (col > 0) {
|
||||||
|
this_len++; /* space before word */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (col == 0) {
|
||||||
|
ab_append(&out, indent, indent_len);
|
||||||
|
col = indent_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (col + this_len > REFLOW_MARGIN && col > 0) {
|
||||||
|
ab_append(&out, "\n", 1);
|
||||||
|
ab_append(&out, indent, indent_len);
|
||||||
|
col = indent_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (col > 0) {
|
||||||
|
ab_append(&out, " ", 1);
|
||||||
|
col++;
|
||||||
|
}
|
||||||
|
|
||||||
|
ab_append(&out, word, wlen);
|
||||||
|
col += wlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (col > 0) {
|
||||||
|
ab_append(&out, "\n", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the old switcharoo */
|
||||||
|
buf = out;
|
||||||
|
ab_free(&out);
|
||||||
|
|
||||||
|
|
||||||
|
for (i = end_row; i >= start_row; i--) {
|
||||||
|
delete_row(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
s = buf.b;
|
||||||
|
while ((e = strchr(s, '\n'))) {
|
||||||
|
erow_insert(start_row++, s, e - s);
|
||||||
|
s = e + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ab_free(&buf);
|
||||||
|
|
||||||
|
editor.dirty++;
|
||||||
|
editor_set_status("Region reflowed to %d columns", REFLOW_MARGIN);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user