summaryrefslogtreecommitdiff
path: root/jet.cpp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2020-06-22 05:44:38 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2020-06-22 05:44:38 -0300
commitc835a9729091445bb68c5d376a8b8fd7a379cb32 (patch)
tree4474942404c2891adc9330e4f883b6131e68866a /jet.cpp
parent19644585485799d19bf98035c8b2b2b1ab402c5f (diff)
downloadjet-c835a9729091445bb68c5d376a8b8fd7a379cb32.tar.gz
jet-c835a9729091445bb68c5d376a8b8fd7a379cb32.zip
Redraw page once per unicode character inserted
Diffstat (limited to 'jet.cpp')
-rw-r--r--jet.cpp68
1 files changed, 37 insertions, 31 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());
}
}
}