[266] | 1 | /****************************** Module Header *******************************
|
---|
| 2 | *
|
---|
| 3 | * Module Name: all.e
|
---|
| 4 | *
|
---|
| 5 | * Copyright (c) Netlabs EPM Distribution Project 2002
|
---|
| 6 | *
|
---|
[2417] | 7 | * $Id: all.e 2417 2011-05-15 23:32:51Z aschn $
|
---|
[266] | 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
|
---|
[1298] | 14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
[266] | 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 | ****************************************************************************/
|
---|
[264] | 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 |
|
---|
[1298] | 60 | ; ALL macro
|
---|
| 61 | defc all=
|
---|
| 62 | universal allorig
|
---|
| 63 | universal allsrch
|
---|
| 64 | universal default_search_options
|
---|
[264] | 65 | call psave_pos(save_pos)
|
---|
| 66 | if .filename = '.ALL' & arg(1) then
|
---|
| 67 | .filename = '.prev_ALL'
|
---|
| 68 | endif
|
---|
| 69 | getfileid allorig
|
---|
[1298] | 70 | 'e /q /n .ALL' -- Don't use XCOM so can handle either windowing style
|
---|
[264] | 71 | .filename = '.ALL'
|
---|
| 72 | getfileid allfile
|
---|
[1298] | 73 | allsrch = strip( arg(1), 'L')
|
---|
| 74 | if allsrch = '' then
|
---|
| 75 | .modify = 0
|
---|
[264] | 76 | 'q'
|
---|
[1298] | 77 | if allorig <> allfile then
|
---|
| 78 | activatefile allorig
|
---|
| 79 | endif
|
---|
[264] | 80 | sayerror 1
|
---|
| 81 | return
|
---|
| 82 | endif
|
---|
[1298] | 83 | for i = 1 to .last
|
---|
[264] | 84 | deleteline 1
|
---|
| 85 | endfor
|
---|
| 86 | activatefile allorig
|
---|
| 87 |
|
---|
[1298] | 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
|
---|
[264] | 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
|
---|
[1298] | 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)
|
---|
[264] | 105 | endif
|
---|
[1298] | 106 | allsrch = allsrch''ch''DSO''user_options
|
---|
[264] | 107 | ; endif
|
---|
| 108 | last_line = .last
|
---|
[1298] | 109 | if pos( 'M', upcase(DSO''user_options)) > pos( 'A', upcase(DSO''user_options)) then
|
---|
[264] | 110 | getmark line, last_line -- /x/m will move to start of mark if past end!
|
---|
| 111 | endif
|
---|
| 112 |
|
---|
[1298] | 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
|
---|
[264] | 117 | display -3
|
---|
| 118 | do forever
|
---|
[1298] | 119 | .col = 1
|
---|
[264] | 120 | 'xcom l' allsrch
|
---|
[1298] | 121 | if rc = -273 then leave; endif -- sayerror("String not found")
|
---|
[264] | 122 | getline line
|
---|
[1298] | 123 | line = rightstr( .line, 5) line -- prepend line no
|
---|
| 124 | insertline line, allfile.last + 1, allfile
|
---|
| 125 | if .line = last_line then leave; endif
|
---|
[264] | 126 | '+1'
|
---|
| 127 | end
|
---|
| 128 | display 3
|
---|
| 129 | call prestore_pos(save_pos)
|
---|
[1298] | 130 | if allfile.last = 0 then
|
---|
[264] | 131 | activatefile allfile
|
---|
[1298] | 132 | .modify = 0
|
---|
[264] | 133 | 'q'
|
---|
| 134 | activatefile allorig
|
---|
[1298] | 135 | sayerror -273 -- sayerror("String not found")
|
---|
[264] | 136 | return
|
---|
| 137 | endif
|
---|
| 138 | sayerror 0
|
---|
| 139 | activatefile allfile
|
---|
| 140 | sayerror 0
|
---|
[1298] | 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.
|
---|
[264] | 145 |
|
---|
| 146 | compile if not defined(ALL_KEY)
|
---|
| 147 | define ALL_KEY = 'c_Q'
|
---|
| 148 | compile endif
|
---|
| 149 |
|
---|
[1298] | 150 | ; Shows the .ALL file's current line in the original file
|
---|
| 151 | def $ALL_KEY =
|
---|
| 152 | universal allorig
|
---|
| 153 | universal allsrch
|
---|
[264] | 154 | if .filename <> '.ALL' then
|
---|
| 155 | getfileid allfile,'.ALL'
|
---|
[1298] | 156 | if allfile = '' then
|
---|
[264] | 157 | sayerror NO_ALL_FILE__MSG
|
---|
| 158 | else
|
---|
| 159 | activatefile allfile
|
---|
[1298] | 160 | -- Scroll the .ALL file a la FILEMAN.
|
---|
| 161 | if .line = .last then
|
---|
[264] | 162 | top
|
---|
[1298] | 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!
|
---|
[264] | 170 | '+1'
|
---|
[1298] | 171 | oldline = .line
|
---|
| 172 | .cursory = (.windowheight + 1)%2 -- Center vertically
|
---|
[264] | 173 | oldline
|
---|
| 174 | endif
|
---|
[1298] | 175 | .col = 6 -- Skip line number for search
|
---|
| 176 | 'l' allsrch'A'
|
---|
[264] | 177 | endif
|
---|
| 178 | return
|
---|
[1298] | 179 | endif -- .filename <> '.ALL'
|
---|
[264] | 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
|
---|
[1298] | 187 | .cursory = .windowheight%2 -- Center vertically
|
---|
[264] | 188 | line
|
---|
[1298] | 189 | .col = 1
|
---|
| 190 | 'l' allsrch'A' -- Use l, not xcom l to highlight hit.
|
---|
| 191 |
|
---|
| 192 |
|
---|