Community
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

c function call hyper-links

 
Post new topic   Reply to topic    Community Forum Index -> Tips
View previous topic :: View next topic  
Author Message
helios



Joined: 02 Mar 2003
Posts: 723
Location: Helios Software Solutions

PostPosted: Wed Aug 13, 2003 1:59 pm    Post subject: c function call hyper-links Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Frank Fesevur



Joined: 13 Jun 2003
Posts: 16
Location: The Netherlands

PostPosted: Thu Aug 14, 2003 12:30 pm    Post subject: Re: c function call hyper-links Reply with quote

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


Free??? It is 25 euro shareware! Sad

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
Back to top
View user's profile Send private message
woho



Joined: 02 Sep 2003
Posts: 100
Location: Steyr/Austria

PostPosted: Tue Oct 28, 2003 4:14 pm    Post subject: Reply with quote

!! 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
Back to top
View user's profile Send private message Visit poster's website
crackwitz



Joined: 10 Oct 2004
Posts: 13

PostPosted: Mon Oct 11, 2004 3:26 pm    Post subject: Reply with quote

to woho: how did you do this thing "<Alt><Left> takes me back where I came from"? useful to me as well...
Back to top
View user's profile Send private message
dixonc



Joined: 02 Feb 2004
Posts: 55

PostPosted: Thu Nov 11, 2004 12:13 pm    Post subject: Reply with quote

Brilliant - just installed it. Can now jump about to my hearts content Very Happy
Very useful - thanks!
Back to top
View user's profile Send private message
woho



Joined: 02 Sep 2003
Posts: 100
Location: Steyr/Austria

PostPosted: Fri Apr 15, 2005 3:39 pm    Post subject: Reply with quote

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]
Back to top
View user's profile Send private message Visit poster's website
Talulah



Joined: 13 Apr 2004
Posts: 11

PostPosted: Thu May 05, 2005 10:29 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
crackwitz



Joined: 10 Oct 2004
Posts: 13

PostPosted: Sat Nov 04, 2006 6:08 pm    Post subject: Reply with quote

http://findtag.sourceforge.net/

the instructions there work fine. maybe you have an older version of findtag?
Back to top
View user's profile Send private message
OnlyTextPad



Joined: 20 May 2006
Posts: 41
Location: Helsinki

PostPosted: Tue Nov 14, 2006 3:17 pm    Post subject: Reply with quote

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"=""
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Community Forum Index -> Tips All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB