// com.sr
// Carol Hankins
// April 8, 1976
get "ALTOFILESYS.D"
get "bravo1.df"
get "com.df"
get "rn1.df"
get "char.df"
get "select.df"
get "display.df"
get "font.df"
get "DOC.df"
get "OM.df"
// incoming procedures
external
[
MyFrame
updatedisplay
updateunderline
underline
select
move
getvp
GetSi
activateomseq
deactivateomseq
SetRegionW
SetRegionA
SetRegionSys
bravochar
updatefdd
setupdate
invalidatewindow
updatewindow
inserttx
MakeCurrentBuf
tsmode
selectwholedoc
stcopy
stappend
stnum
endofkeystream
ugt
finddl
mpDlDld
MapRi
backdylines
BufToRi
CreateSbEff
CreateSbAl
CbpDirty;
flushvm;
MoveWwSys;
]
// incoming statics
external
[
vcinorepeat
vvpampchci
vrldsys
vrlwsys
cominstream
selmain
selarg
selaux
vframe
tscorrect
tstoflush
vfddfaulted
mpWwWwd
macww
vdcborig
vdcbblack
dcb
vrgridpast2
vcridpast2
mpfunfd
rgmaccp
rgpctb
rgyfirst
vfcpFDisplSys
vcp
vfddfirst
tsread
mpmnom
vfRemove
]
// outgoing procedures
external
[
CommandProcessor
confirm
blinkscreen;
extend
buffer
AbNoRepUndo
SetVab
]
// outgoing statics
external
[
vdcb
vdcblink
doctxtemp
vesccom
chcom
comno;
vmeasurestatus;
quitchar;
doctxcurrent;
vundocom
vab
frameCom
labelFaultStor
vcRiW
]
// local statics
static
[
vdcb
vdcblink
doctxtemp
vesccom
chcom
comno;
vmeasurestatus;
quitchar;
doctxcurrent;
vundocom
vab
frameCom
labelFaultStor
vcRiW// count of available ris in vrlwsys
]
let CommandProcessor() be
[
let ci, cs, tch, ab = nil, nil, nil, nil
let cd = vec lcdmax
let cdlast = vec lcdmax
let cf = vec lcfmax
cf >> CF.chcom = 0
let mpchci = vec chmax
let wwdsys = mpWwWwd!0
comno = 16
chcom = 256
frameCom = MyFrame()
while true do
[ if CbpDirty() gr 4 then
flushvm();
underline(uloff, selarg)
underline(ulmode1, selmain)
updateunderline()
labelFaultStor = lfaultStor
SetRegionSys(risyscom, nriready)
SetRegionSys(risysstate, nrisel)
goto lskipKludge
lfaultStor:unless tsread then
until endofkeystream() do bravochar()
blinkscreen()
vdcb>>DCB.next= vdcblink
SetRegionSys(risyspast, riFaultStor)
SetRegionSys(risyscom, 229)
SetRegionSys(risysstate, 230)
lskipKludge:
// **** replaced by ValidateDisplay
// update any empty windows
//for iww= 0 to macww-1 do
//[
//if (mpWwWwd!iww)>>WWD.dlLast eq
// (mpWwWwd!iww)>>WWD.dlFirst - 1 then
// [ deactivateomseq("", 0); updatewindow(iww)]
//]
//waitthings()
// ****
let tcrefOmReplay = (mpmnom ! ($Y-$A))>>OM.cref;
test tsread ifso
[ if (tcrefOmReplay eq 0) then
activateomseq("Y",0,0)
]
ifnot[ if (tcrefOmReplay gr 0) then
deactivateomseq("Y","Y");
]
unless vfcpFDisplSys do wwdsys>>WWD.cpFDispl= 0
setupdate(wwsys)
updatedisplay()
vesccom = false
vundocom = false
tscorrect = false
move(cd, cdlast, lcdmax)
for i = 0 to lcdmax do cd!i = 0
mpchci = getvp(vvpampchci)
[
tsmode()
select(selmain, 0)
cf>>CF.sel = selmain
cf>>CF.selarg = selarg
tstoflush = 0
tch = bravochar()
// if tch eq #36 then
// [ let tyd = YdFind(selmain >> SEL.ww, selmain >> SEL.cpfirst)
// finddl(selmain >> SEL.ww, selmain >> SEL.cpfirst)
// if tyd ne -1 then
// [ @xbugloc = #30
// @ybugloc = tyd
// ]
// loop
// ]
if tch ne chdel then break
RestoreSysWw()
] repeat
// make sure selections not in system window
if (selmain>>SEL.ww eq wwsys) then
[
SetRegionSys(risyspast, 40, 50)// no sel in sys ww
blinkscreen()
loop
]
unless vfcpFDisplSys do wwdsys>>WWD.cpFDispl = 0
setupdate(wwsys)
updatedisplay()
if tch ge $A & tch le $Z then tch = tch+#40
if tch eq ($z+#200) then tch = ctrlz
// cf>>CF.chcom had actual character typed.
cf>>CF.frepeat = false
cf>>CF.fRestoreSysWw = false
switchon tch into
[
case chesc:if cf >> CF.chcom eq 0 then
[
IllCom(tch)
loop;
]
move(cdlast, cd, lcdmax)
tch = cf>>CF.chcom
vesccom = true
test cdlast>>CD.fokrepeat ifso
[
cf>>CF.frepeat = true
ci = cinil
]
ifnot[ cf >> CF.w0 = cdlast
AbNoRepUndo(cf, true)
loop
]
endcase
case $u:
case $U:if cf >> CF.chcom eq 0 then
[
IllCom(tch)
loop;
]
vundocom = true
move(cdlast, cd, lcdmax)
test cdlast>>CD.fokundo ifso
[
if cdlast>>CD.fselundo then
move(selaux, cf>>CF.sel, sell)
tch = cdlast>>CD.chundo
mpchci = getvp(vvpampchci)
ci = mpchci!tch
]
ifnot[ cf >> CF.w0 = cdlast
AbNoRepUndo(cf, false)
loop
]
endcase
default:mpchci = getvp(vvpampchci)
ci = mpchci!tch
if ci eq cinil do
[
IllCom(tch)
loop;
]
]
cf>>CF.chcom = tch
chcom = tch
cf>>CF.ci = ci
unless ci eq cinil do GetSi(cd, ci, lcdmax)
if cd>>CD.fRestoreSysWw then RestoreSysWw();
// set up system window
SetRegionSys(risyscom, cd>>CD.ricom)
SetRegionSys(risysstate, cd>>CD.ristate)
SetRegionSys(risyspast, cd>>CD.ripast)
SetRegionSys(risyspast2, rinil)// clear this
underline(uloff, selmain)
updateunderline()
wwdsys>>WWD.cpFDispl = 0
setupdate(wwsys)
updatedisplay()
cs = lv cd>>CD.acsfirst
if cd >> CD.fOrderedOvs then
deactivateomseq("", 0)
vcridpast2 = 0
vfcpFDisplSys = false
while (rv cs) ne acsnil do
[
vab = abnil
vcRiW = 2
if cs>>CS.asbact ne 0 then
activateomseq(lv cs>>CS.asbact, 0, cs>>CS.cwarray)
ab = (rv cs>>CS.pAbProc) (cf)
if cs>>CS.asbact ne 0 then
deactivateomseq(lv cs>>CS.asbact,
cs+cs>>CS.bsbdeact)
if vab ne abnil then ab = vab
if ab eq abcomplete % ab eq abmsg then break
if ab ne abnil then
[
SetRegionA(vrldsys, risyspast, ab<<AB.crid,
(lv (cs+cs>>CS.brgrid)!(ab<<AB.nrid)) )
break
]
cs = cs + cs>>CS.lcsmac
]
if cf>>CF.fRestoreSysWw then RestoreSysWw();
// "Last command was "
if ab eq abQuit then break
if (ab eq abnil % ab eq abcomplete) & ab ne abmsg then
SetRegionSys(risyspast, nrilcw, cd>>CD.ricom)
if vfcpFDisplSys then
[ let tfn, tcp, tdcp = nil, nil, nil
MapRi(vrldsys, BufToRi(1)-1, lv tfn, lv tcp, lv tdcp)
backdylines(wwsys, tcp, 0)
(mpWwWwd!wwsys)>>WWD.cpFDispl = vcp
]
updatedisplay()
CkCpOflow()
if vcridpast2 then InterpretRgrid()
]
]
and confirm(sb) = valof
[
let trid = nil
SetRegionW(vrlwsys, 0, sb)
trid<<RID.nrl = 1;trid<<RID.ri = 0
SetRegionSys(risysstate, 124, trid)// Type CR to confirm
updatedisplay()
let tchar = bravochar(cominstream)
if tchar eq chcr then resultis true
resultis false
]
// **** replaced by ValidateDisplay
// W A I T T H I N G S
//
// and waitthings() be
// [ if vfddfaulted then
//[ underline(uloff, selmain)
//updateunderline()
//updatefdd(false);
//for ww = 0 to macww-1 do
//invalidatewindow(ww)
//updatedisplay()
//underline(ulmode1, selmain)
//]
// ]
// ****
// B L I N K S C R E E N
//
and blinkscreen() be
[ rv vdcborig = vdcbblack;
let i = 0;
[ i = i+1 ] repeatuntil i eq #40000;
rv vdcborig = dcb;
]
and extend(cf) = valof
[
selectwholedoc(cf>>CF.sel, (cf>>CF.sel)>>SEL.doc)
resultis abnil
]
and buffer(cf) = valof
[
let tch = bravochar()
SetRegionSys(risysstate, 143) // type or sel buffer contents
unless tch le $3 & tch ge $1 then
[
let ab = nil
ab<<AB.crid = 2
ab<<AB.nrid = 0
resultis ab// illegal buffer number
]
let txno = tch - $0
MakeCurrentBuf(txno)
updatedisplay()
inserttx(txno)
resultis abnil
]
and AbNoRepUndo(cf, fRep) = valof
[ let tri = fRep ? 41, 42
let cd = cf >> CF.w0
SetRegionSys(risyspast, tri, cd >> CD.ricom)
updatedisplay()
]
// S E T V A B
and SetVab(ab, mty, ridFirst, nil, nil, nil, nil, nil, nil; numargs na) be
[ if na eq 1 then mty = mtyCond
if mty eq mtyCond & vab ne abnil return
test mty eq mtyAnc & ab eq abmsg ifso
[ blinkscreen()
if vcridpast2+na-2 ls cridMax then
for trid = 0 to na -3 do
[
vrgridpast2 ! vcridpast2 = (lv ridFirst) ! trid
vcridpast2 = vcridpast2 + 1
]
]
ifnot [
if ab eq abmsg then SetRegionA(vrldsys, risyspast, na-2, lv ridFirst)
vab = ab
]
] // end SetVab
and InterpretRgrid() be
[
if vcridpast2 eq 0 then return
let rid, fd, fun, fa, fdh = nil, nil, nil, nil, nil
let tsb = vec 40; let tnum = vec 10
for trid = 0 to vcridpast2-1 do
[
rid = (vrgridpast2 ! trid)
if rid<<RID.nrl le nrlMac do loop
// got a hot one!
activateomseq("S")
test rid<<RID.al ifnot
[
CreateSbEff(tsb, rid<<RID.fun, rid<<RID.fa)
//let fun = rid<<RID.fun
//test fun ls maxfun ifso
//[
//fd = mpfunfd ! fun
//fdh = (lv (fd>>FD.rvrgfdd)) + (fd>>FD.maxmagi)
//stcopy(tsb, lv (fdh>>FDH.rvsbname) )
//stnum(tnum, fdh>>FDH.height)
//stappend(tsb, tnum)
//fa = rid<<RID.fa
//if fa<<FACE.bold then stappend(tsb, "B")
//if fa<<FACE.italic then stappend(tsb, "I")
//stappend(tsb, ".ep")
//]
//ifnot[
//stcopy(tsb, selecton fun into
//[
//case maxfun:
//"HELVETICA10B.EP"
//case maxfun+1:
//"BORDER20.EP"
//case maxfun+2:
//"KEYHOLE20.EP"
//])
//]
]
ifso[
let ifdd = rid >> RID.fun
let tfdd = vfddfirst
for i = 1 to ifdd do
tfdd = tfdd >> FDD.fddnext
CreateSbAl(tsb, tfdd)
//stcopy(tsb, lv tfdd>>FDD.rvsbname)
//stnum(tnum, tfdd>>FDD.height)
//stappend(tsb, tnum)
//stappend(tsb, ".al")
]
deactivateomseq("S", "S")
SetRegionW(vrlwsys, vcRiW, tsb)
rid<<RID.nrl = 1
rid<<RID.ri = vcRiW
vrgridpast2 ! trid = rid
vcRiW = vcRiW + 1
]
SetRegionA(vrldsys, risyspast2, vcridpast2, vrgridpast2)
updatedisplay()
]
// C K C P O F L O W
//
and CkCpOflow() be
[ for doc = 0 to maxdoc-1 do
[ if rgpctb ! doc eq -1 then loop
if ugt(rgmaccp ! doc, #166000) then
[ underline(uloff, selmain)
updateunderline()
selectwholedoc(selmain, doc)
underline(ulmode1, selmain)
SetVab(abmsg, mtyAnc, 228)
]
]
]
// I L L C O M
//
and IllCom(ch) be
[ if (ch eq #34) % (vfRemove eq false) then
ToggleSysWw();
if ch ne #34 then
[ blinkscreen()
SetRegionSys(risyspast, 26)
updatedisplay()
while bravochar() ne chdel do
loop
SetRegionSys(risyspast, 15)
]
]
// R E S T O R E S Y S W W
//
and RestoreSysWw() be
[ if (vfRemove eq false) then
ToggleSysWw();
];
// T O G G L E S Y S W W
//
and ToggleSysWw() be
[ activateomseq("BO",0,maxcdcb*dcbl+50)
MoveWwSys()
deactivateomseq("BO","BO");
]
// F I N D Y D
//
// and YdFind(ww, cp) = valof
// [ let dl = finddl(ww, cp)
// if dl eq -1 then resultis -1
// let dlFirst = (mpWwWwd ! ww) >> WWD.dlFirst
// let tyd = rgyfirst ! ww
// let dld = mpDlDld(dlFirst)
// for tdl = dlFirst to dl-1 do
// [ tyd = tyd+dld >> DLD.dYdBm+dld >> DLD.ld
// dld = dld+lDld
// ]
// resultis tyd
// ]