The only practical use I can think for it as it stands is for keeping
the contents of one window on screen by swapping to the other window and
continue working from there.
\ "swapper.of" 9-Dec-2010 -- intended as demonstration only.
\
\ divides Open Firmware framebuffer text-screen vertically into two
\ full-width borderless windows. Written & tested under dflt fb8 pkg.
\
\ Specify new (2nd) window's vertical start-locations and bg color
\ 0 CONSTANT window1 ( literal 0 used below for top screen line )
032 CONSTANT window2 ( example value used for this demo )
window2 3 #lines 2- between not ( minimum 2 lines for smaller window)
abort" window2 off screen or not big enough: edit 'window2' in src"
( commands employing 'exit?' need > 2 lines to work correctly )
0b ( cyan ) CONSTANT window2-color
\ Derive non-overlapping window dimensions ("lines" = lines of text)
window2 1- CONSTANT title-bar
alias window1-#lines title-bar
1 CONSTANT title-bar-#lines
#lines window1-#lines title-bar-#lines + - CONSTANT window2-#lines
\ save original text-screen's state-values
0 to column#
create save-vector 44 allot
my-vector save-vector 44 move
\ This next section is not needed by all versions of Macintosh Open
\ Firmware. If demo works, try it again with this section removed
%r25 %r28 DO \ search fcode table
i @ 10 - @ 0a6d6f76 ( 0a"mov" ) = IF \ quick-find probable match
i @ 0f - " move-lines" comp \ verify match
0= IF ( found )
" move-lines" i @ (is-user-word) LEAVE \ dictionary alias
THEN
THEN
i %r25 4- = IF
." Installation failed: essential resource not located"
\ compile will terminate with "move-lines not found"
THEN
4 +LOOP
%r25 %r28 DO \ search fcode table
i @ 10 - @ 0b657261 ( 0b"era" ) = IF \ quick-find probable match
i @ 0f - " erase-lines" comp \ verify match
0= IF ( found )
" erase-lines" i @ (is-user-word) LEAVE \ dictionary alias
THEN
THEN
i %r25 4- = IF
." Installation failed: essential resource not located"
\ compile will terminate with "erase-lines not found"
THEN
4 +LOOP
\ scroll full-screen text up to window1's bottom line if overlap
cr \ delete this line if junk appends to every line (some vers only)
line# window1-#lines >= IF
line# title-bar 1- - 0 window1-#lines move-lines
window1-#lines 1- to line#
THEN
\ Clear space for new window using new window's background color
background-color \ save on stack
window2-color to background-color
window2 window2-#lines erase-lines
to background-color \ restore
\
\ reduce original full-screen terminal emulation to window1 dimensions
( needs to be done here as some vers of rom erase all below cursor )
window1-#lines to #lines
window1-#lines 1- line# min to line#
#lines to lines/page
\ copy a my-vector member value to same-named offset at another vector
( Note reversal of direction: vector is vectored via offset )
: via ( n vector -- ) \ usage: <n> <vector> via vectored-value !
' 8 + @ +
;
\ Clone & modify fb state variables for temp one-line title-bar window
create title-bar-vector 44 allot
my-vector title-bar-vector 44 move
title-bar char-height * window-top + title-bar-vector via window-top !
title-bar-#lines title-bar-vector via #lines !
title-bar-#lines 1- title-bar-vector via line# !
\ Clone & modify a set of fb state variables for 2nd (bottom) window
create alt-vector 44 allot
my-vector alt-vector 44 move
window2-color alt-vector via background-color !
window2 char-height * window-top + alt-vector via window-top !
window2-#lines alt-vector via #lines !
create temp-vector 44 allot
: other-window \ toggle i/o between the two potentially active windows
my-vector temp-vector 44 move
alt-vector my-vector 44 move
temp-vector alt-vector 44 move
#lines to lines/page
;
: kill-windows
['] window-top 8 + @ \ get vectored value's offset
dup my-vector + @ swap save-vector + @ <> IF
other-window \ ensure current window = window1
THEN
line#
save-vector my-vector 44 move \ restore full-screen window
to line#
line# 1+ #lines 1- line# - erase-lines \ clear screen below cursor
cr ( this cr will clear scrn below cursor for some versions of rom)
#lines to lines/page
;
\ To clean up thoroughly, also 'forget window2' at prompt. However
\ that would also forget any extra words defined via either window.
\ Title Bar treated as a window for initialization purposes only
my-vector temp-vector 44 move
title-bar-vector my-vector 44 move
\ User instructions (text for adding to title bar):
" 'other-window' toggles between windows, 'kill-windows' ends demo "
\ extra cosmetics give title bar the appearance of a window tab:
background-color -rot \ save on stack
#columns 0f - over - spaces \ right-justify text+rhs margin
window2-color to background-color type \ print text in window2 color
to background-color 0f 1- spaces \ render rhs margin in window1 color
temp-vector my-vector 44 move
\ Final init 2nd window: home its cursor without displaying prompt
other-window \ window2
0 to line#
other-window \ exit to original prompt in window1
\
\ user can now swap between & issue forth commands from either window
\