TAGS file feature...

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
John Wasinger

TAGS file feature...

Post by John Wasinger »

There is a feature in EMACS (an old editor originally developed for the UNIX platform now ported over to windows) called a TAGS file. This file is generated from a REGEXP search through all of the source code of a project for the program declarations. The generated TAGS file has a format like:

function-name, path-file-name, line-number

functionname1 /fldr_x/file_y.c 234
functionname2 /file_q.c 45

When a user is reading through a file this TAGS file gave them the ability to step into a function definition found in another file (opened up into another window). If the function definition started at another line number due to alterations to that file then a search is performed ahead and behind the original line number listing in the TAGS file.

After a large number of changes have been preformed to the code the user could regenerate the TAGS file to update the line number locations and add any new functions.

EMACS is licensed under the GNU public license and its source code is open to the public. It is written in C (I think it might be in C++ now...)

- John Wasinger
jwasinger2@home.com
Andreas

RE: TAGS file feature...

Post by Andreas »

Hello John,

you can already do this with Textpad.
As textpad does not do "hypertext jumps" from normal editing windows, only from Result windows (Search results, Command Results), you have to get your tag file in one of these windows.
To do this:

Create a tool which just prints the current file to the tool output window.
Set the correct regular expression to recognize the filename and line number.
Now load your tag file into textpad, run the tool.

You should now have the contents of the tag file in the "Command results" window.
If you have chosen your regular expression correctly, you can now jump to the given lines by doubleclicking on the entries in the Command results window.

To create the tool:
Configure/Preferences/Tools/Add/DOS Command
In the box, type "type $FILE"
OK
Apply
In the tree, select the new entry "type $FILE"
Set "Initial Folder" to "$FileDir"
Make sure "Capture Output" is checked
Adapt the Regular expression to your needs.

The only thing which does not work is the search if the original line number has changed.

HTH,
Andreas
Andreas

RE: TAGS file feature...

Post by Andreas »

John,
I just saw there is also something about this on the tips page:
http://www.textpad.com/support/tips.html

Andreas
R. Lindner

RE: TAGS file feature...

Post by R. Lindner »

Here is a small solution using awk to extract filename / linenumber from a tags file and construct
a 'textpad file(line,1)' command to load the file into the editor.

This is the awk Program. I'm using the cygwin version, but MKS awk should also do it. (Replace path names
with your settings, not the usage of backward/forward slashes - DOS vs. cygwin)

----snip
# tags.awk to be used by textpad
# install as:
# Command: Cmd.exe
# Parameter: <path-toawk>\awk.exe -f <path-to-tags.qsk>/tags.awk -v ARGUMENT=$Sel tags
# Folder: $Sel
# check "Capture output"
# note: when using ctags of VIM create tags as ctags --format=1
# USAGE: Mark item and then start tool
#
# Rudolf Lindner, Jan, 2000
#

BEGIN {
Arg=ARGUMENT
TextPad="C:/Programme/Textpad 4/Textpad"
}

Arg==$1 {
FileName=$2
SearchString=substr($0, index($0, "/^")+2, length ($0)-index($0,"/^")-3)
Expr="fgrep -n \"" SearchString "\" " FileName
Expr | getline Res
close (Expr)
LineNo=substr(Res, 1, index (Res, ":")-1)
EditCmd=" sh -c \"'"TextPad"' '" FileName "\("LineNo ",1\)'\""
system(EditCmd)
}
---cut here----


Rudolf
Post Reply