\ MINOS descriptor classes
: .d base @ >r decimal '#' emit dup 0< IF '-' emit THEN abs . r> base ! ;
descriptor class descriptors
public:
ptr next
cell var content
cell var name
cell var number
method find-object
method find-name
method set-name
method dump-name
method dump-class
method dump-ptr
method create-ptr
class;
descriptors ptr cur-descs
descriptors ptr all-descs
descriptors implements
: init ( class1 .. classn n -- )
s" " name $!
dup 1+ cells content Handle!
dup content @ !
0 ?DO I' I - cells content @ + ! LOOP ;
: delete-desc ( -- )
cur-descs self ^ = IF 0 F bind cur-descs THEN
F link all-descs
BEGIN dup @ >o next self self o> <> WHILE
dup @ ^ = IF next self swap ! EXIT THEN
@ >o link next o> REPEAT drop ;
: dispose ( -- ) delete-desc
content HandleOff name HandleOff super dispose ;
: assign ( o -- )
dup bind item
content @ @ 1+ 1 ?DO dup content @ Ith
descriptor with bind item endwith LOOP drop
item self 0 update-linker ;
: null ( -- null1 .. nulln )
content @ @ 1+ 1 ?DO content @ Ith
descriptor with null endwith LOOP ;
: make ( -- make1 .. maken )
content @ @ 1+ 1 ?DO content @ Ith
descriptor with make endwith LOOP ;
: rightcase ( addr1 u1 -- addr2 u2 )
scratch place
0 scratch count bounds ?DO
IF I c@ dup tolower dup I c! <>
ELSE true THEN
LOOP drop scratch count 2dup + >r s" name:" tuck r> swap move + ;
: edit-field ( -- o )
name $@ 0 ST[ text@ >current-name ]ST
item self >class" rightcase
infotextfield new dup F bind name-string
content @ @ 1+ 1 ?DO content @ Ith
descriptor with edit-field endwith LOOP
content @ @ 1+ vabox new panel ;
: dump ( -- ) cr indent @ spaces
content @ @ 1+ 1 ?DO content @ Ith
descriptor with dump endwith LOOP
item self >class" lctype
." new " name $@ nip IF ." ^^bind " dump-name THEN
content @ @ 1+ 1 ?DO content @ Ith
descriptor with post-dump endwith LOOP ;
: find-object ( o -- desc-o )
next self self = IF drop 0 EXIT THEN
dup item self = IF drop self EXIT THEN
next goto find-object ;
: find-name ( addr u -- desc-o )
next self self = IF drop 0 EXIT THEN
2dup name $@ compare 0= IF 2drop self EXIT THEN
next goto find-name ;
: set-name ( addr u -- ) name $! ;
: dump-name ( -- )
name $@ nip IF
name $@ type
ELSE
set-var @ IF nvar @ number ! 1 nvar +! THEN
." (" item self >class" lctype ." -" number @ 0
<<# # # #> type #>> ." )"
THEN ;
: dump-class ( -- )
item self >class" lctype ;
: dump-ptr ( -- )
name $@ nip 0= ?EXIT \ IF ." | " THEN
cr indent @ spaces
dump-class ." ptr " dump-name ;
: create-ptr ( -- )
name $@ nip IF
name $@ [: item ptr >in off
item self F postpone bind ;] execute-parsing
THEN ;
class;
Variable tmp-contents
descriptors class font-descriptors
public:
font ptr fnt
method font!
window ptr chooser
how:
: font! ( font -- ) bind fnt
fnt self item font!
item self widget with dpy self endwith
IF item resized THEN ;
: dump ( -- ) super dump
fnt self 0= ?EXIT
fnt with X-font name-string endwith $@
dup IF .' font" ' type .' "' ELSE 2drop THEN ;
: font-selector ( -- )
fnt self IF fnt with X-font name-string endwith $@
ELSE s" " THEN
0 ST[ text@ tmp-contents $! ]ST
s" Font:" infotextfield new
0 1 *fill *hglue new
^ S[ tmp-contents $@ nip fnt self 0= and
IF tmp-contents $@ X-font new bind fnt
ELSE tmp-contents $@ fnt assign THEN
fnt self font! chooser close ]S s" OK " button new
^ S[ chooser close ]S s" Cancel" button new
^ S[ 0" xfontsel &" [ also DOS ] system [ previous ] drop ]S
s" xfontsel" button new
0 1 *fill *hglue new
5 hatbox new hskip
2 vabox new panel
screen self window new window with
s" Font Selection" assign show ^
endwith bind chooser ;
: edit-field ( -- o )
name $@ 0 ST[ text@ >current-name ]ST
item self >class" rightcase infotextfield new dup
^ S[ font-selector ]S s" Change Font" button new 1 habox new hfixbox
2 habox new hskip
swap F bind name-string
content @ @ 1+ 1 ?DO content @ Ith
descriptor with edit-field endwith LOOP
content @ @ 1+ vabox new panel ;
class;
font-descriptors class referred-descs
how:
: dump-ptr ( -- )
cr indent @ spaces
name $@ nip 0= IF ." | " THEN
dump-class ." ptr " dump-name ;
: dump ( -- ) cr indent @ spaces
content @ @ 1+ 1 ?DO content @ Ith
descriptor with dump endwith LOOP
item self >class" lctype
." new ^^bind " dump-name
content @ @ 1+ 1 ?DO content @ Ith
descriptor with post-dump endwith LOOP
fnt self 0= ?EXIT
.' font" ' fnt with X-font name-string endwith $@ type .' "' ;
class;
: >current-name cur-descs set-name ;
descriptor class tri-des
public:
cell var content
how:
: init ( -- ) 0 assign ;
: assign ( n -- ) content !
item self 0= ?EXIT
DELAY get item assign item draw changed ;
: get ( -- n ) content @ ;
: edit-field ( -- )
^ TN[ 0 content ]T[ content @ assign ]TN S" Left" rbutton new
^ TN[ 1 content ]T[ content @ assign ]TN S" Up" rbutton new
^ TN[ 3 content ]T[ content @ assign ]TN S" Down" rbutton new
^ TN[ 2 content ]T[ content @ assign ]TN S" Right" rbutton new
$0 $1 *hfill $0 $1 *vfil glue new
#5 harbox new hskip ;
: null ( -- 0 ) 0 ;
: make ( -- n ) get ;
: dump ( -- ) get
:left case? IF ." :left " EXIT THEN
:up case? IF ." :up " EXIT THEN
:down case? IF ." :down " EXIT THEN
:right case? IF ." :right " EXIT THEN .d ." TRI: " ;
class;
descriptor class string-des
public:
cell var content
how:
: init ( -- ) s" String" assign ;
: dispose ( -- ) content HandleOff super dispose ;
: assign ( addr n -- ) content $!
item self 0= ?EXIT
DELAY get item text! item resized changed ;
: get ( -- addr n ) content $@ ;
: edit-field ( -- o ) ^ F cur bind string
get 0 ST[ text@ pad place pad count cur string assign ]ST
s" String:" infotextfield new
dup F bind edit-string ;
: null ( -- addr u ) s" String" ;
: make ( -- addr u ) get ;
: dump ( -- ) .' X" ' get type .' " ' ;
class;
string-des class text-des
how:
: init ( -- ) s" Text" assign ;
: edit-field ( -- o ) ^ F cur bind text
get 0 ST[ text@ pad place pad count cur text assign ]ST
s" Text" infotextfield new
;
: assign ( addr n -- ) content $!
item self 0= ?EXIT
DELAY get item assign item resized changed ;
: null ( -- addr u ) s" Text" ;
: dump ( -- ) .' T" ' get type .' " ' ;
class;
string-des class menu-des
how:
: init ( -- ) s"