home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR36
/
KEXX.ZIP
/
CTAGS.KEX
< prev
next >
Wrap
Text File
|
1992-06-25
|
2KB
|
80 lines
* Function: Locate the definition of the C function the cursor is on.
* To run: See CTAGS.DOC.
* Requires: KEDIT 4.0 or later
* Version: 1.1 (July 1988) by NBM
* get name of data file
'editv get ctags_dat'
if ctags_dat = '' then ctags_dat = 'ctags.dat'
* if an argument is supplied, use that as the function name
if arg() then word = arg(1)
else do
* if on a closing brace, find the open brace
if field.2() = ')' then do
'cmatch'
if rc \= 0 then exit
end
* if on an open brace, move one character to the left
if field.2() = '(' then 'cursor left'
* if not on a function name then abort
'extract /field'
if \datatype(field.2, 'a') & field.2 \= '_' then do
'emsg Cursor is not on a C function'
exit
end
* get the function name, abort if invalid
do endcol = field.3
c = substr(field.1, endcol, 1)
if \datatype(c, 'a') & c \= '_' then leave
end
if c \= '(' then do
'emsg Cursor is not on a C function'
exit
end
do startcol = field.3 to 1 by -1
c = substr(field.1, startcol, 1)
if \datatype(c, 'm') & c \= '_' then leave
end
startcol = startcol + 1
word = substr(field.1, startcol, endcol - startcol)
if \datatype(substr(word, 1, 1), 'm') then do
'emsg Cursor is not on a C function'
exit
end
end
* edit the data file
original_fid = fileid.1()
'kedit' ctags_dat '(noprofile'
if rc \= 0 then exit rc
if size.1() = 0 then do
'qquit'
'kedit' original_fid
'emsg Data file' ctags_dat 'not found or empty'
exit
end
* find the entry for this function, abort if unsuccessful
'tfind /'word
if rc \= 0 then do
'qquit'
'kedit' original_fid
'emsg Cound not find function "'word'" in data file' ctags_dat
exit
end
'extract /curline/'
target_file = word(curline.3, 2)
target_string = substr(curline.3, pos('?', curline.3) + 2)
target_string = substr(target_string, 1, length(target_string) - 2)
'qquit'
* make the function definition the current line
'kedit' target_file
* version 1.1 fix: use "unusual" delimiter to minimize conflicts
'locate :1 tfind ⌠'target_string