在ubuntu 10.04下试用了Source Navigator,有条件还是装Source insight吧,不是一个级别的,非常不方便。
Source Navigator 是Red Hat出品的一款查看源代码的工具,非常好用,与Windows下的Source Insight有一敌。但是它的界面不怎么好看,用的不是GTK图形库,所以界面风格与Gnome不一致,操作上也有些不同。除了这些,其它功能都非常强大,细数如下。里面的一些简写约定如下:
Code Area
cl Classes
con Constants
e Enums
ec Enum Values
fd Function Declarations
fr friends
fu Functions
gv Global Variables
iv Instance Variables
ma Macros
md Method Definitions
mi Method Implementations
t Typedefs
un Unions
lv Local variables
ud Undefined
Cross-Reference
r Read
w Written
p Passed
u Unused
SNav的代码窗口有6个标签页,它们分别是
“Edit”
“Hierarchy”
“Class”
“Xref”
“Retriever”
“Grep”
其中, Edit区是代码显示和修改的区域,是工作的主要区域;“Hierarchy”和“Class”是C++代码的组织工具;“Xref”是最强大的一个工具,它会把一个函数中的所有用到的变量,调用的函数,用到的结构全记录并展现出来;“Retriever”也是一个非常有用的工具,用于把一个库代码包中的所有定义的符号列出来,并记录相应的属性;“Grep”用于查找某一个符号,可指定搜索的范围,既可全局查找也可部分文件查找。阅读代码时常用到的一些键值组合:
Ctrl+leftarrow | rightarrow | uparrow | downarrow 以词的形式移动光标
Ctrl+Alt+leftarrow | rightarrow | uparrow | downarrow 以词的形式移动光标并选择走过的区域
Ctrl+Shift+D 查看选定符号的声明
Ctrl+Shift+I 查看选定符号的定义代码窗口的工具栏上有7个元素,分别是
“回退跳转”
“前进跳转”
“光标处所在的函数名或结构名”
“选定并要操作(比如查找)的字符串”
“在本文件中查找选定的字符串”(比Ctrl+F查找功能好使)
“在整个工程中查找与选定字符串匹配的代码”
“在整个工程中以Grep的方式查找与选定字符串匹配的代码”(会跳到Grep标签页中显示结果)注意:snavigator在导入目录时,目录名中间不能出现空格。
三、在ubuntu中安装 Source-Navigator及使用手册
2009-09-25 23:19
from : http://hi.baidu.com/xiaohu_tiger/blog/item/66d207888431d6b40f2444ec.html
1 通过apt-get安装(版本较旧)
安装命令:sudo apt-get install sourcenav
启动命令:snavigator
2 手动安装最新版本
1)到官方网站获取软件包
http://sourceforge.net/project/showfiles.php?group_id=51180
2)解压缩
tar zxvf s ourcenav-6.0.tar.gz
./configure --prefix=/opt/sourcenav (install 文件推荐参数)
make
make install
ps:如果出现权限问题,前面加sudo
3)如果碰到下述错误
/root/tk8.4.16/unix/../generic/tk3d.c:1279: error: ‘TkBorder’ has no member named ‘resourceRefCount’
/root/tk8.4.16/unix/../generic/tk3d.c:1280: error: ‘Tk_FakeWin’ has no member named ‘display’
/root/tk8.4.16/unix/../generic/tk3d.c:1280: error: ‘Tk_FakeWin’ has no member named ‘screenNum’
/root/tk8.4.16/unix/../generic/tk3d.c:1280: error: ‘TkBorder’ has no member named ‘screen’
/root/tk8.4.16/unix/../generic/tk3d.c:1281: error: ‘Tk_FakeWin’ has no member named ‘atts’
/root/tk8.4.16/unix/../generic/tk3d.c:1281: error: ‘TkBorder’ has no member named ‘colormap’
/root/tk8.4.16/unix/../generic/tk3d.c:1301: error: ‘TkDisplay’ has no member named ‘borderTable’
/root/tk8.4.16/unix/../generic/tk3d.c:1301: error: ‘TkDisplay’ has no member named ‘borderTable’
/root/tk8.4.16/unix/../generic/tk3d.c:1306: error: ‘TkBorder’ has no member named ‘nextPtr’
。。。。。。
则在终端是输入:sudo apt-get install libx11-dev
4) 启动snavigator
在终端直接输入:snavigator
5) 使用手册(user manual)
http://sourcenav.sourceforge.net/online-docs/userguide/index_ug.html
还有一个 source insight 和source navigator的比较的帖子:
http://fky168.blog.163.com/blog/static/3786097200831033957620/
========================================================
运行source navigator的问题
方法一、(转载)
安装完成后运行 snavigator 提示
[root@MagicLinux sourcenav-6.0]# snavigator
Can\'t find a usable tk.tcl in the following directories:
/usr/local/share/tk8.3
/usr/local/share/tk8.3/tk.tcl: no event type or button # or keysym
no event type or button # or keysym
while executing
"bind Listbox {
%W yview scroll [expr {- (%D / 120) * 4}] units
}"
(file "/usr/local/share/tk8.3/listbox.tcl" line 182)
invoked from within
"source [file join $tk_library listbox.tcl]"
invoked from within
"if {[string compare $tcl_platform(platform) "macintosh"] && /
[string compare {} $tk_library]} {
source [file join $tk_library button.tcl]
so..."
(file "/usr/local/share/tk8.3/tk.tcl" line 30
invoked from within
"source /usr/local/share/tk8.3/tk.tcl"
("uplevel" body line 1)
invoked from within
"uplevel /#0 [list source $file]"
This probably means that tk wasn\'t installed properly.
不知其所以然,重新安装tk8.3无效,升级到tk8.5无效
后来在网上发现需要给下载的Source-Navigator 6.0打补丁
到http://bugs.gentoo.org/show_bug.cgi?id=225999 找到 tk-8.4-lastevent.patch 补丁
将补丁粘贴到source navigator 源码目录 sourcenav-6.0/tk目录下,再cd 到sourcenav-6.0/ tk 的源码目录
patch -p0 -i tk-8.4-lastevent.patch
删除安装,重新安装,可以运行了(我试了一下不行)。
方法二、(转载)
有找到解法:
(http://forums.fedoraforum.org/showthread.php?t=213441)
注掉 lines 182-184 in the file /opt/sourcenav/share/tk8.3/listbox.tcl
注掉 lines 457-459 in the file /opt/sourcenav/share/tk8.3/text.tcl
在panel中添加Launcher,在Command中添加/opt/sourcenav/bin/snavigator
====== 安装完后在桌面增加捷径的方法 ======
我要做捷径的目标是/opt/sourcenav/bin/snavigator (这是个sh script)
里面要改一行
#snbindir=`dirname $0`
snbindir=/opt/sourcenav/bin
这样再建一个捷径到桌面即可:
ln -s /opt/sourcenav/bin/snavigator ~/Desktop/
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/dian_technology/archive/2010/07/23/5757884.aspx