概   述     
    这将是最简单的一课,但它却能够帮助帮助你更好地组织你的思想和开展工作。

正如我们在第一课中学到的,可以有许多中方式来为手头某个特定的任务定制 CodeWarrior。你可以定制 CodeWarrior 的外观和许多设置项,以便使得编译、连接和调试你的程序变得更快、更简单。

下面我们来看看可用于帮助你更有效地使用 CodeWarrior 的定制选项。因为定制 CodeWarrior 会改变 IDE 的所有行为,所以我们可以想到在编辑菜单下找到这些设置项。在那儿你将找到选择、命令和键绑定(Key Bindings)等菜单。点击其中的命令项就会显示定制 IDE 命令设置的窗口。定制 IDE 命令的面板包含两个主标签页。命令标签页允许你很容易的定制出现在每个 CodeWarrior 菜单中的命令。通过该标签页你也可以修改在内置的文本编辑器中使用的命令,例如选择文本和移动光标等命令。在这个设置窗口中,你还可以创建任何用于触发某个菜单命令项的组合键(也称之为键绑定——key binding),以此来启动一个应用程序,或者执行一个脚本。当然,你也可以设定一个某个命令项是否出现在一个菜单中。

定制 IDE 命令的面板中的另一个标签页是工具条项目标签页,在这个标签页中你可以看到在 CodeWarrior 的工具条中显示的项目,例如显示在每个文本编辑器窗口上方(或下方,取决于你的参数设置)。

在工具条项目标签页中,你只需点击一个工具条图标然后把它拖到主菜单下面的工具条或者文本编辑器窗口的工具条中,就可以往相应的工具条中增加一个命令。还可以把工具条中的一个图标拉到工具条的最后。从 CodeWarrior 的窗口菜单中的工具条子菜单中选择重设窗口的工具条(Reset Window Toolbar) 或重设浮动工具条菜单项,还可以重新设置该工具条。

在大多数情况下,CodeWarrior 的默认设置就可以满足你的要求了。偶尔你也可能发现一个通过改变一个菜单或工具条的方式来自动完成一些任务。关于 Codewarrior 的定制,你可以参考它的在线文档获得更多的信息。

CodeWarrior 定制示例

通过定制 CodeWarrior,你可以增强你的工作环境和提高工作效率。     除了对菜单和工具条的简单修改之外,你可能还想只需点击一个图标或键入一个组合键就可以执行一个脚本或启动一个应用程序。有时当你正在参与一个非常庞大的开发项目的时候,需要做一些定制工作来解决自动设置带来的混乱问题。例如,你可以创建一个脚本来完成以下这些工作:
•自动删除编译过程中产生的多余的文件;  
•将输出文件复制到一个本地或网络上的目录中以做备份;  
•为你的工程创建一个安装应用程序。

对于 Windows 用户而言,可以通过 VBScript,Perl或其它使用通用对象模型(Common Object Model,COM)接口的脚本语言来驱动 CodeWarrior Pro 5 IDE 完成一系列复杂的操作。如果使用 VBscript,你还需要一个可以执行 VBScript 的的应用程序(如 Internet Explorer 5),或者是一个 Scripting Host 工具——可以从以下网址下载 http://msdn.microsoft.com/scripting/windowshost/。

下面的 VBScript 脚本用于指导 CodeWarrior IDE 删除当前工程中的所有目标(object)文件,以便执行一个“干净的构建(build)”,然后再执行构建工作(编译和连接操作)。该脚本还打开一个编辑器窗口来显示操作结果(成功或失败的)的总结。这个脚本是有点长,但设计得很好,因为其中包含了许多用于错误检查的代码。

' 文件名:Build.vbs

' 作者: Jim Trudeau, Metrowerks

' 以及版权声明信息

option explicit

'所有的变量都必须进行声明

dim CW
           dim project                      '默认的工程
      dim textDocument           '用于保存报告的文本文档
      dim textEngine                 '用于处理文本的对象
      dim eol                            '行尾字符格式
      dim result                        '返回的值

eol = chr(13)                     '设置行尾字符

'创建 CodeWarrior 的一个实例
set CW = CreateObject("CodeWarrior.CodeWarriorApp")

'创建一个文本文档并获得其引擎(Engine)
set textDocument = CW.OpenUntitledTextDocument()
set textEngine = textDocument.TextEngine

