home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
epmsmp.zip
/
SHOWATTR.E
< prev
next >
Wrap
Text File
|
1992-08-26
|
6KB
|
148 lines
; ShowAttr.e by Larry Margolis
; A routine to produce a summary of all attributes used in a file.
; The Comment field displays the following for the specified classes:
;
; Bookmark: Bookmark name, and (permanent) if it would be saved
; Color: Names of the foreground and background colors
; Font: Font name, size, and selector, separated by '.'
; Style: Style name
;
; In addition, font and color attributes which would not be saved as part of
; the EA EPM.ATTRIBUTES because they're considered part of the preceding
; style attribute have the name of the style prepended to the comment field.
compile if not defined(SMALL) -- Being compiled separately
include 'stdconst.e'
tryinclude 'MYCNF.E'
compile if not defined(NLS_LANGUAGE)
const NLS_LANGUAGE = 'ENGLISH'
compile endif
include NLS_LANGUAGE'.e'
defmain 'showattr'
compile endif
const
COLOR_CLASS = 1
BOOKMARK_CLASS = 13
STYLE_CLASS = 14
FONT_CLASS = 16
COLORS = 'Black Blue Green Cyan Red Magenta Brown light_Gray dark_Gray light_Blue light_Green light_Cyan light_Red light_Magenta Yellow White'
;; values = '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15'
defc showattributes, showattr =
universal EPM_utility_array_ID
universal app_hini
universal default_font
display -8
sayerror 'Working...' -- Might take a while...
display 8
getfileid start_fid
;; call psave_pos(savepos)
'xcom e /c .attrib'
if rc<>-282 then -- -282 = sayerror("New file")
sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
return
endif
.autosave = 0
getfileid attrib_fid
replaceline 'Attributes in' start_fid.filename, 1
insertline '', 2
insertline ' Class Value Push Offst Col Line Comments...', 3
insertline ' ===== ===== ===== ===== ===== ===== ===========', 4
attrib_fid.modify = 0
line=0; col=1; offst=0
style_line=0; style_col=0; style_offst=0; style_list=''; stylename = ''
do forever
class = 0 -- Find any class
attribute_action 1, class, offst, col, line, start_fid -- 1=FIND NEXT ATTR
if class=0 then leave; endif
query_attribute class, val, IsPush, offst, col, line, start_fid
l = line
comments = ''
class_type = ''
if class=BOOKMARK_CLASS then -- get name
do_array 3, EPM_utility_array_ID, 'bmi.'val, bmname -- Get the name
comments = bmname
if IsPush=4 then
comments = comments '(permanent)'
endif
class_type = 'Bookmark'
elseif class=COLOR_CLASS then
comments = word(colors, val//16+1) 'on' word(colors, val%16+1)
if line=style_line & col=style_col & (offst=style_offst+1 | offst=style_offst+2) then
comments = '(Style:' stylename')' comments
endif
class_type = 'Color'
compile if EVERSION >= 5.50
elseif class=FONT_CLASS then -- get font info
comments = queryfont(val)
parse value comments with fontname '.' fontsize '.' fontsel '.'
if fontsel then comments=comments '('font_attribs(fontsel)')'; endif
if line=style_line & col=style_col & offst=style_offst+1 then
comments = '(Style:' stylename')' comments
endif
class_type = 'Font'
compile endif
elseif class=STYLE_CLASS then -- get style info
do_array 3, EPM_utility_array_ID, 'si.'val, stylename -- Get the style name
style_line=line; style_col=col; style_offst=offst
comments = stylename
if val<256 & not pos(chr(val), style_list) then -- a style we haven't seen yet
if style_list='' then
insertline 'Styles used in' start_fid.filename, 1
insertline '', 2, attrib_fid
insertline '', 2, attrib_fid
endif
style_list = style_list || chr(val)
parse value queryprofile(app_hini, 'Style', stylename) with fontname '.' fontsize '.' fontsel '.' fg '.' bg
if fontsel then fontsel=fontsel'='font_attribs(fontsel); endif
insertline leftstr(stylename,20) 'font('fontname') size('fontsize') sel('fontsel') colors' word(colors, fg+1) 'on' word(colors, bg+1), 2+length(style_list), attrib_fid
endif -- new style
class_type = 'Style'
endif -- class=STYLE_CLASS
insertline leftstr(class_type, 8) rightstr(class,5) rightstr(val,5) rightstr(ispush,5) rightstr(offst,5) rightstr(col,5) rightstr(l,5)' 'comments, attrib_fid.last+1, attrib_fid
enddo
if attrib_fid.modify then
attrib_fid.filename = '.attrib'
attrib_fid.titletext = 'Attribute summary for' start_fid.filename
attrib_fid.modify = 0
'postme monofont'
else
'xcom quit'
sayerror 'No attributes found.'
endif
defproc font_attribs(attr)
attribs = ''
plus = ''
if attr // 2 then
attribs = 'Italic'
plus = ' + '
endif
if attr%2 - 2*(attr%4) then
attribs = attribs || plus || 'Underscore'
plus = ' + '
endif
if attr%4 - 2*(attr%8) then
attribs = attribs || plus || 'Negative'
plus = ' + '
endif
if attr%8 - 2*(attr%16) then
attribs = attribs || plus || 'Outline'
plus = ' + '
endif
if attr%16 - 2*(attr%32) then
attribs = attribs || plus || 'Strikeout'
plus = ' + '
endif
if attr%32 - 2*(attr%64) then
attribs = attribs || plus || 'Bold'
plus = ' + '
endif
if attr%64 then
attribs = attribs || plus || '(unknown selection(s))'
endif
return attribs