shithub: orca

Download patch

ref: dbcb8e1e2946030e2abb7ad59af89a3317632f78
parent: ca259636fa5a55cfb0445acd4b665f98865013b9
author: cancel <cancel@cancel.fm>
date: Tue Dec 4 11:02:06 EST 2018

Change piano input mode to forward slash, add cursor display

--- a/tui_main.c
+++ b/tui_main.c
@@ -23,6 +23,11 @@
 }
 
 typedef enum {
+  Tui_input_mode_normal = 0,
+  Tui_input_mode_piano = 1,
+} Tui_input_mode;
+
+typedef enum {
   C_natural,
   C_black,
   C_red,
@@ -167,7 +172,8 @@
 
 void tdraw_tui_cursor(WINDOW* win, int win_h, int win_w, Glyph const* gbuffer,
                       Usz field_h, Usz field_w, Usz ruler_spacing_y,
-                      Usz ruler_spacing_x, Usz cursor_y, Usz cursor_x) {
+                      Usz ruler_spacing_x, Usz cursor_y, Usz cursor_x,
+                      Tui_input_mode input_mode) {
   (void)ruler_spacing_y;
   (void)ruler_spacing_x;
   if (cursor_y >= field_h || cursor_x >= field_w || (int)cursor_y >= win_h ||
@@ -174,7 +180,19 @@
       (int)cursor_x >= win_w)
     return;
   Glyph beneath = gbuffer[cursor_y * field_w + cursor_x];
-  char displayed = beneath == '.' ? '@' : beneath;
+  char displayed;
+  if (beneath == '.') {
+    switch (input_mode) {
+    case Tui_input_mode_normal:
+      displayed = '@';
+      break;
+    case Tui_input_mode_piano:
+      displayed = '^';
+      break;
+    }
+  } else {
+    displayed = beneath;
+  }
   chtype ch =
       (chtype)(displayed | (A_reverse | A_bold | fg_bg(C_yellow, C_natural)));
   wmove(win, (int)cursor_y, (int)cursor_x);
@@ -357,11 +375,6 @@
 
 enum { Argopt_margins = UCHAR_MAX + 1 };
 
-typedef enum {
-  Tui_input_mode_normal = 0,
-  Tui_input_mode_piano = 1,
-} Tui_input_mode;
-
 int main(int argc, char** argv) {
   static struct option tui_options[] = {
       {"margins", required_argument, 0, Argopt_margins},
@@ -560,7 +573,7 @@
     }
     tdraw_tui_cursor(cont_win, cont_win_h, cont_win_w, field.buffer,
                      field.height, field.width, ruler_spacing_y,
-                     ruler_spacing_x, tui_cursor.y, tui_cursor.x);
+                     ruler_spacing_x, tui_cursor.y, tui_cursor.x, input_mode);
     if (content_h > 3) {
       tdraw_hud(cont_win, content_h - 2, 0, 2, content_w, input_file,
                 field.height, field.width, ruler_spacing_y, ruler_spacing_x,
@@ -641,7 +654,7 @@
       tui_resize_grid(&field, &markmap_r, 1, 0, tick_num, &scratch_field,
                       &undo_hist, &tui_cursor, &needs_remarking);
       break;
-    case '\\':
+    case '/':
       if (input_mode == Tui_input_mode_piano) {
         input_mode = Tui_input_mode_normal;
       } else {