'得到默认的工程
set project = CW.DefaultProject

'错误控制
if TypeName(project) = "Nothing" then
textEngine.InsertText("Script operates on default project." &eol)     textEngine.InsertText("There must be at least one open project." &eol)
else
dim target   '当前目标
dim buildmessages '错误和警告

'*** 获得当前目标
set target = project.GetCurrentTarget

textEngine.InsertText("Build Information" &eol)

'显示名字
result = target.name

textEngine.InsertText("Building target " &result &eol)

'*** 删除所有的对象代码目标
RemoveObjectCode true

'*** 获得构建代码后的消息
set buildMessages = target.BuildAndWaitToComplete

ProcessMessages (buildMessages)
end if

'========================================================= ' ProcessMessages - get errors and warnings, process them ' receives build messages '=========================================================

sub ProcessMessages (messages)

dim result           '返回值
dim messageList '消息收集

'*** 获得错误的数量
result = messages.ErrorCount

if result = 0 then textEngine.InsertText(eol &"Build Succeeded." &eol)
else textEngine.InsertText(eol &"!!!BUILD FAILED!!!" &eol)

'*** 显示错误的数量
textEngine.InsertText("Number of errors: " &result &eol)

'*** 获得错误清单
set messageList = messages.Errors

'*** 处理错误
ProcessMessageList (messageList)
end if

'*** 检测是否有警告信息
result = messages.WarningCount

'*** 显示数量
textEngine.InsertText("Number of warnings: " &result &eol)

'*** 取得警告信息并处理之
if result then
'*** 获得警告信息清单
set messageList = messages.Warnings

'*** 处理警告信息
ProcessMessageList (messageList)
end if

end sub

'========================================================= ' ProcessMessagelist - loop through messages, report info ' receives message collection, could be errors or warnings '=========================================================

sub ProcessMessageList (messageList)

dim result '返回值
dim index '循环计数器
dim message '个人信息

'*** 遍历消息清单
for index = 0 to messageList.Count-1
'*** 获得个人信息
set message = messageList.Item(index)

'*** 获得消息文本
result = message.MessageText

'*** 显示消息文本
textEngine.InsertText(result &eol)

****在错误中忽略一行(skip a line between errors )
textEngine.InsertText(eol)
next

end sub

因为使用了微软公司的 OLE/COM 查看器工具,这个 IDE 支持许多 COM 对象。一个脚本语言可以使用这些对象来与 CodeWarrior IDE 进行通信。关于 CodeWarrior 定制与脚本机制,还有很多优秀的功能,但在这里就不详述了,因为 CodeWarrior 把这些功能实现得非常好。打开上面所描述到得窗口自己看看吧!当你熟练使用了 CodeWarrior 的一些功能之后,你会发现它是非常的易用!

附原文:

An Introduction to Customization

This will be the simplest lesson, but it will provide you with the flavoring that will help you organize your thoughts and work much better. As I mentioned in Lesson 1, there are many ways to customize CodeWarrior for the specific development task at hand. You can customize the look and feel of CodeWarrior as well as a multitude of options for compiling, linking, and debugging your code faster and more easily. Let's look at some of the customization options available to help you use CodeWarrior more efficiently. Since customizing CodeWarrior affects the IDE's overall behavior, we can expect to find such settings under the Edit menu. There you'll find the menu selection, Commands, and Key Bindings. Pick this item and the Customize IDE Commands settings window appears. The Customize IDE Commands panel contains two main tabs. The Commands tab allows you to easily customize the commands that appear in each CodeWarrior menu. With it you can also modify commands used within the built-in text editor, such as selecting text and moving the cursor. Using this window, you can create any key combination (key binding) that triggers any menu command, launches an application, or executes a script. You can also choose whether an item should appear on a menu. The Toolbar Items tab allows you to see which items appear in various CodeWarrior toolbars, such as the one that appears at the top (or bottom, depending upon your preference) of each text editor window. In the Toolbar Items tab, you can add a command to the toolbar (either the toolbar under the main menu or the text editor's window toolbar) by clicking on a toolbar item icon and dragging it to the toolbar to which you want to add it. Dropping the icon on the toolbar adds it to the end of that toolbar. You can reset the toolbar by selecting Reset Window Toolbar or Reset Floating Toolbar from the Toolbar submenu in the Window menu. In most cases, CodeWarrior's default settings will work for your needs. Every once in a while, you may find a way to automate some task by changing a menu or toolbar. Consult the CodeWarrior online documentation for more information about CodeWarrior customization.

