Macro containing Find in Files

General questions about using TextPad

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

Post Reply
brian
Posts: 3
Joined: Wed Nov 25, 2009 1:01 pm

Macro containing Find in Files

Post by brian »

I edit Fortran source code files containing multiple subroutines. Potentially, Textpad's "Find in Files" feature is incredibly useful for popping up a separate box that lists the subroutines in the current file being edited (just a search for the text "blank-blank SUBROUTINE"). Then I click on a line in this box and go directly to the head of the corresponding subroutine. To make this usable for different Fortran files, I need (a) to tell "Find in Files" to restrict its search to the current file being edited (without having to type the specific file name in the search dialog each time), (b) to record this search for "SUBROUTINE" in a macro, and (c) create an icon for this macro on the TextPad toolbar. I have not found a way of doing this. Is it possible?
paleolith
Posts: 46
Joined: Sun Jun 26, 2005 6:25 pm
Contact:

Post by paleolith »

Off the top of my head, I can't think of a way to do it.

If you haven't considered using regular Find with Mark All, you might look into it. It's definitely not what you are asking for, but it's the best tool I know of for this situation.

Edward
User avatar
trids
Posts: 69
Joined: Wed May 07, 2003 10:16 am
Location: South Africa

Post by trids »

There is a very cool solution for this, which i use countless times each day. Check it out ..
http://forums.textpad.com/viewtopic.php?p=11264#11264

It uses grep, a free commandline utility .. download link is in that post. Best of all, no need for a macro

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

Jump to subroutine directly: Try FindTag !

Post by woho »

Hi
please search also forum for FindTag (http://findtag.sourceforge.net/) written by Frank Fesevur !

FindTag has may be defined as External Tool with different parameters

with FindTag you can:
- 'ShowTags': pop up a dialog with a tree of all language elements (e.g. subroutines) of your file (or the whole project), doubleclick on one of them => jump to it's definition

- 'GoToTag': put cursor on a language element (e.g. FORTRAN subroutine, C macro, variable,..) and directly jump to it's definition

- 'FileTag': the dialog shows language elements separated by file

- 'TagBack' after that jump back again where you came from !

FindTag is built on Ctags (http://ctags.sourceforge.net/)
Ctags creates within no time a textfile as database including all definitions of functions, macros, parameters,.. of a language. Apart from Fortran ctags it is capable of MANY more languages (I use it for C)

There might be an issue with TextPad 5 (http://forums.textpad.com/viewtopic.php ... ht=findtag) , I used it already with 4.7.3, now with 5.3.1 => no problem


My Tools menu is defined like that:

ShowTags:
[HKEY_CURRENT_USER\Software\Helios\TextPad 5\Tools\43]
"Properties"=hex:00,00,00,00,64,80,00,00,44,00,00,00
"MenuText"="ShowTags"
"Command"="D:\\Programm\\FindTag\\FindTag.exe"
"Parameters"="-tree $AppWnd $File $Line"
"Folder"="$FileDir"
"RE"=""

FindTag
[HKEY_CURRENT_USER\Software\Helios\TextPad 5\Tools\41]
"Properties"=hex:00,00,00,00,5b,80,00,00,44,00,00,00
"MenuText"="GoToTag"
"Command"="D:\\Programm\\FindTag\\FindTag.exe"
"Parameters"="-tag $AppWnd $File $Line $SelWord "
"Folder"="$FileDir"
I assign as keyboard shortcut <Alt>-<CursorRight>

TagBack
[HKEY_CURRENT_USER\Software\Helios\TextPad 5\Tools\42]
"Properties"=hex:00,00,00,00,66,80,00,00,44,00,00,00
"MenuText"="TagBack"
"Command"="D:\\Programm\\FindTag\\FindTag.exe"
"Parameters"="-back"
"Folder"="$FileDir"
"RE"=""
I assign as keyboard shortcut <Alt>-<CursorLeft>
brian
Posts: 3
Joined: Wed Nov 25, 2009 1:01 pm

Post by brian »

Many thanks guys for the inputs. I am exploring them now. You have confirmed for me that the feature I need (and more advanced versions) can be of enormous value to programmers.

It is a pity that Textpad has not already anticipated this, particularly when in the most rudimentary sense it is virtually there now -- a big step forward would just be to give "find in files" an option to search only the current file (of course it now includes occurrences in the current file but they typically get lost in the flood of entries). Alternative, "find" could be given an option to produce a popup list just like "find in files".

Functionality of this type is at the top of my wish list for Textpad enhancements. My not-too-old version of UltraEdit does not have it. (BTW, I use UltraEdit very seldom, and only for its dangerous "replace in files" feature. Otherwise both myself and all my programmer colleagues prefer Textpad.)

Thanks again, and please can the Textpad developers take note.
chrissv
Posts: 3
Joined: Thu Jan 07, 2010 6:10 pm

Post by chrissv »

Can someone make available the FindTag executable modified for TextPad 5.0? I tried to get the source from sourceforge, but had a lot of problems.

Thanks - Steven
brian
Posts: 3
Joined: Wed Nov 25, 2009 1:01 pm

Fiind in files - but just the open file(s)

Post by brian »

On this subject (extremely important to me and apparently others), I have discovered a rather unpleasant solution.

I was able to examine a new version of UltraEdit. This does precisely what we want. That is, its "find in files" search has a checkbox to restrict its output to "open files". Using this, it is trivial to create a keystroke-recorded macro to search in the current file (or all open files) for a string - in my present case the left-justified "SUBROUTINE". Assigning this macro to a Ctrl/Alt key combination, the list of search hits in the open file(s) being edited now pops up -and a mouse click jumps to the desired line. This is EXACTLY what I needed. It is a huge programmer aid. I showed this to my fellow TextPad programmers and they all said "fantastic - this would make our lives so much easier".

At this point, with thanks again to those describing the methods for working around TextPad's limitations, I feel that there is only one sensible solution. With trivial effort, TextPad can provide this capability in its immediately next version.

The alternative is clear. I am a TextPad person and I like it more than the uber-feature-rich UltraEdit, which in a few small but important ways is not as ergonomic as TextPad. But.....
User avatar
trids
Posts: 69
Joined: Wed May 07, 2003 10:16 am
Location: South Africa

Post by trids »

Yep, I agree that a new "all open files" checkbox would be very useful on the "find in files" dialog.

Perhaps it might also be possible to provide a list of all open files by way of an environment variable, which custom tools can access? Helios? Maybe a tab-delimited list of fully qualified filenames.
:roll:
Post Reply