Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| db38266849 | |||
| 6d1b7f8e56 | |||
| 64647f77b0 |
@@ -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.1")
|
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")
|
||||||
|
|||||||
10
default.nix
10
default.nix
@@ -5,9 +5,17 @@
|
|||||||
installShellFiles,
|
installShellFiles,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
cmakeContent = builtins.readFile ./CMakeLists.txt;
|
||||||
|
cmakeLines = lib.splitString "\n" cmakeContent;
|
||||||
|
# Find the line containing set(KE_VERSION "...")
|
||||||
|
versionLine = lib.findFirst (l: builtins.match ".*set\\(KE_VERSION \".+\"\\).*" l != null) (throw "KE_VERSION not found in CMakeLists.txt") cmakeLines;
|
||||||
|
# Extract the version number
|
||||||
|
version = builtins.head (builtins.match ".*set\\(KE_VERSION \"(.+)\"\\).*" versionLine);
|
||||||
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = "ke";
|
pname = "ke";
|
||||||
version = "1.5.1";
|
inherit version;
|
||||||
|
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
|
|
||||||
|
|||||||
20
main.c
20
main.c
@@ -212,6 +212,7 @@ void editor_find_callback(char *query, int16_t c);
|
|||||||
void editor_find(void);
|
void editor_find(void);
|
||||||
char *editor_prompt(char*, void (*cb)(char*, int16_t));
|
char *editor_prompt(char*, void (*cb)(char*, int16_t));
|
||||||
void editor_openfile(void);
|
void editor_openfile(void);
|
||||||
|
int first_nonwhitespace(struct erow *row);
|
||||||
void move_cursor_once(int16_t c, int interactive);
|
void move_cursor_once(int16_t c, int interactive);
|
||||||
void move_cursor(int16_t c, int interactive);
|
void move_cursor(int16_t c, int interactive);
|
||||||
void uarg_start(void);
|
void uarg_start(void);
|
||||||
@@ -507,6 +508,12 @@ erow_render_to_cursor(struct erow *row, int cx)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (b < 0x80) {
|
||||||
|
rx++;
|
||||||
|
j++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
size_t rem = (size_t)row->size - j;
|
size_t rem = (size_t)row->size - j;
|
||||||
size_t n = mbrtowc(&wc, &row->line[j], rem, &st);
|
size_t n = mbrtowc(&wc, &row->line[j], rem, &st);
|
||||||
|
|
||||||
@@ -560,6 +567,9 @@ erow_cursor_to_render(struct erow *row, int rx)
|
|||||||
} else if (b < 0x20) {
|
} else if (b < 0x20) {
|
||||||
w = 3; /* "\\xx" */
|
w = 3; /* "\\xx" */
|
||||||
adv = 1;
|
adv = 1;
|
||||||
|
} else if (b < 0x80) {
|
||||||
|
w = 1;
|
||||||
|
adv = 1;
|
||||||
} else {
|
} else {
|
||||||
size_t rem = (size_t)row->size - j;
|
size_t rem = (size_t)row->size - j;
|
||||||
size_t n = mbrtowc(&wc, &row->line[j], rem, &st);
|
size_t n = mbrtowc(&wc, &row->line[j], rem, &st);
|
||||||
@@ -1928,6 +1938,14 @@ first_nonwhitespace(struct erow *row)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (pos < row->size) {
|
while (pos < row->size) {
|
||||||
|
if ((unsigned char)row->line[pos] < 0x80) {
|
||||||
|
if (!isspace((unsigned char)row->line[pos])) {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
len = mbrtowc(&wc, &row->line[pos], row->size - pos, &state);
|
len = mbrtowc(&wc, &row->line[pos], row->size - pos, &state);
|
||||||
if (len == (size_t)-1 || len == (size_t)-2) {
|
if (len == (size_t)-1 || len == (size_t)-2) {
|
||||||
break;
|
break;
|
||||||
@@ -2875,7 +2893,7 @@ display_refresh(void)
|
|||||||
(editor.rx - editor.coloffs) + 1);
|
(editor.rx - editor.coloffs) + 1);
|
||||||
ab_append(&ab, buf, kstrnlen(buf, 32));
|
ab_append(&ab, buf, kstrnlen(buf, 32));
|
||||||
/* ab_append(&ab, ESCSEQ "1;2H", 7); */
|
/* ab_append(&ab, ESCSEQ "1;2H", 7); */
|
||||||
ab_append(&ab, ESCSEQ "?25l", 6);
|
ab_append(&ab, ESCSEQ "?25h", 6);
|
||||||
|
|
||||||
kwrite(STDOUT_FILENO, ab.b, ab.len);
|
kwrite(STDOUT_FILENO, ab.b, ab.len);
|
||||||
ab_free(&ab);
|
ab_free(&ab);
|
||||||
|
|||||||
Reference in New Issue
Block a user