1 | /****************************** Module Header *******************************
|
---|
2 | *
|
---|
3 | * Module Name: showattr.e
|
---|
4 | *
|
---|
5 | * Copyright (c) Netlabs EPM Distribution Project 2020
|
---|
6 | *
|
---|
7 | * $Id: showattr.e 4251 2020-10-28 11:46:14Z aschn $
|
---|
8 | *
|
---|
9 | * ===========================================================================
|
---|
10 | *
|
---|
11 | * This file is part of the Netlabs EPM Distribution package and is free
|
---|
12 | * software. You can redistribute it and/or modify it under the terms of the
|
---|
13 | * GNU General Public License as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * Netlabs EPM Distribution. This library is distributed in the hope that it
|
---|
16 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
---|
17 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
18 | * General Public License for more details.
|
---|
19 | *
|
---|
20 | ****************************************************************************/
|
---|
21 |
|
---|
22 | ; ShowAttr.e by Larry Margolis
|
---|
23 | ; A routine to produce a summary of all attributes used in a file.
|
---|
24 | ; The Comment field displays the following for the specified classes:
|
---|
25 | ;
|
---|
26 | ; Bookmark: Bookmark name, and (permanent) if it would be saved
|
---|
27 | ; Color: Names of the foreground and background colors
|
---|
28 | ; Font: Font name, size, and selector, separated by '.'
|
---|
29 | ; Style: Style name
|
---|
30 | ;
|
---|
31 | ; In addition, font and color attributes which would not be saved as part of
|
---|
32 | ; the EA EPM.ATTRIBUTES because they're considered part of the preceding
|
---|
33 | ; style attribute have the name of the style prepended to the comment field.
|
---|
34 |
|
---|
35 | compile if not defined( SMALL) -- Being compiled separately
|
---|
36 | include 'stdconst.e'
|
---|
37 | tryinclude 'MYCNF.E'
|
---|
38 | compile if not defined( NLS_LANGUAGE)
|
---|
39 | const NLS_LANGUAGE = 'ENGLISH'
|
---|
40 | compile endif
|
---|
41 | include NLS_LANGUAGE'.e'
|
---|
42 |
|
---|
43 | defmain 'showattr'
|
---|
44 |
|
---|
45 | compile endif
|
---|
46 |
|
---|
47 | const
|
---|
48 | COLOR_CLASS = 1
|
---|
49 | BOOKMARK_CLASS = 13
|
---|
50 | STYLE_CLASS = 14
|
---|
51 | FONT_CLASS = 16
|
---|
52 | COLORS = 'Black Blue Green Cyan Red Magenta Brown light_Gray dark_Gray light_Blue light_Green light_Cyan light_Red light_Magenta Yellow White'
|
---|
53 | ;; values = '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15'
|
---|
54 |
|
---|
55 | defc showattributes, showattr
|
---|
56 | universal EPM_utility_array_ID
|
---|
57 | universal app_hini
|
---|
58 | universal default_font
|
---|
59 |
|
---|
60 | display -8
|
---|
61 | sayerror 'Working...' -- Might take a while...
|
---|
62 | display 8
|
---|
63 |
|
---|
64 | getfileid start_fid
|
---|
65 | ;; call psave_pos(savepos)
|
---|
66 |
|
---|
67 | 'xcom e /c .attrib'
|
---|
68 | if rc <> -282 then -- -282 = sayerror("New file")
|
---|
69 | sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext( rc)
|
---|
70 | return
|
---|
71 | endif
|
---|
72 | .autosave = 0
|
---|
73 | getfileid attrib_fid
|
---|
74 |
|
---|
75 | replaceline 'Attributes in' start_fid.filename, 1
|
---|
76 | insertline '', 2
|
---|
77 | insertline ' Class Value Push Offst Col Line Comments...', 3
|
---|
78 | insertline ' ===== ===== ===== ===== ===== ===== ===========', 4
|
---|
79 | attrib_fid.modify = 0
|
---|
80 |
|
---|
81 | line = 0
|
---|
82 | col = 1
|
---|
83 | offst = 0
|
---|
84 | style_line = 0
|
---|
85 | style_col = 0
|
---|
86 | style_offst = 0
|
---|
87 | style_list = ''
|
---|
88 | stylename = ''
|
---|
89 | do forever
|
---|
90 | class = 0 -- Find any class
|
---|
91 | attribute_action 1, class, offst, col, line, start_fid -- 1 = FIND NEXT ATTR
|
---|
92 | if class = 0 then
|
---|
93 | leave
|
---|
94 | endif
|
---|
95 | query_attribute class, val, IsPush, offst, col, line, start_fid
|
---|
96 | l = line
|
---|
97 | comments = ''
|
---|
98 | class_type = ''
|
---|
99 |
|
---|
100 | if class = BOOKMARK_CLASS then -- get name
|
---|
101 | do_array 3, EPM_utility_array_ID, 'bmi.'val, bmname -- Get the name
|
---|
102 | comments = bmname
|
---|
103 | if IsPush = 4 then
|
---|
104 | comments = comments '(permanent)'
|
---|
105 | endif
|
---|
106 | class_type = 'Bookmark'
|
---|
107 |
|
---|
108 | elseif class = COLOR_CLASS then
|
---|
109 | comments = word( colors, val // 16 + 1) 'on' word( colors, val % 16 + 1)
|
---|
110 | if line = style_line & col = style_col &
|
---|
111 | (offst = style_offst + 1 | offst = style_offst + 2) then
|
---|
112 | comments = '(Style:' stylename')' comments
|
---|
113 | endif
|
---|
114 | class_type = 'Color'
|
---|
115 |
|
---|
116 | elseif class = FONT_CLASS then -- get font info
|
---|
117 | comments = queryfont( val)
|
---|
118 | parse value comments with fontname '.' fontsize '.' fontsel '.'
|
---|
119 | if fontsel then
|
---|
120 | comments = comments '('font_attribs( fontsel)')'
|
---|
121 | endif
|
---|
122 | if line=style_line & col=style_col & offst=style_offst+1 then
|
---|
123 | comments = '(Style:' stylename')' comments
|
---|
124 | endif
|
---|
125 | class_type = 'Font'
|
---|
126 |
|
---|
127 | elseif class = STYLE_CLASS then -- get style info
|
---|
128 | do_array 3, EPM_utility_array_ID, 'si.'val, stylename -- Get the style name
|
---|
129 | style_line = line
|
---|
130 | style_col = col
|
---|
131 | style_offst = offst
|
---|
132 | comments = stylename
|
---|
133 | if val < 256 & not pos( chr( val), style_list) then -- a style we haven't seen yet
|
---|
134 | if style_list = '' then
|
---|
135 | insertline 'Styles used in' start_fid.filename, 1
|
---|
136 | insertline '', 2, attrib_fid
|
---|
137 | insertline '', 2, attrib_fid
|
---|
138 | endif
|
---|
139 | style_list = style_list''chr( val)
|
---|
140 | parse value queryprofile( app_hini, 'Style', stylename) with fontname '.' fontsize '.' fontsel '.' fg '.' bg
|
---|
141 | if fontsel then
|
---|
142 | fontsel = fontsel'='font_attribs( fontsel)
|
---|
143 | endif
|
---|
144 | insertline leftstr( stylename, 20) 'font('fontname') size('fontsize')' ||
|
---|
145 | ' sel('fontsel') colors' word( colors, fg + 1) 'on' word( colors, bg + 1),
|
---|
146 | 2 + length( style_list), attrib_fid
|
---|
147 | endif -- new style
|
---|
148 | class_type = 'Style'
|
---|
149 | endif -- class = STYLE_CLASS
|
---|
150 | insertline leftstr( class_type, 8) rightstr( class, 5) ||
|
---|
151 | ' 'rightstr( val, 5) rightstr( ispush, 5) rightstr( offst, 5) ||
|
---|
152 | ' 'rightstr( col, 5) rightstr( l, 5)' 'comments,
|
---|
153 | attrib_fid.last + 1, attrib_fid
|
---|
154 | enddo
|
---|
155 | if attrib_fid.modify then
|
---|
156 | attrib_fid.filename = '.attrib'
|
---|
157 | attrib_fid.titletext = 'Attribute summary for' start_fid.filename
|
---|
158 | attrib_fid.modify = 0
|
---|
159 | call InitFirstFid( attrib_fid)
|
---|
160 | 'postme monofont'
|
---|
161 | else
|
---|
162 | 'xcom quit'
|
---|
163 | sayerror 'No attributes found.'
|
---|
164 | endif
|
---|
165 |
|
---|
166 | defproc font_attribs(attr)
|
---|
167 | attribs = ''
|
---|
168 | plus = ''
|
---|
169 | if attr // 2 then
|
---|
170 | attribs = 'Italic'
|
---|
171 | plus = ' + '
|
---|
172 | endif
|
---|
173 | if attr % 2 - 2 * (attr % 4) then
|
---|
174 | attribs = attribs''plus'Underscore'
|
---|
175 | plus = ' + '
|
---|
176 | endif
|
---|
177 | if attr % 4 - 2 * (attr % 8) then
|
---|
178 | attribs = attribs''plus'Negative'
|
---|
179 | plus = ' + '
|
---|
180 | endif
|
---|
181 | if attr % 8 - 2 * (attr % 16) then
|
---|
182 | attribs = attribs''plus'Outline'
|
---|
183 | plus = ' + '
|
---|
184 | endif
|
---|
185 | if attr % 16 - 2 * (attr % 32) then
|
---|
186 | attribs = attribs''plus'Strikeout'
|
---|
187 | plus = ' + '
|
---|
188 | endif
|
---|
189 | if attr % 32 - 2 * (attr % 64) then
|
---|
190 | attribs = attribs''plus'Bold'
|
---|
191 | plus = ' + '
|
---|
192 | endif
|
---|
193 | if attr % 64 then
|
---|
194 | attribs = attribs''plus'(unknown selection(s))'
|
---|
195 | endif
|
---|
196 | return attribs
|
---|
197 |
|
---|