r/o

ba4d7d5e176f67de88fc8d76ad6e8848eeb1170f parent 7524f0c5

authored by Yuki Izumi <yuki@kivikakk.ee> 10 years ago

Disable virtual space for now.

TODO | 3 ++-
qb.c | 12 +++++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/TODO b/TODO
index 7416d18..6343c9f 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,7 @@
* model a text editor
* backspace
- * virtual space entry
* scrolling
+ * virtual space
+ * considerations for backspace/delete in virtual space
* model the application GUI
* lexer + parser
diff --git a/qb.c b/qb.c
index 66a8b37..5791da7 100644
--- a/qb.c
+++ b/qb.c
@@ -176,12 +176,22 @@ void qb_keypress(SDL_Keycode sym, Uint16 mod) {
if (sym == SDLK_DOWN && cursor_y < total_lines - 1) {
++cursor_y;
+ int max = get_current_doc_line()->stored;
+ if (cursor_x > max) {
+ cursor_x = max;
+ }
} else if (sym == SDLK_UP && cursor_y > 0) {
--cursor_y;
+ int max = get_current_doc_line()->stored;
+ if (cursor_x > max) {
+ cursor_x = max;
+ }
} else if (sym == SDLK_LEFT && cursor_x > 0) {
--cursor_x;
} else if (sym == SDLK_RIGHT) {
- ++cursor_x;
+ if (cursor_x < get_current_doc_line()->stored) {
+ ++cursor_x;
+ }
} else if (is_printable_key(sym)) {
insert_character(
get_current_doc_line(),