Source insight classic tutorial

Source: Internet
Author: User
Tags tortoisesvn

Source insightIt is essentially a language that supports multiple development languages (Java, C, CAnd so on) editor, but because of its powerful functions such as searching, positioning, and color display, it is often regardedSource codeUse the reading tool.

As an open sourceCodeThe source code library attached to the Linux operating system gives the majority of fans the opportunity to study and study extensively. Especially, the Linux kernel is very complicated and cannot be likeProgramSimilarly, you can use the integrated development environment to check the variables and functions, or even set breakpoints, single-step running, debugging, and other means to figure out the entire program's organizational structure, this makes it especially difficult to read the Linux kernel source code.

Of course, the vim and Emacs editing programs in Linux do not provide functions such as variable, function search, and color display program statements. Their functions are very powerful. For example, VIM and Emacs respectively embed a tag program called CTAG and etag. By configuring these two programs, you can also implement powerful function variable search functions, however, due to its complicated configuration, the relevant information attached to Linux is not very detailed. Even if a tag library is set up to enable the code color display function, further configuration is required (on the otherArticle, I will describe how to configure these features), at the same time, for most enthusiasts, may not be proficient in using vim and Emacs those powerful commands and shortcuts.

To facilitate the study of the Linux source program, we may wish to go back to the Windows environment we are familiar with, which is also a "teacher to long Yi to make Yi. However, on the window platform, some common integrated development environments are used, and the results are not very satisfactory. For example, it is difficult to add all files, and the search speed is slow, functions other than Windows cannot be displayed in color. So I finally found a powerful source code editor by searching on the Internet. Its excellent performance greatly reduced the difficulty of learning the Linux kernel source code. This is source insight3.0, it is a shared software on Windows platform.Http://www.sourceinsight.com/Download the 30-day trial version above. Because source insight is an application software for Windows, you must first obtain the source code of the Program on Linux to Windows, this can be achieved by copying files under the/usr/src directory to a partition on the Windows platform on the Linux platform, or directly copying files from the online CD to a partition on the Windows platform.

The following describes how to use source insight. Considering that the enthusiasts who read the source program have a considerable level of software usage, this article only introduces some of the trivial and well-known details, so that you can quickly use the software and reduce the process of exploration.

Install source insight and start the program. You can go to figure 1. There are several noteworthy items on the toolbar. The project button on the left side of the Inner Concave is used to display the project window. The button on the right will display a window, provides the call diagrams of other functions in the function body where the cursor is located. By clicking those functions in the form, you can enter the place where the function is located.

Figure 1 source insight page

Because source insight is essentially an editor that supports multiple development languages (Java, C, C ++, and so on), it only has powerful functions such as searching, locating, and color display, it is used as a source code reading tool. Therefore, to effectively read the source program, you must first select the "project" option sub-menu "new project" on the function menu to create a new project. The project name can be freely selected, you can also choose to delete a project. When a project is deleted, the project auxiliary files generated by the software are not deleted. After setting, a dialog box 2 is displayed. Accept the default selection. If the disk space is sufficient, select the first check box, this option requires roughly the same space as the source code to create a local database to speed up searching.
Figure 2 engineering settings

Click "OK". After accepting the selection, a new dialog box will pop up. In this dialog box, you can select the file to be read and add it to the project, one way is to enter the name of the source code file in file name and click "add" to add it, you can also use the "add all" and "add Tree" buttons to add all the files in the selected directory to the project, the "add all" option will prompt you to add the top-level file and recursively add all files. The "add Tree" is equivalent to the recursion of the "add all" option to add all files, it can be used as needed. For me, I prefer "add tree. Because this program uses part of the file opening method, unused files will not be opened, so you do not have to worry about joining thousands of files beyond the maximum allowed by the program, I added the Four thousand five hundred and ninety-one files in the linux2.4 kernel using the "add Tree" method.

Figure 3 add a file

After adding the file, click a file to display the user interface, as shown in Figure 4. the window on the right (Linux project, that is, the project window) all files in the current project are listed alphabetically by default.

Figure 4 work window

Click a file to open the file, as shown in Figure 5. In the window to the right, all files can be listed in the file list, with a row of buttons Under each form, the windows (21142.c) on the left are as follows: all tags are listed alphabetically, marked in order of the number of rows in the file, marked by type, viewed locally, and marked window properties. The windows (Linux project) on the right are as follows: file list in alphabetical order, display folder, classify files by file type, all mark lists of all files, mark by TAG type, jump to definition, display tag information, browse project tag, search for function calls and engineering properties, all the tag list options of all files may take some time to extract tags and synchronize them to the database. If you choose to create a tag database, the synchronization time will be saved in the future, the most useful method is browsing Tag Information and searching function calls. The former can use the "jump" button to find the same tag in different places, you can also use the "Reference" button in combination with the latter to perform global tag search.

