Unified · Split
| @@ -8,6 +8,8 @@ · 7 unmodified lines | ||
| 8 | 8 | #include <keyboard.h> |
| 9 | 9 | #include <thread.h> |
| 10 | 10 | |
| 11 | +typedef struct Key Key; | |
| 12 | + | |
| 11 | 13 | #define MIN(x,y) ((x)<(y)?(x):(y)) |
| 12 | 14 | #define MAX(x,y) ((x)>(y)?(x):(y)) |
| 13 | 15 | |
| @@ -33,6 +35,12 @@ enum { · 19 unmodified lines | ||
| 33 | 35 | Mselect, |
| 34 | 36 | Nummodes, |
| 35 | 37 | |
| 38 | + Menu3load = 0, | |
| 39 | + Menu3save, | |
| 40 | + Menu3dotstyle, | |
| 41 | + Menu3rulerstyle, | |
| 42 | + Nummenu3, | |
| 43 | + | |
| 36 | 44 | Dback = 0, |
| 37 | 45 | Dfhigh, |
| 38 | 46 | Dfmed, |
| @@ -45,18 +53,35 @@ enum { · 6 unmodified lines | ||
| 45 | 53 | Numcolors, |
| 46 | 54 | }; |
| 47 | 55 | |
| 48 | −typedef struct Key Key; | |
| 49 | − | |
| 50 | −static struct { | |
| 51 | − u8int u[4]; | |
| 52 | − Usz at; | |
| 53 | −}noteoff[16*128]; /* 16 channels, 128 notes each */ | |
| 54 | − | |
| 55 | 56 | struct Key { |
| 56 | 57 | int down; |
| 57 | 58 | Rune rune; |
| 58 | 59 | }; |
| 59 | 60 | |
| 61 | +static Rune *linebuf; | |
| 62 | +static Usz tick; | |
| 63 | +static int gridw = 8, gridh = 8; | |
| 64 | +static int rulerstyle = Sfancy, dotstyle = Sfancy; | |
| 65 | +static int bpm = 120, pause; | |
| 66 | +static int curx, cury; | |
| 67 | +static int selw = 1, selh = 1; | |
| 68 | +static int charw, charh; | |
| 69 | +static Field field; | |
| 70 | +static Mbuf_reusable mbuf; | |
| 71 | +static Oevent_list events; | |
| 72 | +static char filename[256]; | |
| 73 | +static Channel *cchan; | |
| 74 | +static Field copyfield; | |
| 75 | +static int altdown; | |
| 76 | +static int mode = Minsert; | |
| 77 | +static long framedev; /* frame deviation >= 1µs */ | |
| 78 | + | |
| 79 | +static char *style[Numstyles] = { | |
| 80 | + [Sfancy] = "fancy", | |
| 81 | + [Splain] = "plain", | |
| 82 | + [Snone] = "none", | |
| 83 | +}; | |
| 84 | + | |
| 60 | 85 | static Rune dot[Numstyles] = { |
| 61 | 86 | [Sfancy] = L'·', |
| 62 | 87 | [Splain] = '.', |
| @@ -81,23 +106,10 @@ static Rune ruler[Numstyles][9] = { · 18 unmodified lines | ||
| 81 | 106 | }, |
| 82 | 107 | }; |
| 83 | 108 | |
| 84 | −static Rune *linebuf; | |
| 85 | −static Usz tick; | |
| 86 | −static int gridw = 8, gridh = 8; | |
| 87 | −static int rulerstyle = Sfancy, dotstyle = Sfancy; | |
| 88 | −static int bpm = 120, pause; | |
| 89 | −static int curx, cury; | |
| 90 | −static int selw = 1, selh = 1; | |
| 91 | −static int charw, charh; | |
| 92 | −static Field field; | |
| 93 | −static Mbuf_reusable mbuf; | |
| 94 | −static Oevent_list events; | |
| 95 | −static char filename[256]; | |
| 96 | −static Channel *cchan; | |
| 97 | −static Field copyfield; | |
| 98 | −static int altdown; | |
| 99 | −static int mode = Minsert; | |
| 100 | −static long framedev; /* frame deviation >= 1µs */ | |
| 109 | +static struct { | |
| 110 | + u8int u[4]; | |
| 111 | + Usz at; | |
| 112 | +}noteoff[16*128]; /* 16 channels, 128 notes each */ | |
| 101 | 113 | |
| 102 | 114 | static u32int theme[Numcolors] = { |
| 103 | 115 | [Dback] = 0x000000ff, |
| @@ -120,10 +132,9 @@ static char *modes[Nummodes] = { · 16 unmodified lines | ||
| 120 | 132 | [Mselect] = "select", |
| 121 | 133 | }; |
| 122 | 134 | |
| 123 | −static char *menu3i[] = { | |
| 124 | − "load", | |
| 125 | − "save", | |
| 126 | − nil, | |
| 135 | +static char *menu3i[Nummenu3+1] = { | |
| 136 | + [Menu3load] = "load", | |
| 137 | + [Menu3save] = "save", | |
| 127 | 138 | }; |
| 128 | 139 | |
| 129 | 140 | static Menu menu3 = { |
| @@ -309,9 +320,9 @@ redraw(void) · 179 unmodified lines | ||
| 309 | 320 | if (c == '.') { |
| 310 | 321 | c = dot[dotstyle]; |
| 311 | 322 | if ((x % gridw) == 0 && (y % gridh) == 0) { |
| 312 | − rx = x == 0 ? 0 : (x == field.width-1 ? 2 : 1); | |
| 313 | − ry = y == 0 ? 0 : (y == field.height-1 ? 2 : 1); | |
| 314 | − c = ruler[dotstyle][ry*3+rx]; | |
| 323 | + rx = !!x + (x + 1) / field.width; | |
| 324 | + ry = !!y + (y + 1) / field.height; | |
| 325 | + c = ruler[rulerstyle][ry*3+rx]; | |
| 315 | 326 | } |
| 316 | 327 | } |
| 317 | 328 | linebuf[x] = c; |
| @@ -680,18 +691,25 @@ threadmain(int argc, char **argv) · 362 unmodified lines | ||
| 680 | 691 | case 2: |
| 681 | 692 | break; |
| 682 | 693 | case 4: |
| 694 | + menu3i[Menu3dotstyle] = tmp; | |
| 695 | + menu3i[Menu3rulerstyle] = 1 + menu3i[Menu3dotstyle] + sprintf(tmp, "%s dots", style[(dotstyle+1) % Numstyles]); | |
| 696 | + sprintf(menu3i[Menu3rulerstyle], "%s rulers", style[(rulerstyle+1) % Numstyles]); | |
| 683 | 697 | n = menuhit(3, mctl, &menu3, nil); |
| 684 | − if (n == 0 || n == 1) { | |
| 698 | + if (n == Menu3load || n == Menu3save) { | |
| 685 | 699 | strncpy(tmp, filename, sizeof(tmp)); |
| 686 | 700 | if (enter("file path:", tmp, sizeof(tmp), mctl, &kctl, nil) > 0) { |
| 687 | − if (n == 0 && fieldload(tmp) == 0) { | |
| 701 | + if (n == Menu3load && fieldload(tmp) == 0) { | |
| 688 | 702 | w = field.width; |
| 689 | 703 | h = field.height; |
| 690 | 704 | strncpy(filename, tmp, sizeof(filename)); |
| 691 | − } else if (n == 1 && fieldsave(tmp) == 0) { | |
| 705 | + } else if (n == Menu3save && fieldsave(tmp) == 0) { | |
| 692 | 706 | strncpy(filename, tmp, sizeof(filename)); |
| 693 | 707 | } |
| 694 | 708 | } |
| 709 | + } else if (n == Menu3dotstyle) { | |
| 710 | + dotstyle = ++dotstyle % Numstyles; | |
| 711 | + } else if (n == Menu3rulerstyle) { | |
| 712 | + rulerstyle = ++rulerstyle % Numstyles; | |
| 695 | 713 | } |
| 696 | 714 | break; |
| 697 | 715 | } |