]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added TargetCol updates to home and end key handlers
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 9 Oct 2016 22:44:54 +0000 (18:44 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 9 Oct 2016 22:44:54 +0000 (18:44 -0400)
TODO.md
keyboard.c
xedit.c

diff --git a/TODO.md b/TODO.md
index c5a4291969b262200f026ab404c77fa7ab46ec54..39689ed53db5e7a2885048f3d6306ffed20bd2e3 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -1,6 +1,5 @@
 # Internals and Miscellaneous
 
-* Re-work column tracking to keep the cursor reasonably close to where expected
 * Calculate line numbers and keep up to date while editing
 * Support multiple buffers
 * Implement undo/redo log
@@ -13,7 +12,6 @@
 # Unicode
 
 * Fix display of asian scripts and combining characters
-* Read the file in bytewise and detect the encoding and line endings. Use that info to perform cursor movements and redisplay.
 
 # Graphical User Interface
 
index 801426996fb24169150c27cb15e1f2a335be13ea..983320c884cd8f2dcaaa233f8f7bf0ce9338acec 100644 (file)
@@ -24,6 +24,16 @@ static void cursor_right(void) {
     TargetCol = buf_getcol(&Buffer, CursorPos);
 }
 
+static void cursor_home(void) {
+    CursorPos = buf_bol(&Buffer, CursorPos);
+    TargetCol = 0;
+}
+
+static void cursor_end(void) {
+    CursorPos = buf_eol(&Buffer, CursorPos);
+    TargetCol = (unsigned)-1;
+}
+
 void handle_key(Rune key) {
     /* ignore invalid keys */
     if (key == RUNE_ERR) return;
@@ -49,8 +59,8 @@ static void special_keys(Rune key) {
         case KEY_INSERT: Buffer.insert_mode = !Buffer.insert_mode; break;
         case KEY_F1:     Buffer.insert_mode = !Buffer.insert_mode; break;
         case KEY_DELETE: buf_del(&Buffer, CursorPos);              break;
-        case KEY_HOME:   CursorPos = buf_bol(&Buffer, CursorPos);  break;
-        case KEY_END:    CursorPos = buf_eol(&Buffer, CursorPos);  break;
+        case KEY_HOME:   cursor_home();                            break;
+        case KEY_END:    cursor_end();                             break;
     }
 }
 
diff --git a/xedit.c b/xedit.c
index 4cbdbd4bb2cbd1d0d7cf266e8fc03b3a41284520..b2281b19269d2c1adac44c9434612bd894636db4 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -216,10 +216,11 @@ static void redraw(void) {
     /* flush the screen buffer */
     unsigned nrows, ncols;
     screen_getsize(&nrows, &ncols);
-    screen_status(" %s %s%s",
+    screen_status(" %s %%s",
         (Buffer.charset == BINARY ? "BIN" : "UTF-8"),
-        (Buffer.modified ? " * " : " "),
-        Buffer.path);
+        (Buffer.modified ? '*' : ' '),
+        Buffer.path
+    );
     for (unsigned y = 0; y < nrows; y++) {
         Row* row = screen_getrow(y);
         XftDrawString32(X.xft, (y==0 ? &bkgclr : &txtclr), X.font, 0, (y+1) * fheight, (FcChar32*)(row->cols), (row->len));
@@ -257,6 +258,5 @@ int main(int argc, char** argv) {
       }
       redraw();
     }
-    deinit();
     return 0;
 }