ref: 97d50f6ed11bf1470c2525420c7bf158b26064b6
parent: 5296e55cfb065247016be4632c9fb30425425908
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Feb 16 10:37:33 EST 2020
plan9: use boolean where applicable
--- a/plan9.c
+++ b/plan9.c
@@ -66,7 +66,7 @@
static vlong tick;
static int gridw = 8, gridh = 8;
static int rulerstyle = Sfancy, dotstyle = Sfancy;
-static int bpm = 120, apm = 120, pause, forward;
+static int bpm = 120, apm = 120;
static int curx, cury;
static int selw = 1, selh = 1;
static int charw, charh;
@@ -75,7 +75,7 @@
static char filename[256];
static Channel *cchan;
static Field copyfield, selfield;
-static int altdown;
+static bool altdown, pause, forward;
static int mode = Minsert;
static long framedev; /* frame deviation >= 1ms */
static Rune *linebuf;
@@ -284,7 +284,7 @@
process(&events);
nbsendul(drawchan, 0);
- forward = 0;
+ forward = false;
do {
end = 15000000000LL/bpm; /* 1e9*60/4 */
n = nanosec() - start;
@@ -315,7 +315,8 @@
Rectangle r;
Point p, top, bot;
int x, y, rx, ry, i;
- int oldbg, oldfg, bg, fg, attr, selected, off;
+ int oldbg, oldfg, bg, fg, attr, off;
+ bool selected;
char s[32];
Rune c;
@@ -478,10 +479,11 @@
static void
selset(Rune key)
{
- int y, commented;
+ int y;
+ bool commented;
if (key == '#') {
- commented = 1;
+ commented = true;
for (y = cury; y < cury+selh && y < field.height && commented; y++) {
commented =
field.buffer[curx + field.width*y] == key &&
@@ -490,7 +492,7 @@
if (commented)
key = '.';
} else {
- commented = 0;
+ commented = false;
}
for (y = cury; y < cury+selh && y < field.height; y++) {
@@ -690,11 +692,11 @@
*a++ = 0;
if (strcmp(s, "play") == 0)
- pause = 0;
+ pause = false;
else if (strcmp(s, "stop") == 0)
- pause = 1;
+ pause = true;
else if (strcmp(s, "run") == 0)
- forward = 1;
+ forward = true;
else if (a != nil) {
x = atoi(a);
@@ -722,8 +724,9 @@
Mouse m;
char tmp[256];
Channel *kchan;
- int oldw, oldh, w, h, n, shiftdown, complete;
- int movex, movey, ctldown;
+ int oldw, oldh, w, h, n;
+ int movex, movey;
+ bool shiftdown, complete, ctldown;
Alt a[Numchan+1] = {
[Cchar] = { nil, &key.rune, CHANRCV },
[Ckey] = { nil, &key, CHANRCV },
@@ -777,15 +780,15 @@
memset(mscr.buffer, 0, w*h);
proccreate(orcathread, a[Credraw].c, mainstacksize);
- shiftdown = 0;
- altdown = 0;
- complete = 1;
+ shiftdown = false;
+ altdown = false;
+ complete = true;
movex = 1;
movey = 1;
for (;;) {
redraw(complete);
- complete = 0;
+ complete = false;
oldw = w = field.width;
oldh = h = field.height;
@@ -815,7 +818,7 @@
} else if (n == Menu3exit) {
goto end;
}
- complete = 1;
+ complete = true;
} else {
goto noredraw;
}
@@ -823,7 +826,7 @@
case Cresize:
getwindow(display, Refnone);
- complete = 1;
+ complete = true;
break;
case Ckey:
@@ -927,7 +930,7 @@
break;
case 0x12: /* C-r */
tick = -1;
- forward = 1;
+ forward = true;
break;
case 0x13: /* C-s */
tmp[0] = 0;
@@ -948,19 +951,19 @@
break;
case '[':
gridw = MAX(4, gridw-1);
- complete = 1;
+ complete = true;
break;
case ']':
gridw = MIN(16, gridw+1);
- complete = 1;
+ complete = true;
break;
case '{':
gridh = MAX(4, gridh-1);
- complete = 1;
+ complete = true;
break;
case '}':
gridh = MIN(16, gridh+1);
- complete = 1;
+ complete = true;
break;
case '(':
w = snaplow(w, gridw);
@@ -996,7 +999,7 @@
selw = selh = 1;
break;
case Kack: /* C-f */
- forward = 1;
+ forward = true;
break;
case '`':
case '~':
@@ -1047,7 +1050,7 @@
);
field_resize_raw(©field, h, w);
- complete = 1;
+ complete = true;
}
}