The reference feature is one of the characteristics of source insight. It can find all the tags in the project at extremely fast speeds and add a small red arrow button link to the front of the program. Figure 6 is the result of a reference search. It can be displayed in two modes, one is to show the results in a centralized manner. Figure 6 shows this mode. In this mode, you can use the red arrow button on the front to enter another mode. You can also click the Red Arrow to enter the mode where the tag is located, you can also use the two red arrows on the toolbar to move forward and backward in the second mode to view the corresponding information. Its powerful function makes reading the Linux source program as a godlike. However, when the second "Reference" is performed, it prompts you to append the result set to the end of the first result set or replace the first result set. If the former is selected, the result set cannot be classified based on the two search results before and after, and then moved in its subclass. It can only be moved in the entire result set. If the latter is selected, the result set will be replaced with the result of the second search, which is slightly inconvenient.

Figure 6 search results of reference

Source insight settings

1, Background Color Selection
To change the background color options> preference> Windows Background> color, set the background color.

2. Solve the Problem of equal-width alignment of characters.
The default SIS font is verdana, which is very beautiful. This web page should also use verdana fonts. But for the sake of beauty, verdana fonts are not wide. For example, the following two rows
Llllllllll
Mmmmmmmm
The length is also 10 characters, which is too long. verdana is used to check the program, and some of them should be aligned. The method of liberation is to use an equal-width font, but it must be ugly. Courier New is recommended. 3. Solve the tab key indent Problem
Options-> in the editing options column in the lower-right corner of document options, check expand tabs, and then confirm. OK. Now the tab key indent and four spaces indent appear aligned in SIS. 4. Automatic Alignment settings in Si:
In the C program, if a statement without a semicolon at the end of a row, such as if, while, or switch, is written to the end of the row and press enter, the new row is automatically indented to the previous row.
Option-> auto indient type in auto indient under document option has three types: None, simple, and smart. The simple type is recommended for individuals. 5. When adding files to a project, add only specific types of files (File Type Filter)
When editing assembly code, when creating a project in SIS and adding a tree, all Assembly files in the tree are not included according to the default settings.
Only. INC and. ASM suffixes are added. s suffixes are not added. In addition, the. s file opened with sis is black and white, and there is no color. It feels like it is back to the edit age of dos ......
Solution: In options-> document options, click the document type drop-down menu on the left and select x86 ASM source file,
Then add *. s; To *. ASM; *. Inc; in the file filter on the right, and then close.
The above problem is solved, but note that after adding *. S, you need to add the tree again to add the assembly to the project. 6. Add file types
You can define your own types, options-> document options-> Add type, and define the file type name and file name suffix.
Select include when adding to projects and add files under the Add directory to the project. This type of files will be added to the SI project.
If you want to add all files to the SI project, you can define a file type *.*. 7. Restore the full selection function of Ctrl +
Use the keyword save to find save all, change it to Ctrl + Shift + A, select all through the keyword select, and change it to Ctrl +

Common shortcut keys for source insight:
CTRL + =: Jump to definition
Alt +/: Look up reference
F3: Search backward
F4: search forward
F5: go to line
F7: Look up symbols
F8: Look up local symbols
F9: IDENT left
F10: IDENT right
Alt +,: Jump Backword
Alt +.: jump forward
Shift + F3: Search the word under cusor backward
Shift + F4: Search the word under cusor forward
F12: incremental search
Shift + Ctrl + F: Search in Project
Shift + F8: hilight word

Window operations of source insight:
Project window Ctrl + O open
Symbol window Alt + F8 Open and Close
Contex window custom key opening and closing
The Relation window custom key is opened, locked first, and then refreshed.

To add a custom feature to source insight, follow these steps:
1. In source insight, options-> Custom commands...-> Add..., new command name can be written at will. My name is "Edit with vim"
2. Run: "C: \ Program Files \ Vim \ vim63 \ gvim.exe" -- remote-silent + % L % F
This indicates opening the current file in the currently opened gvim window and redirecting to the specified row.
% L is the current row number, and % F is the file name
The function of using -- remote-silent is to jump to the corresponding row instead of opening the corresponding file for the second time.
3. In the same dialog box, select Keys-> assign new key...-> press F12. If you have set F12 to another command, select another key.

