Page 1 of 1
xtags - search for references
Posted: Wed Jun 28, 2006 11:21 pm
by drprav
Hi
To search for all references to a keyword (variable or function name) in a project, I right click on the keyword and select "File Grep" option. This opens a dialog but I have to everytime change the Directory to point to the top level directory of the project. And I have to everytime add the '-d' option to Arguments to search all the sub-directories.
Is there a registry entry or something where I can make these changes permanent and as the default values for "File Grep"?
The output of this is shown in a Tools tab along with the other open files. Is there any way I can redirect the output to some other fixed window so I can easily move between the search result and the source files without having to toggle between the tabs...?
And finally, is there any other better way to search for references?
Thanks,
Praveen
Posted: Thu Jun 29, 2006 12:07 am
by jussij
Hi Praveen,
Is there a registry entry or something where I can make these changes permanent and as the default values for "File Grep"?
There is no registry entry but it is easy to write a macro to achieve the same effect. For example the following
grep.lua macor script will do something similar:
Code: Select all
function key_macro()
local directory;
-- NOTE: The $PDD drive and directory maps to the value specified
-- in the "Project make file" entry field found in the General
-- Section of the Workspace
directory = macro_tag("$PDD")
-- NOTE: The $WDD drive and directory maps to the current workspace
-- drive and directory
directory = macro_tag("$WDD")
-- some debug help
-- message_box(1, "Debug", directory);
-- assume search word is current word or marked area
local word = macro_tag("$WEX")
if string.len(word) == 0 then
-- no word found so ask for a user for a search word
word = user_input("Search String:", word)
end
if string.len(word) > 0 then
-- the files to be searched
local files_extensions = "*.cpp *.hxx *.h"
-- ask for a user for a command line
local cmd = "xfgrep.exe -d -f -n " .. word .. " " .. files_extensions
-- setup command control falgs (see the Zeus Macro help for details)
local flags = 2+4+16+32
-- run command
system(cmd, directory, flags)
end
end
key_macro() -- run the macro
Just save the
grep.lua to the
zScript directory found in the Zeus install directory. To run the script use the
Macro, Execute Scripts menu and type in
grep.
It is also possible to add the macro to the Zeus Macro and/or popup menus or alternatively bind the macro to the keyboard.
Is there any way I can redirect the output to some other fixed window
In the case above the output should always end up in the same Tool window. You can also control the window creation using the
file_open_tool macro function. For more details see this thread:
http://www.zeusedit.com/forum/viewtopic.php?t=74
And finally, is there any other better way to search for references?
I find
xgrep.exe is my favourite way of searching for references
The
Tags, Find menu can be used to search for declarations but unfortunately it will not find references
But since Zeus can easily integrate any external command line tool, if you search the web for a xref tool it should be easy enough to integrate this into Zeus.
Cheers Jussi
Posted: Fri Jun 30, 2006 5:20 pm
by drprav
Thanks Jussi!
The macro is working great. I was able to add it to the Zeus Macro menu, but am not able to add it to the right click popup menu....any ideas of how to go about it?
I am trying to use Zeus in place of another editor, Visul SlickEdit, which has very powerful referencing tools. Zeus is almost there (and much cheaper!) except for not having all the references listed in a separate fixed output window pane from where I can double click the line and it opens the relevant file. If I re-redirect the output to a DOS window, I will not be able to use the double click functionality.
With Regards,
Praveen
Posted: Sat Jul 01, 2006 12:27 am
by jussij
I was able to add it to the Zeus Macro menu, but am not able to add it to the right click popup menu....any ideas of how to go about it?
If you edit the document type where you added the macro, in the macros panel you should see an
Add to popup menu. This will add the macro to the popup menu.
except for not having all the references listed in a separate fixed output window pane from where I can double click the line and it opens the relevant file. If I re-redirect the output to a DOS window, I will not be able to use the double click functionality.
Zeus should be able to capture the grep output to a tool window and let you double click to take you to the correct file and line. If this is not working then theconfiguration is not quite right
Cheers Jussi