Bug fixes on $hex and 2/ + mess with X.

This commit is contained in:
Brad Nelson
2021-01-05 10:38:09 -08:00
parent 100ddf375b
commit 476434c92c
4 changed files with 36 additions and 5 deletions

View File

@ -22,7 +22,7 @@
: bl 32 ; : nl 10 ;
: 1+ 1 + ; : 1- 1 - ;
: 2* 2 * ; : 2/ 2 / ;
: 4* 4 * ; : 2/ 4 / ;
: 4* 4 * ; : 4/ 4 / ;
: +! ( n a -- ) swap over @ + swap ! ;
( Cells )

View File

@ -3,7 +3,7 @@
#define NEXT w = *ip++; goto **(void **) w
#define CELL_LEN(n) (((n) + sizeof(cell_t) - 1) / sizeof(cell_t))
#define FIND(name) find(name, sizeof(name) - 1)
#define LOWER(ch) ((ch) & 95)
#define LOWER(ch) ((ch) & 0x5F)
#if PRINT_ERRORS
#include <unistd.h>
@ -23,15 +23,15 @@ static cell_t convert(const char *pos, cell_t n, cell_t *ret) {
cell_t negate = 0;
cell_t base = g_sys.base;
if (!n) { return 0; }
if (pos[0] == '$') { base = 16; ++pos; --n; }
if (pos[0] == '-') { negate = -1; ++pos; --n; }
if (pos[0] == '$') { base = 16; ++pos; --n; }
for (; n; --n) {
uintptr_t d = pos[0] - '0';
if (d > 9) {
d = LOWER(d) - 7;
if (d < 10) { return 0; }
}
if (d >= (uintptr_t) g_sys.base) { return 0; }
if (d >= base) { return 0; }
*ret = *ret * base + d;
++pos;
}

View File

@ -24,6 +24,9 @@ z" XNextEvent" 2 xlib XNextEvent ( a a -- void )
z" XPutImage" 10 xlib XPutImage ( a n a a n n n n n n -- void )
z" XSelectInput" 3 xlib XSelectInput ( a n n -- void )
z" XDrawString" 7 xlib XDrawString ( a n n n n a n -- void )
z" XSetForeground" 3 xlib XSetForeground ( a a n -- void )
z" XSetBackground" 3 xlib XSetBackground ( a a n -- void )
z" XFillRectangle" 7 xlib XFillRectangle ( a n n n n n n -- void )
0 constant NULL
32 cells constant xevent-size

View File

@ -18,7 +18,35 @@ PointerMotionMask or
StructureNotifyMask or constant event-mask
display window event-mask XSelectInput drop
variable width
variable height
create event xevent-size allot
: de event xevent-size dump cr cr ;
: de event xevent-size
event c@ .
event c@ Expose = if =
width @ . height @ .
display gc black XSetForeground drop
display gc black XSetBackground drop
display window gc 0 0 width @ height @ XFillRectangle drop
display gc white XSetForeground drop
display gc white XSetBackground drop
display window gc 0 0 width @ 2/ height @ 2/ XFillRectangle drop
." Expose"
then
event c@ ButtonPress = if ." ButtonPress" then
event c@ ButtonRelease = if ." ButtonRelease" then
event c@ KeyPress = if ." KeyPress" then
event c@ KeyRelease = if ." KeyRelease" then
event c@ MotionNotify = if ." MotionNotify" then
event c@ DestroyNotify = if ." DestroyNotify" then
event c@ ConfigureNotify = if
event 3 16 * 8 + + l@ width !
event 3 16 * 12 + + l@ height !
width @ . height @ .
." ConfigureNotify"
then
event c@ MapNotify = if ." MapNotify" then
cr ;
: 1e display event XNextEvent drop de ;
: gg begin 1e again ;