xref: /freebsd/stand/forth/frames.4th (revision 26a58599a09a6181e0f5abe624021865a0c23186)
1ca987d46SWarner Losh\ Copyright (c) 2003 Scott Long <scottl@FreeBSD.org>
2ca987d46SWarner Losh\ Copyright (c) 2012-2015 Devin Teske <dteske@FreeBSD.org>
3ca987d46SWarner Losh\ All rights reserved.
4ca987d46SWarner Losh\
5ca987d46SWarner Losh\ Redistribution and use in source and binary forms, with or without
6ca987d46SWarner Losh\ modification, are permitted provided that the following conditions
7ca987d46SWarner Losh\ are met:
8ca987d46SWarner Losh\ 1. Redistributions of source code must retain the above copyright
9ca987d46SWarner Losh\    notice, this list of conditions and the following disclaimer.
10ca987d46SWarner Losh\ 2. Redistributions in binary form must reproduce the above copyright
11ca987d46SWarner Losh\    notice, this list of conditions and the following disclaimer in the
12ca987d46SWarner Losh\    documentation and/or other materials provided with the distribution.
13ca987d46SWarner Losh\
14ca987d46SWarner Losh\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15ca987d46SWarner Losh\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16ca987d46SWarner Losh\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17ca987d46SWarner Losh\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18ca987d46SWarner Losh\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19ca987d46SWarner Losh\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20ca987d46SWarner Losh\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21ca987d46SWarner Losh\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22ca987d46SWarner Losh\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23ca987d46SWarner Losh\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24ca987d46SWarner Losh\ SUCH DAMAGE.
25ca987d46SWarner Losh\
26ca987d46SWarner Losh
27ca987d46SWarner Loshmarker task-frames.4th
28ca987d46SWarner Losh
29ca987d46SWarner Loshvocabulary frame-drawing
30ca987d46SWarner Loshonly forth also frame-drawing definitions
31ca987d46SWarner Losh
32ca987d46SWarner Losh\ XXX Filled boxes are left as an exercise for the reader... ;-/
33ca987d46SWarner Losh
34ca987d46SWarner Loshvariable h_el
35ca987d46SWarner Loshvariable v_el
36ca987d46SWarner Loshvariable lt_el
37ca987d46SWarner Loshvariable lb_el
38ca987d46SWarner Loshvariable rt_el
39ca987d46SWarner Loshvariable rb_el
40ca987d46SWarner Loshvariable fill
41ca987d46SWarner Losh
42ca987d46SWarner Losh\ ASCII frames (used when serial console is detected)
43ca987d46SWarner Losh 45 constant ascii_dash
44ca987d46SWarner Losh 61 constant ascii_equal
45ca987d46SWarner Losh124 constant ascii_pipe
46ca987d46SWarner Losh 43 constant ascii_plus
47ca987d46SWarner Losh
48ca987d46SWarner Losh\ Single frames
4956758831SToomas Soome0x2500 constant sh_el
5056758831SToomas Soome0x2502 constant sv_el
5156758831SToomas Soome0x250c constant slt_el
5256758831SToomas Soome0x2514 constant slb_el
5356758831SToomas Soome0x2510 constant srt_el
5456758831SToomas Soome0x2518 constant srb_el
55ca987d46SWarner Losh\ Double frames
5656758831SToomas Soome0x2550 constant dh_el
5756758831SToomas Soome0x2551 constant dv_el
5856758831SToomas Soome0x2554 constant dlt_el
5956758831SToomas Soome0x255a constant dlb_el
6056758831SToomas Soome0x2557 constant drt_el
6156758831SToomas Soome0x255d constant drb_el
62ca987d46SWarner Losh\ Fillings
63ca987d46SWarner Losh0 constant fill_none
64ca987d46SWarner Losh32 constant fill_blank
6556758831SToomas Soome0x2591 constant fill_dark
6656758831SToomas Soome0x2592 constant fill_med
6756758831SToomas Soome0x2593 constant fill_bright
68ca987d46SWarner Losh
69ca987d46SWarner Loshonly forth definitions also frame-drawing
70ca987d46SWarner Losh
71ca987d46SWarner Losh: hline	( len x y -- )	\ Draw horizontal single line
72ca987d46SWarner Losh	at-xy		\ move cursor
73ca987d46SWarner Losh	0 do
7456758831SToomas Soome		h_el @ xemit
75ca987d46SWarner Losh	loop
76ca987d46SWarner Losh;
77ca987d46SWarner Losh
78ca987d46SWarner Losh: f_ascii ( -- )	( -- )	\ set frames to ascii
79ca987d46SWarner Losh	ascii_dash h_el !
80ca987d46SWarner Losh	ascii_pipe v_el !
81ca987d46SWarner Losh	ascii_plus lt_el !
82ca987d46SWarner Losh	ascii_plus lb_el !
83ca987d46SWarner Losh	ascii_plus rt_el !
84ca987d46SWarner Losh	ascii_plus rb_el !
85ca987d46SWarner Losh;
86ca987d46SWarner Losh
87ca987d46SWarner Losh: f_single	( -- )	\ set frames to single
88ca987d46SWarner Losh	boot_serial? if f_ascii exit then
89ca987d46SWarner Losh	sh_el h_el !
90ca987d46SWarner Losh	sv_el v_el !
91ca987d46SWarner Losh	slt_el lt_el !
92ca987d46SWarner Losh	slb_el lb_el !
93ca987d46SWarner Losh	srt_el rt_el !
94ca987d46SWarner Losh	srb_el rb_el !
95ca987d46SWarner Losh;
96ca987d46SWarner Losh
97ca987d46SWarner Losh: f_double	( -- )	\ set frames to double
98ca987d46SWarner Losh	boot_serial? if
99ca987d46SWarner Losh		f_ascii
100ca987d46SWarner Losh		ascii_equal h_el !
101ca987d46SWarner Losh		exit
102ca987d46SWarner Losh	then
103ca987d46SWarner Losh	dh_el h_el !
104ca987d46SWarner Losh	dv_el v_el !
105ca987d46SWarner Losh	dlt_el lt_el !
106ca987d46SWarner Losh	dlb_el lb_el !
107ca987d46SWarner Losh	drt_el rt_el !
108ca987d46SWarner Losh	drb_el rb_el !
109ca987d46SWarner Losh;
110ca987d46SWarner Losh
111ca987d46SWarner Losh: vline	( len x y -- )	\ Draw vertical single line
112ca987d46SWarner Losh	2dup 4 pick
113ca987d46SWarner Losh	0 do
114ca987d46SWarner Losh		at-xy
11556758831SToomas Soome		v_el @ xemit
116ca987d46SWarner Losh		1+
117ca987d46SWarner Losh		2dup
118ca987d46SWarner Losh	loop
119ca987d46SWarner Losh	2drop 2drop drop
120ca987d46SWarner Losh;
121ca987d46SWarner Losh
122ca987d46SWarner Losh: box	( w h x y -- )	\ Draw a box
123*3630506bSToomas Soome	framebuffer? if
124*3630506bSToomas Soome		s" term-drawrect" sfind if
125*3630506bSToomas Soome			>R
126*3630506bSToomas Soome			rot		( w x y h )
127*3630506bSToomas Soome			over + >R	( w x y -- R: y+h )
128*3630506bSToomas Soome			swap rot	( y x w -- R: y+h )
129*3630506bSToomas Soome			over + >R	( y x -- R: y+h x+w )
130*3630506bSToomas Soome			swap R> R> R> execute
131*3630506bSToomas Soome			exit
132*3630506bSToomas Soome		else
133*3630506bSToomas Soome			drop
134*3630506bSToomas Soome		then
135*3630506bSToomas Soome	then
136*3630506bSToomas Soome	\ Non-framebuffer version
137ca987d46SWarner Losh	2dup 1+ 4 pick 1- -rot
138ca987d46SWarner Losh	vline		\ Draw left vert line
139ca987d46SWarner Losh	2dup 1+ swap 5 pick + swap 4 pick 1- -rot
140ca987d46SWarner Losh	vline		\ Draw right vert line
141ca987d46SWarner Losh	2dup swap 1+ swap 5 pick 1- -rot
142ca987d46SWarner Losh	hline		\ Draw top horiz line
143ca987d46SWarner Losh	2dup swap 1+ swap 4 pick + 5 pick 1- -rot
144ca987d46SWarner Losh	hline		\ Draw bottom horiz line
14556758831SToomas Soome	2dup at-xy lt_el @ xemit	\ Draw left-top corner
14656758831SToomas Soome	2dup 4 pick + at-xy lb_el @ xemit	\ Draw left bottom corner
14756758831SToomas Soome	2dup swap 5 pick + swap at-xy rt_el @ xemit	\ Draw right top corner
14856758831SToomas Soome	2 pick + swap 3 pick + swap at-xy rb_el @ xemit
149ca987d46SWarner Losh	2drop
150ca987d46SWarner Losh;
151ca987d46SWarner Losh
152ca987d46SWarner Loshf_single
153ca987d46SWarner Loshfill_none fill !
154ca987d46SWarner Losh
155ca987d46SWarner Loshonly forth definitions
156