mirror of
https://github.com/nippur72/apple1-videocard-lib.git
synced 2024-06-12 09:29:34 +00:00
add line_input routine
This commit is contained in:
parent
fd2d060a91
commit
95d46a7e00
33
lib/apple1.h
33
lib/apple1.h
|
@ -123,6 +123,39 @@ byte apple1_readkey() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void apple1_input_line(byte *buffer, byte max) {
|
||||||
|
byte x=0;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
byte c = apple1_getkey();
|
||||||
|
buffer[x] = c;
|
||||||
|
if(c==13) {
|
||||||
|
// RETURN ends input
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(c==27) {
|
||||||
|
// ESC clears the string
|
||||||
|
x=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(c==8 || c=='_') {
|
||||||
|
// BACKSPACE
|
||||||
|
if(x != 0) {
|
||||||
|
woz_putc('_');
|
||||||
|
x--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// character input
|
||||||
|
if(x<max) {
|
||||||
|
woz_putc(c);
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buffer[x]=0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef APPLE1
|
#ifdef APPLE1
|
||||||
|
|
||||||
#include <stdlib.h> // for memcpy
|
#include <stdlib.h> // for memcpy
|
||||||
|
|
Loading…
Reference in New Issue
Block a user