CodeWarrior Customization Examples

By customizing CodeWarrior, you can enhance your work environment and become much more productive. In addition to simple changes to menus and toolbars, you may want to execute a script or launch an application by clicking an icon or typing a key combination. Sometimes, when you work on very large development projects, there is a need to automate more intricately and customize your development environment. For example, you could create a script to do any of the following:
•Automatically delete extra files created by the build process.
•Copy your output file or files to a local or network directory for backup.
•Build an installer application for your project.

For Windows, you can drive the CodeWarrior Pro 5 IDE through a complex sequence of operations using VBScript, Perl, or another scripting language that uses the Common Object Model (COM) interface. For VBScript, you'll need an application that executes VBScript (such as Internet Explorer 5), or the Scripting Host utility, available at http://msdn.microsoft.com/scripting/windowshost/. The following VBScript directs the CodeWarrior IDE to perform a "clean build" by removing all of the object files in the current project, and then executing the build (compile and link operations). The script also opens an editor window and displays a summary of the operation (success or failure). It's a trifle long, but that's fine because the script includes a lot of error-checking code.

' file: Build.vbs

' author: Jim Trudeau, Metrowerks

' and warning messages.

option explicit 'all variables must be declared

dim CW dim project 'default project dim textDocument 'text document object to hold report dim textEngine 'the object for dealing with text dim eol 'end-of-line character for formatting dim result 'returned values

eol = chr(13) 'set end of line character

'create an instance of CodeWarrior set CW = CreateObject("CodeWarrior.CodeWarriorApp")

'create text document and get engine set textDocument = CW.OpenUntitledTextDocument() set textEngine = textDocument.TextEngine

'get the default project set project = CW.DefaultProject

'do some error control here if TypeName(project) = "Nothing" then textEngine.InsertText("Script operates on default project." &eol) textEngine.InsertText("There must be at least one open project." &eol) else dim target 'current target dim buildmessages 'errors and warnings

'*** get the current target set target = project.GetCurrentTarget

textEngine.InsertText("Build Information" &eol)

'display name result = target.name

textEngine.InsertText("Building target " &result &eol)

'*** remove all object code target.RemoveObjectCode true

'*** get messages after building code set buildMessages = target.BuildAndWaitToComplete

ProcessMessages (buildMessages) end if

'========================================================= ' ProcessMessages - get errors and warnings, process them ' receives build messages '=========================================================

sub ProcessMessages (messages)

dim result 'returned values dim messageList 'message collection

'*** get the number of errors result = messages.ErrorCount

if result = 0 then textEngine.InsertText(eol &"Build Succeeded." &eol) else textEngine.InsertText(eol &"!!!BUILD FAILED!!!" &eol)

'*** display number of errors textEngine.InsertText("Number of errors: " &result &eol)

'*** get the list of errors set messageList = messages.Errors

'*** process the errors ProcessMessageList (messageList) end if

'*** determine whether there are warnings result = messages.WarningCount

'*** display number textEngine.InsertText("Number of warnings: " &result &eol)

'*** get warnings and process them if result then '*** get the list of warnings set messageList = messages.Warnings

'*** process the warnings ProcessMessageList (messageList) end if

end sub

'========================================================= ' ProcessMessagelist - loop through messages, report info ' receives message collection, could be errors or warnings '=========================================================

sub ProcessMessageList (messageList)

dim result 'returned values dim index 'loop counter dim message 'individual message

'*** walk through the list of messages for index = 0 to messageList.Count-1 '*** get the individual message set message = messageList.Item(index)

'*** get the text of the message result = message.MessageText

'*** display the message text textEngine.InsertText(result &eol)

'skip a line between errors textEngine.InsertText(eol) next

end sub

Using Microsoft's OLE/COM Viewer utility, the IDE supports a large number of COM objects. A scripting language can use these objects to communicate with the CodeWarrior IDE. There is a lot here regarding CodeWarrior scriptability and customization, but there isn't much to say about it, since CodeWarrior implements it so elegantly. Open the windows described above and explore! You will find that CodeWarrior is even easier to use when you have precise control over some of its functions!

