home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
epm603b.zip
/
EPMSMP.ZIP
/
COLORMAR.E
< prev
next >
Wrap
Text File
|
1992-08-26
|
2KB
|
66 lines
; COLORMARK.E - routine to color a marked region
;
; The following is set up to be a separate .ex file that you execute by
; typing its name on the EPM command line.
; Color a marked region in EPM, by Larry Margolis
defmain
argstring = upcase(arg(1))
parse value argstring with w1 rest
if w1 = '' | w1 = '?' then
sayerror 'colormark [foreground] [[ON] background] e.g., Colormark red on light cyan'
return
endif
mt = marktype()
if mt = '' then
sayerror -280 -- 'Text not marked.'
return
endif
fg = trunc(.textcolor//16)
bg = .textcolor%16
if w1 <> 'ON' then
fg = getcolor(argstring)
parse value argstring with w1 rest
if w1='ON' then argstring = rest; endif
else
argstring = rest
endif
if argstring <> '' then
bg = getcolor(argstring)
endif
attribute = bg * 16 + fg
; following from ProcessFontRequest in STDCTRL.E
getmark fstline, lstline, fstcol, lstcol, mkfileid
call attribute_on(1) -- Colors flag
if mt='BLOCK' then
do i = fstline to lstline
Insert_Attribute_Pair(1, attribute, i, i, fstcol, lstcol, mkfileid)
enddo
else
if mt='LINE' then
getline line, lstline, mkfileid
lstcol=length(line)
endif
Insert_Attribute_Pair(1, attribute, fstline, lstline, fstcol, lstcol, mkfileid)
endif
call attribute_on(8) -- "Save attributes" flag
const --wrd# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
colors = 'BLACK BLUE GREEN CYAN RED MAGENTA BROWN LIGHT_GREY DARK_GREY LIGHT_GRAY DARK_GRAY LIGHT_BLUE LIGHT_GREEN LIGHT_CYAN LIGHT_RED LIGHT_MAGENTA YELLOW LIGHT_BROWN WHITE'
values = '0 1 2 3 4 5 6 7 8 7 8 9 10 11 12 13 14 14 15'
defproc getcolor(var colorstring)
parse value colorstring with w1 colorstring
if w1 = 'LIGHT' | w1='DARK' then
parse value colorstring with c colorstring
w1 = w1'_'c
endif
p = wordpos(w1, colors)
if p then
return word(values, p)
endif
sayerror 'Invalid argument: 'w1
stop