1 | /****************************** Module Header *******************************
|
---|
2 | *
|
---|
3 | * Module Name: all.e
|
---|
4 | *
|
---|
5 | * Copyright (c) Netlabs EPM Distribution Project 2002
|
---|
6 | *
|
---|
7 | * $Id: all.e 2417 2011-05-15 23:32:51Z 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 | /* This command will create a new file showing all occurrances of the */
|
---|
22 | /* search string given. Syntax: ALL /find_string[/[c]] */
|
---|
23 | /* where / can be any delimiter, and c means ignore case. */
|
---|
24 | /* */
|
---|
25 | /* The key c_Q is set up so that if you press it while in the .ALL */
|
---|
26 | /* file, it will position you on the corresponding line in the */
|
---|
27 | /* original file. If you are not in .ALL, you will be placed there */
|
---|
28 | /* and the cursor will be moved down one line. This enables you to */
|
---|
29 | /* rapidly switch from .ALL to succeeding lines of the original. */
|
---|
30 | /* */
|
---|
31 | /* Set ALL_HIGHLIGHT_COLOR in your MYCNF.E to have the "hits" */
|
---|
32 | /* highlighted in the .all file. E.g., */
|
---|
33 | /* compile if defined(BLACK) */
|
---|
34 | /* define */
|
---|
35 | /* ALL_HIGHLIGHT_COLOR = Magenta + Yellowb */
|
---|
36 | /* compile endif */
|
---|
37 | /* */
|
---|
38 | /* Author: Larry Margolis, MARGOLI at YORKTOWN */
|
---|
39 |
|
---|
40 | compile if not defined(SMALL) -- If being externally compiled...
|
---|
41 | define INCLUDING_FILE = 'ALL.E'
|
---|
42 | const
|
---|
43 | tryinclude 'MYCNF.E'
|
---|
44 | compile if not defined(SITE_CONFIG)
|
---|
45 | const SITE_CONFIG = 'SITECNF.E'
|
---|
46 | compile endif
|
---|
47 | compile if SITE_CONFIG
|
---|
48 | tryinclude SITE_CONFIG
|
---|
49 | compile endif
|
---|
50 | const
|
---|
51 | compile if not defined(NLS_LANGUAGE)
|
---|
52 | NLS_LANGUAGE = 'ENGLISH'
|
---|
53 | compile endif
|
---|
54 | include NLS_LANGUAGE'.e'
|
---|
55 |
|
---|
56 | defmain
|
---|
57 | 'all' arg(1)
|
---|
58 | compile endif
|
---|
59 |
|
---|
60 | ; ALL macro
|
---|
61 | defc all=
|
---|
62 | universal allorig
|
---|
63 | universal allsrch
|
---|
64 | universal default_search_options
|
---|
65 | call psave_pos(save_pos)
|
---|
66 | if .filename = '.ALL' & arg(1) then
|
---|
67 | .filename = '.prev_ALL'
|
---|
68 | endif
|
---|
69 | getfileid allorig
|
---|
70 | 'e /q /n .ALL' -- Don't use XCOM so can handle either windowing style
|
---|
71 | .filename = '.ALL'
|
---|
72 | getfileid allfile
|
---|
73 | allsrch = strip( arg(1), 'L')
|
---|
74 | if allsrch = '' then
|
---|
75 | .modify = 0
|
---|
76 | 'q'
|
---|
77 | if allorig <> allfile then
|
---|
78 | activatefile allorig
|
---|
79 | endif
|
---|
80 | sayerror 1
|
---|
81 | return
|
---|
82 | endif
|
---|
83 | for i = 1 to .last
|
---|
84 | deleteline 1
|
---|
85 | endfor
|
---|
86 | activatefile allorig
|
---|
87 |
|
---|
88 | -- Copied from DEFC L - we only will use E or C (case) and A or M (mark)
|
---|
89 | DSO = '' -- DSO = subset of default_search_options
|
---|
90 | do i = 1 to length(default_search_options)
|
---|
91 | ch = substr( default_search_options, i, 1)
|
---|
92 | if pos( ch, 'EeCcAaMm') > 0 then
|
---|
93 | DSO = DSO''ch
|
---|
94 | endif
|
---|
95 | end
|
---|
96 | /* Insert default_search_options just before supplied options (if any) */
|
---|
97 | /* so the supplied options will take precedence. */
|
---|
98 | ; if DSO then
|
---|
99 | ch =substr( allsrch, 1, 1)
|
---|
100 | p =pos( ch, allsrch, 2)
|
---|
101 | user_options = ''
|
---|
102 | if p > 0 then
|
---|
103 | user_options = substr( allsrch, p + 1)
|
---|
104 | allsrch = substr( allsrch, 1, p - 1)
|
---|
105 | endif
|
---|
106 | allsrch = allsrch''ch''DSO''user_options
|
---|
107 | ; endif
|
---|
108 | last_line = .last
|
---|
109 | if pos( 'M', upcase(DSO''user_options)) > pos( 'A', upcase(DSO''user_options)) then
|
---|
110 | getmark line, last_line -- /x/m will move to start of mark if past end!
|
---|
111 | endif
|
---|
112 |
|
---|
113 | -- Append U (new feature) to disable T or B option. Otherwise All will not work.
|
---|
114 | allsrch = allsrch'U'
|
---|
115 |
|
---|
116 | 0 -- move cursor on line 0
|
---|
117 | display -3
|
---|
118 | do forever
|
---|
119 | .col = 1
|
---|
120 | 'xcom l' allsrch
|
---|
121 | if rc = -273 then leave; endif -- sayerror("String not found")
|
---|
122 | getline line
|
---|
123 | line = rightstr( .line, 5) line -- prepend line no
|
---|
124 | insertline line, allfile.last + 1, allfile
|
---|
125 | if .line = last_line then leave; endif
|
---|
126 | '+1'
|
---|
127 | end
|
---|
128 | display 3
|
---|
129 | call prestore_pos(save_pos)
|
---|
130 | if allfile.last = 0 then
|
---|
131 | activatefile allfile
|
---|
132 | .modify = 0
|
---|
133 | 'q'
|
---|
134 | activatefile allorig
|
---|
135 | sayerror -273 -- sayerror("String not found")
|
---|
136 | return
|
---|
137 | endif
|
---|
138 | sayerror 0
|
---|
139 | activatefile allfile
|
---|
140 | sayerror 0
|
---|
141 | .modify = 0
|
---|
142 | top; .col = 7
|
---|
143 | 'postme l' allsrch'A' -- Position cursor under first hit.
|
---|
144 | -- Use l, not xcom l to highlight hit.
|
---|
145 |
|
---|
146 | compile if not defined(ALL_KEY)
|
---|
147 | define ALL_KEY = 'c_Q'
|
---|
148 | compile endif
|
---|
149 |
|
---|
150 | ; Shows the .ALL file's current line in the original file
|
---|
151 | def $ALL_KEY =
|
---|
152 | universal allorig
|
---|
153 | universal allsrch
|
---|
154 | if .filename <> '.ALL' then
|
---|
155 | getfileid allfile,'.ALL'
|
---|
156 | if allfile = '' then
|
---|
157 | sayerror NO_ALL_FILE__MSG
|
---|
158 | else
|
---|
159 | activatefile allfile
|
---|
160 | -- Scroll the .ALL file a la FILEMAN.
|
---|
161 | if .line = .last then
|
---|
162 | top
|
---|
163 | elseif .last <= (.windowheight - 2) then -- no need to scroll
|
---|
164 | .cursory = .cursory + 1
|
---|
165 | elseif .line < (.windowheight%2) then -- no need to scroll - yet
|
---|
166 | .cursory = .cursory + 1
|
---|
167 | elseif (.last - .line) < (.windowheight%2) then -- === Bot === on screen
|
---|
168 | .cursory = .cursory + 1
|
---|
169 | else -- Scroll!
|
---|
170 | '+1'
|
---|
171 | oldline = .line
|
---|
172 | .cursory = (.windowheight + 1)%2 -- Center vertically
|
---|
173 | oldline
|
---|
174 | endif
|
---|
175 | .col = 6 -- Skip line number for search
|
---|
176 | 'l' allsrch'A'
|
---|
177 | endif
|
---|
178 | return
|
---|
179 | endif -- .filename <> '.ALL'
|
---|
180 | getline line
|
---|
181 | parse value line with line .
|
---|
182 | if not isnum(line) then
|
---|
183 | sayerror BAD_ALL_LINE__MSG
|
---|
184 | return
|
---|
185 | endif
|
---|
186 | activatefile allorig
|
---|
187 | .cursory = .windowheight%2 -- Center vertically
|
---|
188 | line
|
---|
189 | .col = 1
|
---|
190 | 'l' allsrch'A' -- Use l, not xcom l to highlight hit.
|
---|
191 |
|
---|
192 |
|
---|