c function call hyper-links

Usage tips, posted by users. No questions here please.

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

Post Reply
helios
Posts: 716
Joined: Sun Mar 02, 2003 5:52 pm
Location: Helios Software Solutions
Contact:

c function call hyper-links

Post by helios »

I think I have just stumbled upon a most fantastic way of using TextPad (well, if you are a c programmer that is). It makes textpad easily as good as MS VisualStudio as an IDE for C programming.

What it does:

It allows you to edit, seamlessly, a large C source-file tree, spread over many directories, with the ability to double-click on a C function call, and be transported to the function definition, even if it is in another file or directory. Wow !!! You can just hop around the project, function to function, not worrying about the location of the files.

( This isn't quite as good as auto-complete in Visual Studio, but its pretty good. )

I have been using this to help me get to grips with a HUGE C project which I am unfamiliar with (so I don't know which files all the functions are in), and it works beautifully.

Here are some instructions for setting things up as I have, which maybe will only be of use to a C programmer.



Steps.

1) CXT
-------

Get a free utility, called CXT, available from //www.bigfoot.com/~sxt.

try to get version 2.64 or greater. This does many good things, but we're going to use it to create a database, and then query it. Install it, by simply putting exe's and dll's into PATH. Read the docs by all means, but you could probably just charge ahead with commands given below.

2) Create database
------------------

assume there is a C development source tree rooted at c:\blah\project.

create a directory for the database, maybe c:\blah\doc

cd to \blah\doc, and issue the following command to create the database.

cft -G -N +c:\blah\doc\*.*

( You will probably get zillions of warning messages about the code, but this never seems to prevent it from creating a useful database. In case of difficulty, consult SXT.DOC, although this is a rather large and complex piece of software. )

this may take some time!

You should now have some *.DBF files in the \doc directory.

3) test database (optional)
--------------------------

Before modifying TextPad, we can test that everything works, by trying a simple query:

> cftn -b main

Here "main" is the name of a function we are looking for somewhere in the project. It should repsond with a filename and line number of the C definition of that function.



4) configure textpad (once only)
--------------------------------

What we now have to do is configure textpad to use this information to jump to the right file/line number

Observe the output of this command:

> cftn -b"TextPad %s(%d)" main

It is outputting the command we need to start textpad. We need textpad to be in the PATH to get this command to work, so make sure that it is.

Create a windows batch file, cxtlink.bat, and put it in the PATH

it should contain something like:

cftn -b"textpad %%s(%%d)" %1 >cxttemp.bat
cxttemp

i.e. we use the output of cftn to create a single line .bat, which we then execute.

you have to double up on the %%'s to pass the "%s(%d)" through to cftn without molestation by the dos .bat engine. The %1, which isn't doubled, is replaced by the parameter passed.

We now get textpad to execute cxtlink.bat , passing as an argument the text that is highlighted (which ought to be the name of a c function). This can be done in Config/Tools/add/dos-command by using the $Sel parameter to pick up what the user has double-clicked on.

IMPORTANT: In the configuration of this textpad tool, you need to set the working directory to the c:\blah\doc directory, so that the database will be found. You probably also want to run minimised, and not capture output, and close on exit.

5) Programmer Heaven Awaits !
------------------------------

Once you have done all this, you should be able to edit a C source file deep within the tree below c:\blah\project, and then double click on a function call, press the correct tool key, and then find yourself looking at the code of that very function. And do it again. And again.. FANTASTIC!!!!!

Contributed by Stuart Mitchell.
Frank Fesevur
Posts: 16
Joined: Fri Jun 13, 2003 12:46 pm
Location: The Netherlands

Re: c function call hyper-links

Post by Frank Fesevur »

helios wrote:Get a free utility, called CXT, available from //www.bigfoot.com/~sxt.
Free??? It is 25 euro shareware! :(

I wrote a free Add-on that does the same as described here (and more). It is relies on ctags and version 2.0 has turned Open Source.

You can find my add-on at http://findtag.sourceforge.net

Frank
User avatar
woho
Posts: 100
Joined: Tue Sep 02, 2003 9:12 am
Location: Steyr/Austria
Contact:

Post by woho »

!! This is a really great tool !!
It integrates ctags.exe in TextPad very well.
It is most useful for browsing through a huge C project which I didn't write myself.

I have just to place the cursor over a "tag" (function, variable, structure member, typedef,...) and press <Alt><Right> (this is the KeyShortcut I assigned to FindTag.exe) which will take me to the definition of the tag even if it's in another file not open in TextPad.

<Alt><Left> takes me back where I came from

Additionally you can invoke FindTag with options so that a window opens showing all Tags in a tree view

THANKS FRANK !!!!!

Wolfgang
crackwitz
Posts: 13
Joined: Sun Oct 10, 2004 8:14 pm

Post by crackwitz »

to woho: how did you do this thing "<Alt><Left> takes me back where I came from"? useful to me as well...
dixonc
Posts: 54
Joined: Mon Feb 02, 2004 3:05 pm

Post by dixonc »

Brilliant - just installed it. Can now jump about to my hearts content :D
Very useful - thanks!
User avatar
woho
Posts: 100
Joined: Tue Sep 02, 2003 9:12 am
Location: Steyr/Austria
Contact:

Post by woho »

crackwitz wrote:to woho: how did you do this thing "<Alt><Left>
takes me back where I came from"? useful to me as well...
invoke findTag with parameter "-back" !!

Create a TextPad tool:
command:FindTag.exe
parameter: -back

assign <Alt><Left> as Keyboard Shortcut to the new Tool
woho
[/img]
Talulah
Posts: 11
Joined: Tue Apr 13, 2004 10:03 am

Post by Talulah »

woho wrote: invoke findTag with parameter "-back" !!

Create a TextPad tool:
command:FindTag.exe
parameter: -back

assign <Alt><Left> as Keyboard Shortcut to the new Tool
woho
[/img]
I just get the error dialog box "Not enough command line parameters!" when I do that. Can you tell us the whole command line and parameter list?
crackwitz
Posts: 13
Joined: Sun Oct 10, 2004 8:14 pm

Post by crackwitz »

http://findtag.sourceforge.net/

the instructions there work fine. maybe you have an older version of findtag?
OnlyTextPad
Posts: 41
Joined: Sat May 20, 2006 9:10 pm
Location: Helsinki
Contact:

Post by OnlyTextPad »

crackwitz wrote:http://findtag.sourceforge.net/

the instructions there work fine. maybe you have an older version of findtag?
I have the newest version and still getting the same error message :

[HKEY_CURRENT_USER\Software\Helios\TextPad 4\Tools\16]
"Properties"=hex:00,00,00,00,66,80,00,00,40,00,00,00
"MenuText"="Back"
"Command"="C:\\utils\\FindTag.exe"
"Parameters"="-back"
"Folder"=""
"RE"=""
Post Reply