• Source Insight 自定义命令说明


    1.Custom Command Dialog box

    Command

    显示当前选中命令的名字. 下拉列表中包含了所有的自定义命令.

    Run

    命令行,当调用自定义命令时,这个命令行就会被执行. 命令行中可以包含特殊的元字符. 详见 “The 'Run' Field Format”.

    Dir

    设定命令行执行时的工作目录.
    Source Insight 会在命令行执行前将当前工作目录设置为此处设定的值. 
    如果是空的,那么Source Insight 会将当前工作目录设置为工程源码目录.

    Output Group

    这组选项控制命令输出.

    Iconic Window(窗口显示模式)

    启动此项, 命令执行产生的窗口是最小化的,Source InSight仍是当前活动窗口;
    不启动此项, 命令执行产生的窗口取代Source InSight成为当前活动窗口.
    举例来说,比如命令是打开Windows资源管理器,
    启用此项后,Windows资源管理器被打开,但是窗口是最小化的;
    不启动此项, Windows资源管理器正常打开,窗口显示Source InSight前面.

    Capture Output

    启用此项后,当命令执行完成后,命令的标准输入会被捕捉并且显示在一个新的命令输入窗口中,这个窗口的标题是自定义命令的名字.
    不启动此项, 不会捕捉标准输出.

    Paste Output

    启用此项后,命令的标准输出会被粘贴到当前的选择区域.

    Control Group

    这组选项控制Source Insight在命令执行前后做什么处理

    Save Files First

    启用此项后,Source Insight 会在命令执行前 执行'Save All'(Ctrl+Shift+S)命令. 
    'Save All' 命令会提示你每一个被更改的文件来让你确认是否要保存.
    不启动此项, 命令执行时不会保存任何改动过的文件. 未保存的‘变化’在命令结束后仍然保留 . 
    如果命令导致Source Insight崩溃,Source Insight可以恢复,未保存的‘变化’也是完好的.

    Pause When Done

    启用此项后, 当命令结束后,Source Insight 会在DOS窗口中显示下面的消息:

    Press any key to return to Source Insight...

    不启动此项, DOS窗口会在命令结束后关闭.

    Beep When Done

    启用此项后, Source Insight 会在命令结束后发出beep音.

    Wait Until Done

    启用此项后,Source Insight 会挂起(suspend)直到命令结束.
    不启动此项, 你可以切换回Source Insight窗口继续工作,命令会在后台继续执行 .

    Exit Source Insight

    命令执行后Source Insight 会关闭.

    Source Links in Output

    你可以使用这些选项来处理命令结束后的输出. 
    你可以让Source Insight 分析捕捉到的输出,从中找出你指定的内容,例如某些警告或者错误信息.

    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处必须填入一个有限的正则表达式(that contains “groups” for the file name and the line number.

    Add

    添加一个自定义命令.

    Remove

    删除当前自定义命令.

    Close

    退出设定.

    Help

    查看自定义命令的帮助文档,即本文.

    Run

    运行当前自定义命令.

    Menu

    将自定义命令导入Source Insight菜单.

    Keys

    给当前命令设定快捷键.


    2.The 'Run' Field Format

    The Run text box contains the command line to execute when the custom command is invoked. 可以包含多个命令,命令之间使用分号分割, 例如:

    cat make.log;echotime

    This string causes “cat make.log” to execute, followed by “echotime”.


     3.Running the Command Shell

    如果你想运行windows的DOS命令, 例如 “type”、 “dir”, 或者你想运行一个批处理文件, 
    那么你必须使用cmd.exe来运行他们. 请看下面的例子:

    cmd /c mybat.bat 
    cmd /c type foo.txt

    Note: 如果你是用的是 Windows 9x/Me, 你应该使用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;dir
    

    This 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.bat
    

    This 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

    当前文件的完整路径名 【*】

    c:myprojfile.c

    %r

    当前文件相对于工程源码目录的相对路径名 【*】

    file.c

    %n

    leaf name of the current file *

    file.c

    %d

    当前文件所在的完整路径名

    c:myproj

    %h

    directory path of current file without the drive letter

    myproj

    %b

    leaf name of current file w/o extension *

    file

    %e

    extension of the current file

    c

    %c

    drive letter of the current file

    c:

    %p

    the current project name

    c:myprojmyproj

    %j

    the source directory of the current project

    c:myproj

    %J

    the data directory of the current project

    C:Documents and SettingsJim SmithMy DocumentsSource InsightProjectsBase

    %v

    the drive letter of the current project’s source directory

    c:

    %o

    leaf name of the project without path

    myproj

    %l

    当前行号

    行号

    %w

    选择区域的第一个单词,或者光标处的单词

    任何单词

    %s

    自定义命令运行时,保存当前选择的临时文件名.

    d: mpvt0004.

    %a

    当前日期

    05-12-02

    %t

    当前时间

    08:23

    %1 - %9

    提示用户输入参数

    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 Commands

    自定义命令支持 “ShellExecute” 函数, 可以通过他告知 Windows shell 去如果操作一个文件. 
    ShellExecute的一个优点是你不必知道何种应用被注册去处理某种类型的文件. 
    详细技术资料见Windows Shell API 文档中的 “ShellExecute” .

    “ShellExecute” 的使用方法如下:

    ShellExecute <verb> <filespec> <optional parameters>

    例如使用浏览器打开一个网站:

    ShellExecute open https://www.baidu.com

    verb 是一个单词, 可以是下列其中一个:

     edit 打开一个编辑器来编辑指定的文件.只能是文档文件(document file)

     explore 使用资源管理器打开指定的文件夹.

     open 打开指定的文件. 文件类型可以是可执行文件、 文档文件(document file) 或者是文件夹.

     print 打印指定的文件,如果文件类型不是文档文件(document file),函数会失败.

    • properties 显示文件或者文件夹的属性.

     find 加载windows的文件查找功能.

     "" (空字符串) 跳过此参数.

    参数 filespec 可以是任意有效的路径. 
    如果路径中有空格,使用双引号将路径括起来 你可以使用元字符,例如 %f (当前文件). .

    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 Examples

    Here are some useful examples showing how to use ShellExecute.

    Action

    Custom Command Run String

    To browse to a web site:

    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”

    To launch Internet Explorer:

    ShellExecute “” iexplore

    To preview a file in Internet Explorer:

    ShellExecute “” iexplore %f

    To search for files in the current project folder:

    ShellExecute find %j


    7.Running Custom Commands in the Background

    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.

    ref: http://www.cnblogs.com/LubinLew/p/SoureInsight-CustomCommand.html

  • 相关阅读:
    jQuery函数继承 $.extend, $.fn.extend
    [原创]茗洋AaronYang的 jquery.myselect.js 我的一次前端突破[上]
    EasyUI 的 combotree 加载数据后折叠起来,并且只允许单击子节点的写法
    判断js数组包是否包含某个元素
    JS中 HTMLEncode和HTMLDecode
    Easyui datagrid 特殊处理,记录笔记
    easyui tab上面添加右键菜单
    第三方文本框 在div中显示预览,让指定节点不受外部css影响
    Easyui 让Window弹出居中
    C# txt格式记录时间,时间对比,决定是否更新代码记录Demo
  • 原文地址:https://www.cnblogs.com/listenerln/p/7365727.html
Copyright © 2020-2023  润新知