shithub: orca

Download patch

ref: 49dc72d06eba5a4924c2e123cb8e9d8af2236de7
parent: 03172f6c6066f7f9e788fae1692cbd9e656b1da1
author: cancel <cancel@cancel.fm>
date: Thu Jan 17 01:21:19 EST 2019

Add --initial-size argument for tui

--- a/tui_main.c
+++ b/tui_main.c
@@ -33,6 +33,9 @@
 "                           If you plan to work with large files,\n"
 "                           set this to a low number.\n"
 "                           Default: 100\n"
+"    --initial-size <nxn>   When creating a new grid file, use these\n" 
+"                           starting dimensions.\n"
+"                           Default: 57x25\n"
 "    -h or --help           Print this message and exit.\n"
 "\n"
 "OSC/MIDI options:\n"
@@ -1814,6 +1817,7 @@
 enum {
   Argopt_margins = UCHAR_MAX + 1,
   Argopt_undo_limit,
+  Argopt_init_grid_size,
   Argopt_osc_server,
   Argopt_osc_port,
   Argopt_osc_midi_bidule,
@@ -1828,6 +1832,7 @@
   static struct option tui_options[] = {
       {"margins", required_argument, 0, Argopt_margins},
       {"undo-limit", required_argument, 0, Argopt_undo_limit},
+      {"initial-size", required_argument, 0, Argopt_init_grid_size},
       {"help", no_argument, 0, 'h'},
       {"osc-server", required_argument, 0, Argopt_osc_server},
       {"osc-port", required_argument, 0, Argopt_osc_port},
@@ -1845,6 +1850,8 @@
   char const* osc_hostname = NULL;
   char const* osc_port = NULL;
   bool strict_timing = false;
+  int init_grid_dim_y = 25;
+  int init_grid_dim_x = 57;
   Midi_mode midi_mode;
   midi_mode_init_null(&midi_mode);
   for (;;) {
@@ -1880,6 +1887,28 @@
         exit(1);
       }
     } break;
+    case Argopt_init_grid_size: {
+      enum {
+        Max_dim_arg_val_y = ORCA_Y_MAX,
+        Max_dim_arg_val_x = ORCA_X_MAX,
+      };
+      if (sscanf(optarg, "%dx%d", &init_grid_dim_x, &init_grid_dim_y) != 2) {
+        fprintf(stderr, "Bad argument format or count for initial-size.\n");
+        exit(1);
+      }
+      if (init_grid_dim_x <= 0 || init_grid_dim_x > Max_dim_arg_val_x) {
+        fprintf(stderr,
+                "X dimension for initial-size must be 1 <= n <= %d, was %d.\n",
+                Max_dim_arg_val_x, init_grid_dim_x);
+        exit(1);
+      }
+      if (init_grid_dim_y <= 0 || init_grid_dim_y > Max_dim_arg_val_y) {
+        fprintf(stderr,
+                "Y dimension for initial-size must be 1 <= n <= %d, was %d.\n",
+                Max_dim_arg_val_y, init_grid_dim_y);
+        exit(1);
+      }
+    } break;
     case Argopt_osc_server: {
       osc_hostname = optarg;
     } break;
@@ -2001,7 +2030,8 @@
     heapstr_init_cstr(&file_name, input_file);
   } else {
     heapstr_init_cstr(&file_name, "unnamed");
-    field_init_fill(&ged_state.field, 25, 57, '.');
+    field_init_fill(&ged_state.field, (Usz)init_grid_dim_y,
+                    (Usz)init_grid_dim_x, '.');
   }
   ged_state.filename = file_name.str;
   ged_set_midi_mode(&ged_state, &midi_mode);