Modified to use the new structured keyboard events. - sam - An updated version … | |
git clone git://vernunftzentrum.de/sam.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 6c30b996149947cc5c874fd3dc7e3fea9ac202d3 | |
parent 7dbd2384a6bb71e4f846fd69ce323a43d1bccec6 | |
Author: Rob King <[email protected]> | |
Date: Tue, 17 May 2016 17:45:25 -0500 | |
Modified to use the new structured keyboard events. | |
Diffstat: | |
samterm/io.c | 34 ++++++++++++++++--------------- | |
samterm/main.c | 4 +++- | |
samterm/mesg.c | 6 +++--- | |
samterm/samterm.h | 2 +- | |
4 files changed, 25 insertions(+), 21 deletions(-) | |
--- | |
diff --git a/samterm/io.c b/samterm/io.c | |
@@ -10,7 +10,7 @@ int cursorfd; | |
int input; | |
int got; | |
int block; | |
-int kbdc; | |
+Keystroke keystroke; | |
int reshaped; | |
uchar *hostp; | |
uchar *hoststop; | |
@@ -82,7 +82,7 @@ waitforio(void) | |
externload(&e); | |
break; | |
case Ekeyboard: | |
- kbdc = e.kbdc; | |
+ keystroke = e.keystroke; | |
break; | |
case Emouse: | |
mouse = e.mouse; | |
@@ -145,37 +145,39 @@ externchar(void) | |
return -1; | |
} | |
-int | |
+Keystroke | |
kbdchar(void) | |
{ | |
- int c; | |
+ Keystroke k = {0}; | |
static Event e; | |
- c = externchar(); | |
- if(c > 0) | |
- return c; | |
+ k.c = externchar(); | |
+ if(k.c > 0) | |
+ return k; | |
if(got & Ekeyboard){ | |
- c = kbdc; | |
- kbdc = -1; | |
+ k = keystroke; | |
+ keystroke.c = -1; | |
got &= ~Ekeyboard; | |
- return c; | |
+ return k; | |
} | |
while(ecanread(Eextern)){ | |
eread(Eextern, &e); | |
externload(&e); | |
- c = externchar(); | |
- if(c > 0) | |
- return c; | |
+ k.c = externchar(); | |
+ if(k.c > 0) | |
+ return k; | |
} | |
- if(!ecankbd()) | |
- return -1; | |
+ if(!ecankbd()){ | |
+ k.c = -1; | |
+ return k; | |
+ } | |
return ekbd(); | |
} | |
int | |
qpeekc(void) | |
{ | |
- return kbdc; | |
+ return keystroke.c; | |
} | |
void | |
diff --git a/samterm/main.c b/samterm/main.c | |
@@ -483,6 +483,7 @@ type(Flayer *l, int res) /* what a bloody mess this … | |
{ | |
Text *t = (Text *)l->user1; | |
Rune buf[100]; | |
+ Keystroke k; | |
Rune *p = buf; | |
int c, backspacing, moving; | |
long a; | |
@@ -509,7 +510,8 @@ type(Flayer *l, int res) /* what a bloody mess this … | |
} | |
backspacing = 0; | |
moving = 0; | |
- while((c = kbdchar())>0){ | |
+ while(((k = kbdchar()), k.c) > 0){ | |
+ c = k.c; | |
if(res == RKeyboard){ | |
if(c == UPKEY || c==SCROLLKEY || c==ESC || c==COMMANDK… | |
break; | |
diff --git a/samterm/mesg.c b/samterm/mesg.c | |
@@ -30,9 +30,9 @@ void | |
rcv(void) | |
{ | |
int c; | |
- static state = 0; | |
- static count = 0; | |
- static i = 0; | |
+ static int state = 0; | |
+ static int count = 0; | |
+ static int i = 0; | |
static int errs = 0; | |
while((c=rcvchar()) != -1) | |
diff --git a/samterm/samterm.h b/samterm/samterm.h | |
@@ -88,7 +88,7 @@ int load(char*, int); | |
int waitforio(void); | |
int rcvchar(void); | |
int getch(void); | |
-int kbdchar(void); | |
+Keystroke kbdchar(void); | |
int qpeekc(void); | |
void mouseexit(void); | |
void cut(Text*, int, int, int); |