SourceInSight自定义命令说明与应用
?
1.自定義命名設(shè)置界面(Tool -> Custom Commands...)
Command
顯示當(dāng)前選中命令的名字. 下拉列表中包含了所有的自定義命令.
Run
命令行,當(dāng)調(diào)用自定義命令時,這個命令行就會被執(zhí)行. 命令行中可以包含特殊的元字符. 詳見 “The 'Run' Field Format”.
Dir
設(shè)定命令行執(zhí)行時的工作目錄.
Source Insight 會在命令行執(zhí)行前將當(dāng)前工作目錄設(shè)置為此處設(shè)定的值.
如果是空的,那么Source Insight 會將當(dāng)前工作目錄設(shè)置為工程源碼目錄.
Output Group
這組選項控制命令輸出.
Iconic Window(窗口顯示模式)
啟動此項, 命令執(zhí)行產(chǎn)生的窗口是最小化的,Source InSight仍是當(dāng)前活動窗口;
不啟動此項, 命令執(zhí)行產(chǎn)生的窗口取代Source InSight成為當(dāng)前活動窗口.
舉例來說,比如命令是打開Windows資源管理器,
啟用此項后,Windows資源管理器被打開,但是窗口是最小化的;
不啟動此項, Windows資源管理器正常打開,窗口顯示Source InSight前面.
Capture Output
啟用此項后,當(dāng)命令執(zhí)行完成后,命令的標(biāo)準(zhǔn)輸入會被捕捉并且顯示在一個新的命令輸入窗口中,這個窗口的標(biāo)題是自定義命令的名字.
不啟動此項, 不會捕捉標(biāo)準(zhǔn)輸出.
Paste Output
啟用此項后,命令的標(biāo)準(zhǔn)輸出會被粘貼到當(dāng)前的選擇區(qū)域.
Control Group
這組選項控制Source Insight在命令執(zhí)行前后做什么處理
Save Files First
啟用此項后,Source Insight 會在命令執(zhí)行前 執(zhí)行'Save All'(Ctrl+Shift+S)命令.
'Save All' 命令會提示你每一個被更改的文件來讓你確認(rèn)是否要保存.
不啟動此項, 命令執(zhí)行時不會保存任何改動過的文件. 未保存的‘變化’在命令結(jié)束后仍然保留 .
如果命令導(dǎo)致Source Insight崩潰,Source Insight可以恢復(fù),未保存的‘變化’也是完好的.
Pause When Done
啟用此項后, 當(dāng)命令結(jié)束后,Source Insight 會在DOS窗口中顯示下面的消息:
Press any key to return to Source Insight...不啟動此項, DOS窗口會在命令結(jié)束后關(guān)閉.
Beep When Done
啟用此項后, Source Insight 會在命令結(jié)束后發(fā)出beep音.
Wait Until Done
啟用此項后,Source Insight 會掛起(suspend)直到命令結(jié)束.
不啟動此項, 你可以切換回Source Insight窗口繼續(xù)工作,命令會在后臺繼續(xù)執(zhí)行 .
Exit Source Insight
命令執(zhí)行后Source Insight 會關(guān)閉.
Source Links in Output
你可以使用這些選項來處理命令結(jié)束后的輸出.
你可以讓Source Insight 分析捕捉到的輸出,從中找出你指定的內(nèi)容,例如某些警告或者錯誤信息.
Parse Source Links
The command output will be searched for source link patterns. The patterns typically will match warning and error messages. If a pattern match is found, Source Insight inserts a source link at that line. The source link is used to link the warning or error message to its target source line. If Parse Source Links is enabled, you must have a valid search expression in the Pattern text box.
Pattern contains
File, then Line and Line, then File. This indicates the order of the groups in the pattern expression.
Select File, then Line if the first group in the pattern expression is the file name and the second group is the line number. With this setting, the second group, (i.e. the line number), is optional.
Select Line, then File if the first group in the pattern expression is the line number and the second group is the file name.
Pattern
Contains the regular expression used to search the command output for file names and line numbers.
如果 Parse Source Links 選項未啟用,Source Insight會忽略Pattern;
如果 Parse Source Links 選項啟用了,那么Pattern處必須填入一個有限的正則表達(dá)式(that contains “groups” for the file name and the line number.
Add…
添加一個自定義命令.
Remove
刪除當(dāng)前自定義命令.
Close
退出設(shè)定.
Help
查看自定義命令的幫助文檔,即本文.
Run
運行當(dāng)前自定義命令.
Menu…
將自定義命令導(dǎo)入Source Insight菜單.
Keys…
給當(dāng)前命令設(shè)定快捷鍵.
?
2.自定義命令的格式
可以包含多個命令,命令之間使用分號分割, 例如:
cat make.log;echotimeThis string causes “cat make.log” to execute, followed by “echotime”.
?
?
?3.Running the Command Shell
如果你想運行windows的DOS命令, 例如 “type”、 “dir”, 或者你想運行一個批處理文件,
那么你必須使用cmd.exe來運行他們. 請看下面的例子:
Note: 如果你是用的是 Windows 9x/Me, 你應(yīng)該使用command.com 代替 cmd.exe.
If the Run string contains more than one command, separated by semi-colons, you don’t need to run cmd.exe because Source Insight creates a batch file from the run string commands and runs command.com automatically in that case. For example,
cat readme.txt;dirThis works fine because it is already running in a batch file inside a shell.
You may find that the shell you spawned by cmd.exe does not have enough environment space. If that happens, use the /e switch with cmd.exe. For example,
cmd /e:1024 /c mybat.batThis allocates 1K bytes of environment space to the new sub shell spawned by command.com.
?
?4.Command Line Substitutions
The Run text box can contain meta-characters that cause the following items to be substituted in the string.
Table 1: Custom Command Meta-Characters
| Character | Expands to | Example |
| %f | 當(dāng)前文件的完整路徑名 【*】 | c:\myproj\file.c |
| %r | 當(dāng)前文件相對于工程源碼目錄的相對路徑名 【*】 | file.c |
| %n | leaf name of the current file 【*】 | file.c |
| %d | 當(dāng)前文件所在的完整路徑名 | c:\myproj |
| %h | 當(dāng)前文件的路徑名(無磁盤驅(qū)動器字符) | \myproj |
| %b | 當(dāng)前文件名(無后綴名) 【*】 | file |
| %e | 當(dāng)前文件的后綴名 | c (file.c 的文件后綴名為 c) |
| %c | 當(dāng)前文件所在的磁盤驅(qū)動器字符 | c: (表示當(dāng)前文件在磁盤驅(qū)動器C:下) |
| %p | 當(dāng)前項目名稱(包含完整路徑) | c:\myproj\myproj |
| %j | 當(dāng)前項目的源碼路徑 | c:\myproj |
| %J | 當(dāng)前項目的數(shù)據(jù)路徑 | C:\Documents and Settings\Jim Smith\My Documents\Source Insight\Projects\Base |
| %v | 當(dāng)前項目源碼所在的磁盤驅(qū)動器字符 | c: |
| %o | 當(dāng)前項目的名稱(不包含路徑) | myproj |
| %l | 當(dāng)前行號 | 行號 |
| %w | 選擇區(qū)域的第一個單詞,或者光標(biāo)處的單詞 | 任何單詞 |
| %s | 自定義命令運行時,保存當(dāng)前選擇的臨時文件名. | d:\tmp\vt0004. |
| %a | 當(dāng)前日期 | 05-12-02 |
| %t | 當(dāng)前時間 | 08:23 |
| %1 - %9 | 提示用戶輸入?yún)?shù) | any strings |
You can also postfix any of the above characters marked with * with either of the following modifier characters.
| Character | Expands to | Example |
| %o | 所有打開的文件 | %f%o |
| %m | 所有修改的文件 | %f%m |
?
?
?5.ShellExecute 命令
自定義命令支持 “ShellExecute” 函數(shù), 可以通過他告知 Windows shell 去如果操作一個文件.
ShellExecute的一個優(yōu)點是你不必知道何種應(yīng)用被注冊去處理某種類型的文件.
詳細(xì)技術(shù)資料見Windows Shell API 文檔中的 “ShellExecute” .
“ShellExecute” 的使用方法如下:
ShellExecute <verb> <filespec> <optional parameters>例如使用瀏覽器打開一個網(wǎng)站:
ShellExecute open https://www.baidu.comverb 是一個單詞, 可以是下列其中一個:
? edit 打開一個編輯器來編輯指定的文件.只能是文檔文件(document file)
? explore 使用資源管理器打開指定的文件夾.
? open 打開指定的文件. 文件類型可以是可執(zhí)行文件、 文檔文件(document file) 或者是文件夾.
? print 打印指定的文件,如果文件類型不是文檔文件(document file),函數(shù)會失敗.
? properties 顯示文件或者文件夾的屬性.
? find 加載windows的文件查找功能.
? "" (空字符串) 跳過此參數(shù).
參數(shù) filespec 可以是任意有效的路徑.
如果路徑中有空格,使用雙引號將路徑括起來 你可以使用元字符,例如 %f (當(dāng)前文件). .
The optional parameters list is anything to the right of the filespec. It specifies the parameters to be passed to the application that ultimately runs. The format is determined by the verb that is to be invoked, and the application that runs. You can use custom command meta-characters here as well.
The working directory text box of the custom command is applied before the ShellExecute is invoked. However, output cannot be captured or parsed when using ShellExecute.
?
?
6.ShellExecute 使用例子
下面是幾個使用 ShellExecute 的例子.
| 想要完成的動作 | 執(zhí)行命令例子 |
| 打開一個網(wǎng)站 | ShellExecute open http://www.somewebsite.com |
| To explore your Windows 2000 documents file folder: | ShellExecute explore “C:\Documents and Settings” |
| To explore your Windows 98 documents file folder: | ShellExecute explore “C:\My Documents” |
| 打開瀏覽器 | ShellExecute “” iexplore |
| 在IE瀏覽器中預(yù)覽一個文件 | ShellExecute “” iexplore %f |
| 在當(dāng)前項目目錄搜索文件 | ShellExecute find %j |
?
?
7.后臺運行自定義命令
When Source Insight spawns a Custom Command shell program, it actually runs a program called Sihook3.exe.
Sihook3.exe in turn spawns the command and performs the output capturing.
You can run a custom command and click back on the Source Insight window to continue editing with Source Insight while the custom command runs in the background.
?
轉(zhuǎn)載于:https://www.cnblogs.com/LubinLew/p/SoureInsight-CustomCommand.html
總結(jié)
以上是生活随笔為你收集整理的SourceInSight自定义命令说明与应用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 可立克为什么是5G 产品可用于5G设备上
- 下一篇: 兖州煤业暴涨超20% 竟然要转型做新能源