The following are some common custom functions: (custom commands)

Open Resource Manager and select the current file
ShellExecute open Explorer/e,/select, % F
View log
"C: \ Program Files \ tortoisesvn \ bin \ tortoiseproc.exe"/command: log/path: % F/notempfile/closeonend
Diff
"C: \ Program Files \ tortoisesvn \ bin \ tortoiseproc.exe"/command: Diff/path: % F/notempfile/closeonend
Get the lock (check out)
"C: \ Program Files \ tortoisesvn \ bin \ tortoiseproc.exe"/command: Lock/path: % F/notempfile/closeonend
Submit (check in)
"C: \ Program Files \ tortoisesvn \ bin \ tortoiseproc.exe"/command: commit/path: % F/notempfile/closeonend
Update)
"C: \ Program Files \ tortoisesvn \ bin \ tortoiseproc.exe"/command: update/path: % F/notempfile/closeonend
Update all)
"C: \ Program Files \ tortoisesvn \ bin \ tortoiseproc.exe"/command: update/path: *. */notempfile/closeonend
Undo check out)
"C: \ Program Files \ tortoisesvn \ bin \ tortoiseproc.exe"/command: Revert/path: % F/notempfile/closeonend
Edit in ultriedit
"C: \ Program Files \ UltraEdit-32/uedit32" % F
Edit and locate the current row in VIM
"C: \ Program Files \ Vim \ vim63 \ gvim.exe" -- remote-silent + % L % F

Other tips:

Make {And} unindent:

Options-> document options-> auto indent-> indent open brace/indent close Brace

Hao space: sourceinsight tips
1. Press ctrl and point to a variable. Click it to enter the definition of the variable.

2. Today, I opened a c file neatly formatted with sourceinsight and accidentally opened it with VC. After studying for half a day, we found that Si has different width for each character.
Ask your colleagues to find that you can choose "View --> draft View" to make the width of each character consistent. The shortcut key is "Alt + F12"

3. "Shift + F8" highlight all words in the text where the cursor is located

4. Jump to a line: "Ctrl + G"

 

Source insight is a good tool for reading and writing code. It is basically a classic. Although there is still a small bug, it is not necessary for these C programmers. The following tips are summarized by colleagues at work, which is helpful for improving work efficiency. Some of them correspond to SVN, users who do not use SVN for version management should not waste effort.

ShellExecute open Explorer/e,/select, % F
/* The function is to open the current editing file in the resource manager and select */
/* You can set the shortcut key, such as Ctrl + E, to easily open the corresponding file in the resource manager and perform tortoisesvn operations */

X: \ progra ~ 1 \ tortoisesvn \ bin \ tortoiseproc.exe/command: log/path: %/notempfile/closeonend
/* Change the corresponding bin installation path before use */
/* Directly view the svn log of the current file */
/* Shortcut keys such as Ctrl + L */

X: \ progra ~ 1 \ tortoisesvn \ bin \ tortoiseproc.exe/command: Diff/path: %/notempfile/closeonend
/* Change the corresponding bin installation path before use */
/* View the comparison between the current file and the reference version */
/* Shortcut keys such as Ctrl + D */

File filter in source insight

When creating a new project, you need to add some addition. c. files other than H, such. S ,. such as SCF, makefile, and releasenotes.Shown only known document types, And after clicking Add all, selectRecusively add lower sub-Directories, AlsoStill unable to recognize such files normallyYou can only manually double-click the project to add it to the project. It doesn't matter if there are few files, but it does not matter if there are many large projects that contain subfolders.

Baidu finally found the solution:

Open source insight and enter

Options->Document options... alt-T-> ClickDocument TypeAnd then select make file.File FilterAdd a semicolon after the original *. Mak, that isSeparate multiple filter rules with semicolons, Add * makefile to *. Mak; * makefile, and selectInclude when adding to projectsIn this way, you can identify makefile or makefile when creating a project later (as if source insight is not case sensitive ).

Similar principle: add different types of files you want to add to the backend of some original file types respectively. Be sure to separate them with semicolons or directly create a new file type, then write the corresponding concern rules, such

Click Add type and enter the name of the new file type scatter file,Write *. SCF in the file filter, and select include when adding to projects next to it.A new file type is created. When a new project is added to a file, the system will be able to identify files with a suffix of SCF.

Of course, if you are interested, you can also perform some formatting settings for the new file type. Including parsing and Tab settings.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.