CodeWarrior 使用教程第六课:定制相关推荐

  1. TurboLinux入门教程:第六课Linux与其他操作系统的区别(转)

    TurboLinux入门教程:第六课Linux与其他操作系统的区别(转) 第六课 Linux 与其他操作系统的区别 目前运行在 PC 机上的操作系统主要有 Microsoft 的 MS-DOS . W ...

  2. 前端React教程第六课 认识栈调和、setState和Fiber架构

    10 React 中的"栈调和"(Stack Reconciler)过程是怎样的? 时下 React 16 乃至 React 17 都是业界公认的"当红炸子鸡" ...

  3. MT4/MQL4入门到精通EA教程第六课-MQL语言常用函数(六)-常用订单功能函数

    bool OrderClose() 平仓函数,该函数有5个参数 bool OrderClose( int ticket, // 订单号double lots, // 手数double price, / ...

  4. 前端React教程第六课 虚拟DOM

    09 真正理解虚拟 DOM:React 选它,真的是为了性能吗? 在过去的十年里,前端技术日新月异.从最早的纯静态页面,到 jQuery 一统江湖,再到近几年大火的 MVVM 框架--研发模式升级这件 ...

  5. TurboLinux入门教程:第七课TurboLinux简介(转)

    TurboLinux入门教程:第七课TurboLinux简介(转) 第七课 TurboLinux简介 TurboLinux是拓林思公司最近发行的linux版本,已在日本和中国取得了巨大的成功,在美国也 ...

  6. NeHe OpenGL教程 第三十六课:从渲染到纹理

    转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...

  7. 以太坊构建DApps系列教程(六):使用定制代币进行投票

    在本系列关于使用以太坊构建DApps教程的第5部分中,我们讨论了如何为Story添加内容,查看如何添加参与者从DAO购买代币的功能以及在Story中添加提交内容.现在是编写DAO最终形式的时候了:投票 ...

  8. NeHe OpenGL教程 第二十六课:反射

    转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...

  9. ionic入门教程第十六课-在微信中使用ionic的解决方案(按需加载加强版)

    对于微信端来说,其实使用ionic是一个比较大的前端框架. 有更多比较轻量化的前端框架可以选择. 但是使用ionic有一个明显的优点就是,能够做到一端开发,三端同步上线. 这个梗说了好多遍了,但确实是 ...

最新文章

  1. Python网络数据采集2-wikipedia
  2. Linux最常用命令:简单易学,但能解决95%以上的问题
  3. java nextline没有停住_java中使用nextLine(); 没有输入就自动跳过的问题?
  4. SAP fiori backend determine cache setting
  5. RocketMQ消费者是如何获取消息的?转疯了!
  6. JPA 系列教程12-复合主键-2个@Id+@IdClass
  7. 四平方和(程序设计)
  8. HBase之MemStore flush流程
  9. 02205微型计算机原理与接口技术自考,2012年微型计算机原理与接口技术自考题模拟(2)...
  10. win7无线局域网_局域网共享一键修复 19.3.13(推荐更新)
  11. docker修改服务器防火墙,docker宿主机iptables配置
  12. 如何让房间每一个角落都充满 Wi-Fi?
  13. openlayers中绘制态势箭头、进击箭头、钳击箭头等
  14. 中秋节后如何有面子的带女票回家?
  15. 【缓存】@CacheEvict
  16. Filebeat is unable to load the Ingest Node pipelines for the configured modules
  17. 什么是HTTP HOST
  18. 招聘网站的几个新控件(2)
  19. DMC-Net: Generating Discriminative Motion Cues for Fast Compressed Video Action Recognition 论文赏析
  20. token代替session使用

热门文章

  1. 有没有简单易懂不枯燥的Java入门教程?
  2. 入门CG板绘须知:学插画需要学好素描吗?
  3. 互联网最后一个绯闻女友出嫁 大众点评联姻腾讯
  4. Django项目的创建、Admin后台系统以及数据库迁移
  5. 微信小程序使用腾讯位置服务地图选点实现地址的选取|微信小程序腾讯位置服务地图选点请求来源未被授权
  6. 软件著作权保护的内容
  7. LW_OOPC.H 面向对象C MISOO 头文件
  8. 基于高斯塞德尔方法的超松弛迭代法MATLAB实现
  9. 复古高冷风视频调色luts预设
  10. 全面回顾2022年加密行业大事件:破后而立方能绝处逢生