summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jet.cpp68
-rw-r--r--todo.txt2
2 files changed, 37 insertions, 33 deletions
diff --git a/jet.cpp b/jet.cpp
index 894fc69..b11744a 100644
--- a/jet.cpp
+++ b/jet.cpp
@@ -3,7 +3,7 @@
#include <assert.h>
#include <locale.h>
#include <curses.h>
-#define PAGE_SIZE 2
+#define PAGE_SIZE 4096
#include "page.cpp"
#include "point.cpp"
#include "buffer.cpp"
@@ -56,38 +56,44 @@ int main(int argc, char *argv[]) {
}
int input = getch();
-
- if (mode == NORMAL_MODE) {
- switch (input) {
- case '':
- quit = 1;
- break;
- case 'i':
- mode = INSERT_MODE;
- break;
- case 'k':
- buffer.prev_line(window_width);
- break;
- case 'j':
- buffer.next_line(window_width);
- break;
- case 'h':
- buffer.cursor--;
- break;
- case 'l':
- buffer.cursor++;
- break;
+ if (byte_type(input) == 1) {
+ if (mode == NORMAL_MODE) {
+ switch (input) {
+ case '':
+ quit = 1;
+ break;
+ case 'i':
+ mode = INSERT_MODE;
+ break;
+ case 'k':
+ buffer.prev_line(window_width);
+ break;
+ case 'j':
+ buffer.next_line(window_width);
+ break;
+ case 'h':
+ buffer.cursor--;
+ break;
+ case 'l':
+ buffer.cursor++;
+ break;
+ }
+ } else {
+ switch (input) {
+ case '':
+ mode = NORMAL_MODE;
+ break;
+ case KEY_BACKSPACE:
+ buffer.cursor.pop();
+ break;
+ default:
+ buffer.cursor.push(input);
+ }
}
} else {
- switch (input) {
- case '':
- mode = NORMAL_MODE;
- break;
- case KEY_BACKSPACE:
- buffer.cursor.pop();
- break;
- default:
- buffer.cursor.push(input);
+ buffer.cursor.push(input);
+ for (int i = 0; i < byte_type(input) - 1; i++) {
+ buffer.cursor.push(getch());
}
}
}
diff --git a/todo.txt b/todo.txt
index 0d89fc7..ba70618 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,3 +1 @@
* free page correctly after no points point to it
-* add utf-8 support on push and pop
-* fix pop