﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-gyn</title><link>http://www.cnitblog.com/gyn/</link><description>Win32下的Perl，无用的select，停滞的Tk，结束吧....</description><language>zh-cn</language><lastBuildDate>Wed, 29 Apr 2026 06:00:47 GMT</lastBuildDate><pubDate>Wed, 29 Apr 2026 06:00:47 GMT</pubDate><ttl>60</ttl><item><title>TclTk Socket编程的测试</title><link>http://www.cnitblog.com/gyn/archive/2010/03/25/64822.html</link><dc:creator>gyn_tadao</dc:creator><author>gyn_tadao</author><pubDate>Thu, 25 Mar 2010 07:04:00 GMT</pubDate><guid>http://www.cnitblog.com/gyn/archive/2010/03/25/64822.html</guid><wfw:comment>http://www.cnitblog.com/gyn/comments/64822.html</wfw:comment><comments>http://www.cnitblog.com/gyn/archive/2010/03/25/64822.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cnitblog.com/gyn/comments/commentRss/64822.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/gyn/services/trackbacks/64822.html</trackback:ping><description><![CDATA[最近写了一个tcltk的rpc脚本，用来远程执行tcl脚本。基本上的思路就是，客户端发出一连串的脚本命令，只要是tcl的都行，函数啊什么的；服务
器端接受后，检测一下，没有语法错误的话，就把运行结果返回给客户端，同时清空缓冲区并等待接下来接收的命令。具体的解释以后再说，也可能不写了。我的想
法是把这个脚本安在一个服务器上，作为一个以tcl脚本为基础的通用服务，执行来自不同客户端的各个任务。<br />
大抵这种两端跑的程序，写的时候没什么，测试的时候就颇为麻烦了。开两个cmd，一边一个server，另一边client，完了为了停下来还得两头按
Control-C，真是一个手忙脚乱啊！<br />
我想这样的测试，一般都是起了服务端，再客户端发一些命令，然后看接受效果就差不多了。完全可以搞在一起，把测试弄成一个脚本来执行，完了一起退出。当然
服务器端脚本和客户端脚本要在不同的环境中运行。这里有两个选择，要么建两个interp，要么用多线程。前段时间用interp用得有点腻味，包括这个
rpc脚本也是用interp来处理不同的客户端连接的，所以这次换用多线程。具体的脚本如下，存为test_in_thread.tcl文件：<br />
package require Thread<br />
package require ltools<br /><br />
foreach file $argv command {server_commands client_commands} {<br />
    set $command "source $file"<br />
}<br /><br />
set serv_thread [thread::create $server_commands]<br />
set cli_thread  [thread::create $client_commands]<br /><br />
after 5000 {<br />
    leach [list $::cli_thread $::serv_thread] [@ {thread} {<br />
        thread::release $thread<br />
    }]<br />
    set delay 1<br />
}<br /><br />
vwait delay<br />
其实很简单，执行的参数包含两个脚本名，分别是服务器端和客户端的；接着，起两个线程，程序等待在delay变量上，5秒之后重设delay并完成退出。
这样以后测试socket程序就方便多了。如上面说的rpc程序，写完之后运行：tcl86 test_in_thread.tcl rpc.tcl 
rpc_test.tcl，看看结果就行了。<br /><a href="/Files/gyn/test_in_threads.rar">附件下载</a><br /><img src ="http://www.cnitblog.com/gyn/aggbug/64822.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/gyn/" target="_blank">gyn_tadao</a> 2010-03-25 15:04 <a href="http://www.cnitblog.com/gyn/archive/2010/03/25/64822.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tcl闭包</title><link>http://www.cnitblog.com/gyn/archive/2010/03/15/64656.html</link><dc:creator>gyn_tadao</dc:creator><author>gyn_tadao</author><pubDate>Mon, 15 Mar 2010 12:26:00 GMT</pubDate><guid>http://www.cnitblog.com/gyn/archive/2010/03/15/64656.html</guid><wfw:comment>http://www.cnitblog.com/gyn/comments/64656.html</wfw:comment><comments>http://www.cnitblog.com/gyn/archive/2010/03/15/64656.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/gyn/comments/commentRss/64656.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/gyn/services/trackbacks/64656.html</trackback:ping><description><![CDATA[
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="ProgId" content="Word.Document" />
		<meta name="Generator" content="Microsoft Word 11" />
		<meta name="Originator" content="Microsoft Word 11" />
		<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" />
		<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>0</w:Zoom>
  <w:PunctuationKerning/>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
		<!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
		<style>
				<!--
 /* Font Definitions */
 @font-face
	{font-family:华文中宋;
	panose-1:2 1 6 0 4 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:647 135200768 16 0 262303 0;}
@font-face
	{font-family:"\@华文中宋";
	panose-1:2 1 6 0 4 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:647 135200768 16 0 262303 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	font-size:10.5pt;
	mso-bidi-font-size:12.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:华文中宋;
	mso-bidi-font-family:"Times New Roman";
	mso-font-kerning:1.0pt;}
 /* Page Definitions */
 @page
	{mso-page-border-surround-header:no;
	mso-page-border-surround-footer:no;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:36.0pt;
	mso-footer-margin:36.0pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
		</style>
		<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]-->
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">Tcl</span>
				<span style="font-family: 华文中宋;">中没有闭包，但是以字符串为基础的构建使得类似功能的实现并不是一件很困难的事情。在平时的</span>
				<span lang="EN-US">coding</span>
				<span style="font-family: 华文中宋;">中倒是经常为一些</span>
				<span lang="EN-US">Tcl</span>
				<span style="font-family: 华文中宋;">的规则所困扰。比如说，需要一个用过即丢弃的功能，由于</span>
				<span lang="EN-US">Tcl</span>
				<span style="font-family: 华文中宋;">并没有匿名函数一说，为此不得不建立一个命名函数，这个随无伤大雅但在代码的结构上看来却有点扎眼，很让人不爽。</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">我没有对闭包做深入的研究，所以对于类似闭包功能的使用，仅仅实现了以下的几个功能。第一，一个容易读懂的代码段；第二，具备上下文环境的信息；第三，可在运行时接收参数。</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">这里所谓容易懂的代码是指不用双引号包围的字符串，虽然使用双引号可以很方便地融入上下文环境中，但是由于转义和执行等情况的存在，不仅不易于编写而且更不容易读明白，因此最好还是用花括号来包围。</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">第二个问题比较麻烦。对于在花括号中定义的字符串，一般可以使用</span>
				<span lang="EN-US">subst</span>
				<span style="font-family: 华文中宋;">来做一些替换工作，但事实上</span>
				<span lang="EN-US">subst</span>
				<span style="font-family: 华文中宋;">除了提供延时替换以及</span>
				<span lang="EN-US">nobackslashes</span>
				<span style="font-family: 华文中宋;">、</span>
				<span lang="EN-US">nocommand</span>
				<span style="font-family: 华文中宋;">控制特征之外，与双引号没有本质上的区别，有些时候甚至不如双引号方便。而即使是用双引号包围了的代码段，依然可能在不经意间造成错误。假设有以下一个程序：</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
		</p>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="ProgId" content="Word.Document" />
		<meta name="Generator" content="Microsoft Word 11" />
		<meta name="Originator" content="Microsoft Word 11" />
		<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" />
		<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>0</w:Zoom>
  <w:PunctuationKerning/>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
		<!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
		<style>
				<!--
 /* Font Definitions */
 @font-face
	{font-family:华文中宋;
	panose-1:2 1 6 0 4 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:647 135200768 16 0 262303 0;}
@font-face
	{font-family:"\@华文中宋";
	panose-1:2 1 6 0 4 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:647 135200768 16 0 262303 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	font-size:10.5pt;
	mso-bidi-font-size:12.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:华文中宋;
	mso-bidi-font-family:"Times New Roman";
	mso-font-kerning:1.0pt;}
 /* Page Definitions */
 @page
	{mso-page-border-surround-header:no;
	mso-page-border-surround-footer:no;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:36.0pt;
	mso-footer-margin:36.0pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
		</style>
		<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]-->
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">set a jack</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">set code “ set a mike; puts $a “</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
		</p>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="ProgId" content="Word.Document" />
		<meta name="Generator" content="Microsoft Word 11" />
		<meta name="Originator" content="Microsoft Word 11" />
		<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" />
		<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>0</w:Zoom>
  <w:PunctuationKerning/>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
		<!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
		<style>
				<!--
 /* Font Definitions */
 @font-face
	{font-family:华文中宋;
	panose-1:2 1 6 0 4 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:647 135200768 16 0 262303 0;}
@font-face
	{font-family:"\@华文中宋";
	panose-1:2 1 6 0 4 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:647 135200768 16 0 262303 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	font-size:10.5pt;
	mso-bidi-font-size:12.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:华文中宋;
	mso-bidi-font-family:"Times New Roman";
	mso-font-kerning:1.0pt;}
 /* Page Definitions */
 @page
	{mso-page-border-surround-header:no;
	mso-page-border-surround-footer:no;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:36.0pt;
	mso-footer-margin:36.0pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
		</style>
		<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]-->
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">在全局环境中，定义了一个值为</span>
				<span lang="EN-US">jack</span>
				<span style="font-family: 华文中宋;">的变量</span>
				<span lang="EN-US">a</span>
				<span style="font-family: 华文中宋;">；接着，又定义了一个名为</span>
				<span lang="EN-US">code</span>
				<span style="font-family: 华文中宋;">的字符串，其中也定义了变量</span>
				<span lang="EN-US">a</span>
				<span style="font-family: 华文中宋;">，但是由于存在转义，事实上这个</span>
				<span lang="EN-US">code</span>
				<span style="font-family: 华文中宋;">变成了：</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">set a mike; puts jack</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">也就是说，如果用</span>
				<span lang="EN-US">code</span>
				<span style="font-family: 华文中宋;">来实现闭包的功能，那么将无法在定义与全局中同名的变量。这显然不是很方便，当在类闭包中定义了一个变量的时候，它的作用域应该是属于当前的，而与外层的环境无关，只有没有显式定义的参数我们才需要将其置换为上下文环境中定义的值。</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">到这里就涉及到一个如何引入上下文环境的问题了，一种就像上面所写的，直接进行变量替换，但是这样做存在副作用；另一种办法是，添加参数定义，即搜索类闭包中的参数，之后在类闭包的开始处添加使用上下文环境的值的定义。还是上面那个例子，使用这个办法，</span>
				<span lang="EN-US">code</span>
				<span style="font-family: 华文中宋;">将变为：</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">set a jack</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">set a mike; puts $a</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">倘若</span>
				<span lang="EN-US">code</span>
				<span style="font-family: 华文中宋;">中没有</span>
				<span lang="EN-US">a</span>
				<span style="font-family: 华文中宋;">的显式定义，则是：</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">set a jack</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">puts $a</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">由于添加的定义永远先于类闭包中代码段的内容，所以无论是否定义同名参数，都不会影响到实际的执行效果。这是一种本地优先的规则，类闭包中没有定义的变量将使用全局替换，而定义了的变量，即使是上下文环境同名变量，依然会使用类闭包中定义的值。</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">显然作为后一种方法，是恰好能满足我们需要的，不过也面临一个问题，即找出在类比包中的变量名。我用了一个正则判断来得到所有的变量，之后进行筛选以剔除重复并使用</span>
				<span lang="EN-US">info</span>
				<span style="font-family: 华文中宋;">函数来验证的确存在该变量。</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">set unique_vars {}</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">foreach w [regexp -all -inline {\$[:\w]+} $code] {</span>
		</p>
		<p class="MsoNormal" style="text-indent: 38.85pt;">
				<span lang="EN-US">foreach u $unique_vars {</span>
		</p>
		<p class="MsoNormal" style="text-indent: 59.85pt;">
				<span lang="EN-US">if {$u == $w} { continue }</span>
		</p>
		<p class="MsoNormal" style="text-indent: 41.05pt;">
				<span lang="EN-US">}</span>
		</p>
		<p class="MsoNormal" style="text-indent: 41.05pt;">
				<span lang="EN-US">lappend unique_vars $w</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">}</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">set buf {}</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">foreach w $unique_vars {</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>set w [string trimleft $w
\$]</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>if [uplevel 1 info exists
$w] {</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">        </span>upvar 1 $w var</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">        </span>set buf "$buf set
$w $var;"<span style="">    </span></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>}</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">}</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">最终得到的</span>
				<span lang="EN-US">buf</span>
				<span style="font-family: 华文中宋;">将被放置在</span>
				<span lang="EN-US">code</span>
				<span style="font-family: 华文中宋;">之前，实现上下文环境对类比包的作用。</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">第三问题说明，这个类闭包可以接收传入参数，比如一个类闭包被赋值给名为</span>
				<span lang="EN-US">lambda</span>
				<span style="font-family: 华文中宋;">的变量，那么它支持形如</span>
				<span lang="EN-US">”yield lambda $var”</span>
				<span style="font-family: 华文中宋;">形式的调用。至于支持传入几个参数，就像</span>
				<span lang="EN-US">proc</span>
				<span style="font-family: 华文中宋;">一样，在定义类闭包的时候需要显式说明。</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">参数传入的实现，在原理上与第二个问题的解决办法类似，但这里的关键在于在与生成的类闭包对象。事实上，该对象包含了两个部分，分别是传入参数的定义和代码段。当执行类闭包的时候，传入的值将和定义的参数结合，被放置于</span>
				<span lang="EN-US">code</span>
				<span style="font-family: 华文中宋;">的前端。</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 华文中宋;">最后为了方便使用，我将创建和运行类闭包的命令</span>
				<span lang="EN-US">fenbie </span>
				<span style="font-family: 华文中宋;">定义为“</span>
				<span lang="EN-US">@</span>
				<span style="font-family: 华文中宋;">”和“</span>
				<span lang="EN-US">~</span>
				<span style="font-family: 华文中宋;">”。以下是一个例子：</span>
		</p>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="ProgId" content="Word.Document" />
		<meta name="Generator" content="Microsoft Word 11" />
		<meta name="Originator" content="Microsoft Word 11" />
		<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" />
		<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>0</w:Zoom>
  <w:PunctuationKerning/>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
		<!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
		<style>
				<!--
 /* Font Definitions */
 @font-face
	{font-family:华文中宋;
	panose-1:2 1 6 0 4 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:647 135200768 16 0 262303 0;}
@font-face
	{font-family:"\@华文中宋";
	panose-1:2 1 6 0 4 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:647 135200768 16 0 262303 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	font-size:10.5pt;
	mso-bidi-font-size:12.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:华文中宋;
	mso-bidi-font-family:"Times New Roman";
	mso-font-kerning:1.0pt;}
 /* Page Definitions */
 @page
	{mso-page-border-surround-header:no;
	mso-page-border-surround-footer:no;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:42.55pt;
	mso-footer-margin:49.6pt;
	mso-paper-source:0;
	layout-grid:15.6pt;}
div.Section1
	{page:Section1;}
-->
		</style>
		<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]-->
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">if 1 {</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>set name1 jack<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>set name2 mike<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>set lamb [ @ {{id 1}} { <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">        </span>if {$id == {}} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">            </span>puts {nothing to
puts}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">            </span>return<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">        </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">        </span>while {$id &gt; 0} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">            </span>puts "hello,
$name1 and $name2"<span style="">     </span><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">            </span>incr id -1<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">        </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>} ]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>~ $lamb</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
		</p>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="ProgId" content="Word.Document" />
		<meta name="Generator" content="Microsoft Word 11" />
		<meta name="Originator" content="Microsoft Word 11" />
		<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" />
		<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>0</w:Zoom>
  <w:PunctuationKerning/>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
		<!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
		<style>
				<!--
 /* Font Definitions */
 @font-face
	{font-family:华文中宋;
	panose-1:2 1 6 0 4 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:647 135200768 16 0 262303 0;}
@font-face
	{font-family:"\@华文中宋";
	panose-1:2 1 6 0 4 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:647 135200768 16 0 262303 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	font-size:10.5pt;
	mso-bidi-font-size:12.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:华文中宋;
	mso-bidi-font-family:"Times New Roman";
	mso-font-kerning:1.0pt;}
 /* Page Definitions */
 @page
	{mso-page-border-surround-header:no;
	mso-page-border-surround-footer:no;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:36.0pt;
	mso-footer-margin:36.0pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
		</style>
		<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]-->
		<span style="font-size: 10.5pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
				<span style="">    </span>puts {}</span>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>foreach id {1 2 3} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">        </span>puts "$id
time(s):"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">        </span>~ $lamb $id<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">        </span>puts {}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<span style="">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">}</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span lang="EN-US">
						<a href="/Files/gyn/closure.rar">closure包下载</a>
						<br />
				</span>
		</p>
		<p>
		</p>
		<p>
		</p>
<img src ="http://www.cnitblog.com/gyn/aggbug/64656.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/gyn/" target="_blank">gyn_tadao</a> 2010-03-15 20:26 <a href="http://www.cnitblog.com/gyn/archive/2010/03/15/64656.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>对在Erlang中用的makefile的一点解释</title><link>http://www.cnitblog.com/gyn/archive/2010/02/24/64375.html</link><dc:creator>gyn_tadao</dc:creator><author>gyn_tadao</author><pubDate>Wed, 24 Feb 2010 05:49:00 GMT</pubDate><guid>http://www.cnitblog.com/gyn/archive/2010/02/24/64375.html</guid><wfw:comment>http://www.cnitblog.com/gyn/comments/64375.html</wfw:comment><comments>http://www.cnitblog.com/gyn/archive/2010/02/24/64375.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/gyn/comments/commentRss/64375.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/gyn/services/trackbacks/64375.html</trackback:ping><description><![CDATA[又重新开始读了《Programming Erlang》，也就又读到了第六章中的makefile，结合学习中的具体情况，略作了修改如下：<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">.SUFFIXES: .erl .beam<br /><br />OUT </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> .</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">beam<br /><br />.erl.beam:<br />    erlc </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">W $</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> ; mv $@ ${OUT}<br /><br />ERL </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> erl </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">boot start_clean<br /><br />MODS </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> kvs<br /><br />all: compile<br /><br />compile: ${MODS:</span><span style="color: rgb(0, 0, 0);">%=%</span><span style="color: rgb(0, 0, 0);">.beam}<br /><br /># application:<br />#     ${ERL} </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">s application start ARG1 ARG2<br /><br />clean:<br />    rm </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">rf </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">.beam erl_crash.dump<br /></span></div><br />跟书里有的一点不同是，我把编译之后的文件转移到了beam文件夹里了，所以为此，在“~/.erlang”中也添加了该路径：<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">path_addz(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">./beam</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).</span></div><br />这样，就方便载入自己编写的模块。最后还是要对以上的makefile稍作解释，以便以后忘了可以看看。<br />.SUFFIX声明要用到的或者将生成的文件的类型；.erl.beam是指.beam依赖于.erl，紧接着下一行一个tab之后的是一段有关于这种生成关系的具体命令，我也就是在这里把beam文件移动到./beam文件夹里的；MODS和OUT都是定义的变量，方便重复使用（虽然这里没有再用到，但是至少看起来很清楚）；application这个替换被注释掉了，因为我几乎用不到，但也可能以后会用到，除了编译之外，它还负责运行编译之后的模块函数；clean就是删除当前文件夹下的beam文件。<br /><br /><img src ="http://www.cnitblog.com/gyn/aggbug/64375.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/gyn/" target="_blank">gyn_tadao</a> 2010-02-24 13:49 <a href="http://www.cnitblog.com/gyn/archive/2010/02/24/64375.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ATS：TclTk IDE下载</title><link>http://www.cnitblog.com/gyn/archive/2009/12/21/63264.html</link><dc:creator>gyn_tadao</dc:creator><author>gyn_tadao</author><pubDate>Mon, 21 Dec 2009 07:01:00 GMT</pubDate><guid>http://www.cnitblog.com/gyn/archive/2009/12/21/63264.html</guid><wfw:comment>http://www.cnitblog.com/gyn/comments/63264.html</wfw:comment><comments>http://www.cnitblog.com/gyn/archive/2009/12/21/63264.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cnitblog.com/gyn/comments/commentRss/63264.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/gyn/services/trackbacks/63264.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt">
				<span style="FONT-FAMILY: 黑体">
						<a href="/Files/gyn/ats.rar">ATS for windwos下载</a> （别放在桌面运行，程序对中文路径支持不好）<br />   最近很不想写随笔，其实是怕写出来丢人。以前啥都不懂的时候，什么都敢写，也不怕出洋相，而现在却害怕拿出来丢人了，就像我现在写文章没</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">5000</span>
				<span style="FONT-FAMILY: 黑体">字也不敢出去发。某种意义上说，算是水平有点了吧，虽然这个说法很是贻笑大方。</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">
						<?xml:namespace prefix = o /?>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt">
				<span style="FONT-FAMILY: 黑体">今天，我把前段时间做的一个用于开发</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">TclTk</span>
				<span style="FONT-FAMILY: 黑体">的</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">IDE</span>
				<span style="FONT-FAMILY: 黑体">工具用</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">TDK</span>
				<span style="FONT-FAMILY: 黑体">打了个包，传上来。从做完到修掉大多数</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">bug</span>
				<span style="FONT-FAMILY: 黑体">，之间隔了一段时间，一个原因是做完之后精神一下子放松下来了，没有了干劲；第二个，毕竟是一个人的作品，很难做到面面俱到，不过我也算是尽力而为了。目前的作品是可以拿出来用的，至少我自己是用它来写程序的，一面修改一些</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">bug</span>
				<span style="FONT-FAMILY: 黑体">。这次打包的程序中，除了对</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">Tcl</span>
				<span style="FONT-FAMILY: 黑体">的支持，还有对</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">python</span>
				<span style="FONT-FAMILY: 黑体">的语法着色和缩进支持，但只是很简略的，主要还是为了</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">Tcl</span>
				<span style="FONT-FAMILY: 黑体">。</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt">
				<span style="FONT-FAMILY: 黑体">接下来，有空的时候，我会再给它增加几个菜单栏，至少要让它有模有样起来。其实一开始我是打算先做菜单的，因为这个我有经验。相反地对于工具栏我没有什么信心，也不知道该放点什么功能上去，于是花了大力气在这方面，最后反而冷落了菜单的设置。我想这个不难，只是要花点功夫。另外，就以前写的一个提词软件，感谢崔姓同学的建议和提供的国外软件样本，有时间我会改写的。</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt">
				<span style="FONT-FAMILY: 黑体">前段时间，我还参与了联汇公司的</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">link pro</span>
				<span style="FONT-FAMILY: 黑体">音频工作站测试和部署工作。逻辑功能是比较完善，不过</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">UI</span>
				<span style="FONT-FAMILY: 黑体">乱且不说，简直惨不忍睹，国内的软件普遍有这个坏毛病。不过，把管理站建立在</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">web</span>
				<span style="FONT-FAMILY: 黑体">中，我个人认为是一个好的方向，以后可以考虑更多一点的富客户端应用，甚至把整个系统都搬到</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">web</span>
				<span style="FONT-FAMILY: 黑体">上去，这也不是不可能，而且无论从安全性还是性能、外观都会上一个台阶。不过，就目前的这个管理站的</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">ASP.Net</span>
				<span style="FONT-FAMILY: 黑体">开发水平，这些开发员怕还是不够看。</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt">
				<span style="FONT-FAMILY: 黑体">年终将近，铁塔的工程牵扯了我大半的精力，到目前为止竣工已经不再是遥遥无期的事情了，但还需要加把劲争取在年前完成。以前很喜欢听</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">911</span>
				<span style="FONT-FAMILY: 黑体">的歌，后来</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">coldplay</span>
				<span style="FONT-FAMILY: 黑体">，间或一直在听</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">sting</span>
				<span style="FONT-FAMILY: 黑体">的歌，现在变得只能听班得瑞了</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">…</span>
				<span style="FONT-FAMILY: 黑体">人啊总是在朝一个方向走的，什么都拉不住</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">…</span>
				<span style="FONT-FAMILY: 黑体">下午的天气很好，休息，休息一下</span>
				<span lang="EN-US" style="FONT-FAMILY: Arial">….</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt">
				<span lang="EN-US" style="FONT-FAMILY: Arial">
						<img src="http://www.cnitblog.com/images/cnitblog_com/gyn/8564/r_ats.png" />
						<br />
				</span>
		</p>
<img src ="http://www.cnitblog.com/gyn/aggbug/63264.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/gyn/" target="_blank">gyn_tadao</a> 2009-12-21 15:01 <a href="http://www.cnitblog.com/gyn/archive/2009/12/21/63264.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>类Emacs窗体分割之我见</title><link>http://www.cnitblog.com/gyn/archive/2009/09/29/61631.html</link><dc:creator>gyn_tadao</dc:creator><author>gyn_tadao</author><pubDate>Tue, 29 Sep 2009 11:42:00 GMT</pubDate><guid>http://www.cnitblog.com/gyn/archive/2009/09/29/61631.html</guid><wfw:comment>http://www.cnitblog.com/gyn/comments/61631.html</wfw:comment><comments>http://www.cnitblog.com/gyn/archive/2009/09/29/61631.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/gyn/comments/commentRss/61631.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/gyn/services/trackbacks/61631.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">其实也并非</span>
				<span lang="EN-US">
						<font face="Arial">Emacs</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">专有，像</span>
				<span lang="EN-US">
						<font face="Arial">Vim</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">或者</span>
				<span lang="EN-US">
						<font face="Arial">UE</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">也有类似的功能，只是我用</span>
				<span lang="EN-US">
						<font face="Arial">Emacs</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">比较多，所以才取了这个题目。总之，就是将在编辑的一个文本框分割为垂直或者水平的两个相同大小的文本，对于同一个编辑目标，两者保持相同的内容变更，但两者又可分别显示不同的编辑对象，被分割出来的两个文本框又可自行再次分割，以此类推。如果看的迷糊的，自己试试</span>
				<span lang="EN-US">
						<font face="Arial">Emacs</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">去，“</span>
				<span lang="EN-US">
						<font face="Arial">Control x 2</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">（</span>
				<span lang="EN-US">
						<font face="Arial">3</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">）”就行。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">这么做的好处在于可以同时观察到两个相关的代码段，有助于查找需要的信息，或者其中一个编辑另一个执行某个如</span>
				<span lang="EN-US">
						<font face="Arial">tclsh</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">的命令，等等。差不多就是一个多任务的形式，思维比较活跃的人多是喜欢这样开好几个窗口干活。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">这个看似简单易用的玩意儿，实现起来却有点让人无从下手。首先，要让两个同编辑目标的文本框保持同步更新；第二，同一个文本框中切换不同编辑对象时，需要保证如语法渲染之类的操作不影响切换速度；第三，保证分割出来的文本框不会改变父窗体的大小。也许还有别的问题，但这三个是让我有点茫然的东西。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">经过一番思量，对于第一个问题，应该可以用</span>
				<span lang="EN-US">
						<font face="Arial">rename</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">注入代码完成。这在我之前写的文章里有很多涉及，这里就具体不讲。只是需要判断一下两个文本框的编辑对象是否一致。如此一来，对于第二个问题，则需要在每次切换的时候将涉及到渲染或者计算的部分以一定结构的数据形式将结果存储起来以备后用，比如将用于作色渲染的</span>
				<span lang="EN-US">
						<font face="Arial">tag</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">标记都</span>
				<span lang="EN-US">
						<font face="Arial">dump</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">出来，还有复制内容，当前插入点等等。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">不过，在这里我采用了另一种更加优雅的方式，其实是使用了在</span>
				<span lang="EN-US">
						<font face="Arial">Tk8.5</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">中新加入的</span>
				<span lang="EN-US">
						<font face="Arial">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">组件命令：</span>
				<span lang="EN-US">
						<font face="Arial">peer</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">，在</span>
				<span lang="EN-US">
						<font face="Arial">actovetcl</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">的</span>
				<span lang="EN-US">
						<font face="Arial">demo</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">中也可以看到相关的例子。就是对于一个已建的</span>
				<span lang="EN-US">
						<font face="Arial">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">组件，通过</span>
				<span lang="EN-US">
						<font face="Arial">peer</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">命令生成它的镜像对象，这两个对象是完全相同的，对任一个的才做都会影响其他对象的变现。事实上，对于一个新建的文本编辑对象，我<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /?><st1:personname w:st="on" productid="都首">都首</st1:personname>先生成了一个不被</span>
				<span lang="EN-US">
						<font face="Arial">geometry</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">的</span>
				<span lang="EN-US">
						<font face="Arial">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">对象，用术语说就是</span>
				<span lang="EN-US">
						<font face="Arial">buffer</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">，再针对这个</span>
				<span lang="EN-US">
						<font face="Arial">buffer</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">来</span>
				<span lang="EN-US">
						<font face="Arial">peer</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">出所有需要显示的文本框窗体。那么对于第二个问题，就不是某个</span>
				<span lang="EN-US">
						<font face="Arial">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">组件中内容之间的切换了，而是不同</span>
				<span lang="EN-US">
						<font face="Arial">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">组件之间的切换，可以通过</span>
				<span lang="EN-US">
						<font face="Arial">forget</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">来完成。这么做的好处在于，我肯本不用考虑切换时状态存储，而且</span>
				<span lang="EN-US">
						<font face="Arial">peer</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">可以更好地保证编辑对象的一致性要求。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">而第三个问题的解决让我对</span>
				<span lang="EN-US">
						<font face="Arial">geometry</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">中的</span>
				<span lang="EN-US">
						<font face="Arial">place</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">命令有了全新的认识。众所周知，</span>
				<span lang="EN-US">
						<font face="Arial">geometry</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">的三种方法中，最被广泛使用的是</span>
				<span lang="EN-US">
						<font face="Arial">pack</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">，其次是</span>
				<span lang="EN-US">
						<font face="Arial">grid</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">，最后才是</span>
				<span lang="EN-US">
						<font face="Arial">place</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">。无论那本介绍</span>
				<span lang="EN-US">
						<font face="Arial">Tk</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">的书籍，都是按照这个顺寻来编写的。也许是应为</span>
				<span lang="EN-US">
						<font face="Arial">pack</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">的命令最短，也更通俗易懂一些。但在这里，我不得不使用</span>
				<span lang="EN-US">
						<font face="Arial">place</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">。对于一个需要被分割的文本框，以下的代码很难控制父窗体的大小。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'">package require Tk<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'">text .t1<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'">text .t2<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'">pack .t1 –fill both –expand 1<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'">pack forget .t1<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'">pack .t1 .t2 -side left –fill both –expand 1<o:p></o:p></span>
		</p>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-ascii-font-family: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-hansi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt">事实上，这么做的结果是使父窗体加宽了一倍。即使你小心地设定了</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 黑体; mso-bidi-font-size: 12.0pt">text</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-ascii-font-family: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-hansi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt">组件的</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 黑体; mso-bidi-font-size: 12.0pt">width</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-ascii-font-family: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-hansi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt">，一旦</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 黑体; mso-bidi-font-size: 12.0pt">fill</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-ascii-font-family: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-hansi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt">开来就面目全非了。在这里只能使用</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 黑体; mso-bidi-font-size: 12.0pt">place</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-ascii-font-family: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-hansi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt">，结合相对起点与相对长宽，精确设定分割窗体大小。以下是一个实现类以上所讲到和没讲到的功能的完整</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 黑体; mso-bidi-font-size: 12.0pt">demo</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-ascii-font-family: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-hansi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt">，有兴趣的可以看看。其中还包含了切换和关闭</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 黑体; mso-bidi-font-size: 12.0pt">buffer</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-ascii-font-family: Arial; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-hansi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt">的快捷键。<br /><a href="/Files/gyn/split.rar">split.tcl文件下载</a></span>
<img src ="http://www.cnitblog.com/gyn/aggbug/61631.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/gyn/" target="_blank">gyn_tadao</a> 2009-09-29 19:42 <a href="http://www.cnitblog.com/gyn/archive/2009/09/29/61631.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tcl中的输出重定向</title><link>http://www.cnitblog.com/gyn/archive/2009/09/25/61573.html</link><dc:creator>gyn_tadao</dc:creator><author>gyn_tadao</author><pubDate>Fri, 25 Sep 2009 06:50:00 GMT</pubDate><guid>http://www.cnitblog.com/gyn/archive/2009/09/25/61573.html</guid><wfw:comment>http://www.cnitblog.com/gyn/comments/61573.html</wfw:comment><comments>http://www.cnitblog.com/gyn/archive/2009/09/25/61573.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/gyn/comments/commentRss/61573.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/gyn/services/trackbacks/61573.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">有时候重定向是得到执行信息的必要手段，比如我在调试某个程序时需要将调试的输出结果存放到某个文件中以便于日后查看。</span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">1.close stdout<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">2.set stdout [open out.txt w]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">我关闭并重定义了</span>
				<span lang="EN-US">
						<font face="Courier New">stdout</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">，使其成为某个被打开文件的</span>
				<span lang="EN-US">
						<font face="Courier New">channel</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">，那么执行</span>
				<span lang="EN-US">
						<font face="Courier New">puts</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">事实上是完成了对于文本的写操作。在还有一些情况中，是将</span>
				<span lang="EN-US">
						<font face="Courier New">stdout</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的结果显示到比如</span>
				<span lang="EN-US">
						<font face="Courier New">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">这样的</span>
				<span lang="EN-US">
						<font face="Courier New">Tk</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">组件上，以上的办法显然是无能为力了。作为</span>
				<span lang="EN-US">
						<font face="Courier New">stdout</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">本身必须是一个</span>
				<span lang="EN-US">
						<font face="Courier New">channel</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">，它不能作为一个变量或者其他什么的，所以一个替代的办法是使用</span>
				<span lang="EN-US">
						<font face="Courier New">Memchan</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">模块，以下是在</span>
				<span lang="EN-US">
						<font face="Courier New">tcl</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的</span>
				<span lang="EN-US">
						<font face="Courier New">wiki</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">上的一段代码。</span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">1.package require Tk<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">2.package require Memchan<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">
						<span style="mso-spacerun: yes"> </span>3.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">4.text .t<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">5..t tag configure stdout -font {Courier 10}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">6..t tag configure stderr -font {Courier 10} -foreground red<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">7.pack .t<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">
						<span style="mso-spacerun: yes"> </span>8.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">9.# install new stdout<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">10.close stdout<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">11.set stdout [fifo]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">12.fileevent $stdout readable ".t insert end \[read $stdout\] stdout; .t see end"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">13.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">14.# install new stderr<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">15.close stderr<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">16.set stderr [fifo]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">17.fileevent $stderr readable ".t insert end \[read $stderr\] stderr; .t see end"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">18.<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">19.# test it<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">20.puts "this is stdout"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">21.puts stderr "this is stderr"<span style="mso-tab-count: 1"></span><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">通过</span>
				<span lang="EN-US">
						<font face="Courier New">fileevent</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">，以上程序提供了一个非常优雅的重定向办法，但是带程序的作者还附加了一句话。事实上，这段代码是无法正确执行的，因为重定义的</span>
				<span lang="EN-US">
						<font face="Courier New">stdout</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">并没有被创建，而且该</span>
				<span lang="EN-US">
						<font face="Courier New">bug</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">似乎至今没有被修复。</span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">warning: the current distribution has a bug, I have submitted a patch to the author<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">在</span>
				<span lang="EN-US">
						<font face="Courier New">cucumber<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /?><st1:chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">1.1.1</st1:chsdate></font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的</span>
				<span lang="EN-US">
						<font face="Courier New">tclsh</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">中需要将</span>
				<span lang="EN-US">
						<font face="Courier New">puts</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的内容如同</span>
				<span lang="EN-US">
						<font face="Courier New">return</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的结果一样写入</span>
				<span lang="EN-US">
						<font face="Courier New">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">文本组件中，但考虑到循环打印的情况，又不能仅仅将</span>
				<span lang="EN-US">
						<font face="Courier New">puts</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">当做</span>
				<span lang="EN-US">
						<font face="Courier New">return</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">来对待，从而导致执行代码的中止。我的解决办法依然是使用</span>
				<span lang="EN-US">
						<font face="Courier New">rename</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">，在</span>
				<span lang="EN-US">
						<font face="Courier New">puts</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">之前注入代码。</span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">1.con eval {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">
						<span style="mso-spacerun: yes"> </span>2.<span style="mso-spacerun: yes">   </span>rename puts _puts<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">
						<span style="mso-spacerun: yes"> </span>3.<span style="mso-spacerun: yes">   </span>proc puts {args} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">
						<span style="mso-spacerun: yes"> </span>4.<span style="mso-spacerun: yes">       </span>putsstdout $args<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">
						<span style="mso-spacerun: yes"> </span>5.<span style="mso-spacerun: yes">   </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">6.}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">7.interp alias con putsstdout {} putsstdout<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5; mso-para-margin-left: .01gd">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">8.proc putsstdout {msg} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">
						<span style="mso-spacerun: yes"> </span>9.<span style="mso-spacerun: yes">   </span>.console insert end "$msg\n"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">10.<span style="mso-spacerun: yes">   </span>.console see end<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: -0.1pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">11.}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 0.1pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">模拟</span>
				<span lang="EN-US">
						<font face="Courier New">tclsh</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的过程是发生在名为</span>
				<span lang="EN-US">
						<font face="Courier New">con</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的子解析器里的，需要使用</span>
				<span lang="EN-US">
						<font face="Courier New">alias</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">将子解析器中的数据交由主解析器中的函数来更新</span>
				<span lang="EN-US">
						<font face="Courier New">.console</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">中的显示。以上代码中的第</span>
				<span lang="EN-US">
						<font face="Courier New">4</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">行便是重定向的关键所在，当然我们还可以将数据以传统形式输出到</span>
				<span lang="EN-US">
						<font face="Courier New">stdout</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">中，这就看具体情况而定了。事实上，这种办法并不算是真正意义上的重定向，但是得到了相同的效果。</span>
		</p>
<img src ="http://www.cnitblog.com/gyn/aggbug/61573.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/gyn/" target="_blank">gyn_tadao</a> 2009-09-25 14:50 <a href="http://www.cnitblog.com/gyn/archive/2009/09/25/61573.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Tk中实现文本局部只读</title><link>http://www.cnitblog.com/gyn/archive/2009/09/25/61571.html</link><dc:creator>gyn_tadao</dc:creator><author>gyn_tadao</author><pubDate>Fri, 25 Sep 2009 05:36:00 GMT</pubDate><guid>http://www.cnitblog.com/gyn/archive/2009/09/25/61571.html</guid><wfw:comment>http://www.cnitblog.com/gyn/comments/61571.html</wfw:comment><comments>http://www.cnitblog.com/gyn/archive/2009/09/25/61571.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/gyn/comments/commentRss/61571.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/gyn/services/trackbacks/61571.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">如果用过</span>
				<span lang="EN-US">
						<font face="Courier New">Python</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的</span>
				<span lang="EN-US">
						<font face="Courier New">idle</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">或者之类的文本型命令行编辑器，你就会发现使用这类工具的可以随意复制黏贴的好处，这比传统的命令行工具方便了很多。但是，传统的优势在于，已执行的命令及得到的返回结果是只读的，不必担心因为误操作破坏历史记录，而这点在</span>
				<span lang="EN-US">
						<font face="Courier New">Tk</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的</span>
				<span lang="EN-US">
						<font face="Courier New">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">组件很难实现。就是说，</span>
				<span lang="EN-US">
						<font face="Courier New">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">天然并不支持在一个文本框对象中实现部分只读，而另一部分可写的状态。</span>
				<span lang="EN-US">
						<font face="Courier New">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的</span>
				<span lang="EN-US">
						<font face="Courier New">state</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">选项只能是整个对象处于只读或者可写的状体。那么像</span>
				<span lang="EN-US">
						<font face="Courier New">idle</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">这样的工具是怎么实现局部只读的呢？特别是</span>
				<span lang="EN-US">
						<font face="Courier New">idle</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">本身即是用</span>
				<span lang="EN-US">
						<font face="Courier New">Tk</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">写成的。最初我认为这可能是使用了</span>
				<span lang="EN-US">
						<font face="Courier New">canvas</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">组件里实现类</span>
				<span lang="EN-US">
						<font face="Courier New">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">功能，但之后我还是使用了</span>
				<span lang="EN-US">
						<font face="Courier New">rename</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">办法在</span>
				<span lang="EN-US">
						<font face="Courier New">text</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">的</span>
				<span lang="EN-US">
						<font face="Courier New">insert</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">和</span>
				<span lang="EN-US">
						<font face="Courier New">delete</font>
				</span>
				<span style="FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'">命令前注入代码，从而实现这一功能。</span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">1.proc init_region_readonly {text} {<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">2.<span style="mso-spacerun: yes">    </span>rename $text fake<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">3.<span style="mso-spacerun: yes">    </span>proc $text {args} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">4.<span style="mso-tab-count: 1"></span><span style="mso-spacerun: yes">       </span>switch [lindex $args 0] {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">5. <span style="mso-tab-count: 1">   </span><span style="mso-spacerun: yes">       </span>"insert" {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">6.<span style="mso-tab-count: 2">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">       </span>if [fake compare insert &gt;= $::com_region_readonly] { <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">7.<span style="mso-tab-count: 2">    </span><span style="mso-spacerun: yes">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">       </span>uplevel 1 fake $args<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">8.<span style="mso-tab-count: 2">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">       </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 5.25pt; mso-char-indent-count: .5">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">9.<span style="mso-tab-count: 1"></span><span style="mso-spacerun: yes">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">   </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">10.<span style="mso-tab-count: 1"></span><span style="mso-spacerun: yes">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">   </span>"delete" {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">11.<span style="mso-tab-count: 2">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">       </span>if [fake compare insert &gt; $::com_region_readonly] { <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">12.<span style="mso-tab-count: 2">    </span><span style="mso-spacerun: yes">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">       </span>uplevel 1 fake $args<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">13.<span style="mso-tab-count: 2">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">       </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">14.<span style="mso-tab-count: 1"></span><span style="mso-spacerun: yes">   </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">   </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">15.<span style="mso-tab-count: 1"></span><span style="mso-spacerun: yes">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">   </span>"default" {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">16.<span style="mso-tab-count: 2">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">       </span>uplevel 1 fake $args<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">17.<span style="mso-tab-count: 1"></span><span style="mso-spacerun: yes">    </span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">   </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">18.<span style="mso-tab-count: 1"></span><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">   </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">19.<span style="mso-spacerun: yes">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="BACKGROUND: silver; MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: Consolas">20.}<o:p></o:p></span>
		</p>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">在第</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">6</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">行和第</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">11</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">行里，我增加了对于输入点的判断，也就是说只有当输入点的</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">index</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">处于以一个名为</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">com_region_readonly</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">的全局变量所指定的位置后时，输入才是有效的，否则将丢弃本次操作。这被应用于</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">cucumber<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /?><st1:chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">1.1.1</st1:chsdate></span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">中所集成的</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">tclsh</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">命令行工具中，当然这个工具实现的不仅仅模拟</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">tclsh</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">，还有类似于</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">vim</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">的文本操作命令，这是基于几个</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">alias</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 黑体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">给子解析器的命令实现的，以后再作介绍。</span>
<img src ="http://www.cnitblog.com/gyn/aggbug/61571.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/gyn/" target="_blank">gyn_tadao</a> 2009-09-25 13:36 <a href="http://www.cnitblog.com/gyn/archive/2009/09/25/61571.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Cucumber2的语法高亮代码分析</title><link>http://www.cnitblog.com/gyn/archive/2009/09/24/61556.html</link><dc:creator>gyn_tadao</dc:creator><author>gyn_tadao</author><pubDate>Thu, 24 Sep 2009 12:45:00 GMT</pubDate><guid>http://www.cnitblog.com/gyn/archive/2009/09/24/61556.html</guid><wfw:comment>http://www.cnitblog.com/gyn/comments/61556.html</wfw:comment><comments>http://www.cnitblog.com/gyn/archive/2009/09/24/61556.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/gyn/comments/commentRss/61556.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/gyn/services/trackbacks/61556.html</trackback:ping><description><![CDATA[
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="ProgId" content="Word.Document" />
		<meta name="Generator" content="Microsoft Word 11" />
		<meta name="Originator" content="Microsoft Word 11" />
		<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" />
		<link rel="Edit-Time-Data" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_editdata.mso" />
		<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
		<o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="chsdate">
		</o:smarttagtype>
		<o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="chmetcnv">
		</o:smarttagtype>
		<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>0</w:Zoom>
  <w:PunctuationKerning/>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
		<!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
		<!--[if !mso]><object
 classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>
<style>
st1\:*{behavior:url(#ieooui) }
</style>
<![endif]-->
		<style>
				<!--
 /* Font Definitions */
 @font-face
	{font-family:黑体;
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-alt:SimHei;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:1 135135232 16 0 262144 0;}
@font-face
	{font-family:"\@黑体";
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:1 135135232 16 0 262144 0;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:modern;
	mso-font-pitch:fixed;
	mso-font-signature:-1610611985 1073750091 0 0 159 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	font-size:10.5pt;
	font-family:"Courier New";
	mso-fareast-font-family:黑体;
	mso-bidi-font-family:"Times New Roman";
	mso-font-kerning:1.0pt;}
p.MsoCaption, li.MsoCaption, div.MsoCaption
	{mso-style-noshow:yes;
	mso-style-next:正文;
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	font-size:10.0pt;
	font-family:Arial;
	mso-fareast-font-family:黑体;
	mso-font-kerning:1.0pt;}
 /* Page Definitions */
 @page
	{mso-page-border-surround-header:no;
	mso-page-border-surround-footer:no;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:36.0pt;
	mso-footer-margin:36.0pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
		</style>
		<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]-->
		<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1034"/>
</xml><![endif]-->
		<!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 黑体;">在写代码的时候，不应该仅仅追求完成某件功能，而是需去寻找一个尽量优雅的方法解决。我不单是这么想，而且也的的确确这么做的。在处理</span>
				<span lang="EN-US">cucumber</span>
				<span style="font-family: 黑体;">的语法高亮模块时，我思考了很久。最后选择了</span>
				<span lang="EN-US">rename</span>
				<span style="font-family: 黑体;">办法，即是通过</span>
				<span lang="EN-US">rename</span>
				<span style="font-family: 黑体;">和重载原命令来得到命令参数，实现代码注入。举个例子：</span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">1.package require Tk<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">2.text .t<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">3.pack .t<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">4.rename .t t<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">5.proc .t {args} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">6.<span style="">    </span># injected code<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">7.<span style="">  </span><span style="">  </span>uplevel #1 t $args<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">8.}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 黑体;">对于复杂的对象，处于简化使用或者其他的目的，往往会隐藏一些底层的方法，而仅仅提供高级的抽象功能。比如</span>
				<span lang="EN-US">text</span>
				<span style="font-family: 黑体;">组件的剪切功能，将删除、赋值和标记设定等命令以一定的方式顺序组合在一起，对程序员提供一个指令来完成这一系列的事件。以上的办法为在执行这些底层命令前提供了捕获控制的机会。在高亮的解决方案中，通过这种机制，介入所有的</span>
				<span lang="EN-US">text</span>
				<span style="font-family: 黑体;">组件指令，筛选出</span>
				<span lang="EN-US">insert</span>
				<span style="font-family: 黑体;">、</span>
				<span lang="EN-US">delete</span>
				<span style="font-family: 黑体;">、</span>
				<span lang="EN-US">mark set</span>
				<span style="font-family: 黑体;">和</span>
				<span lang="EN-US">see insert</span>
				<span style="font-family: 黑体;">这四个指令，完成当发生包括输入，黏贴、删除，剪切、撤销和重做等事件时的文本高亮渲染。</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 黑体;">在这个基本思想的基础上，</span>
				<span lang="EN-US">cucumber<st1:chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on">1.1.1</st1:chsdate></span>
				<span style="font-family: 黑体;">版本实现了关键词、变量、注解和引号语句的高亮，但如在实现顺序上有错疏忽，虽然可能不会对破坏的渲染结果，但是会极大影响大文本渲染的效率。为什么单指大文本，因为对于文本输入一般包括键盘输入和大段文本的载入如打开文件或者黏贴。与电脑的处理相比无论打字速度多快，其中的间歇都是足够渲染处理打入的单个符号的上下文环境；而大文本的载入首先是一次操作完成的，与下一个操作之间只有一次间隔，第二需要渲染的内容很多，这么一来渲染效率的瓶颈边出现在大文本处理上了。所以，我所说的效率可以理解为特指大文本渲染效率。在第二个版本里我是使用了以下的一系列优化代码。在这里我首先通过一下函数完成捕获</span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">1.proc _tool_core_fake {cucumber fake} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">2.<span style="">    </span>set ::$fake [regsub
{(.*)\..+$} $cucumber {\1.linumColumn}]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">3.<span style="">   </span><span style=""> </span>rename $cucumber $fake<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">4.<span style="">    </span>eval "proc $cucumber
{args} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">5.<span style="">        </span>after idle
\[_tool_core_sortMap $fake \$args\]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">6.<span style="">        </span>uplevel 1 $fake
\$args<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">7.<span style="">    </span>}"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">8.}<o:p></o:p></span>
		</p>
		<p class="MsoCaption" style="text-align: center;" align="center">
				<span lang="EN-US">_tool_core_fake</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 黑体;">第</span>
				<span lang="EN-US">2</span>
				<span style="font-family: 黑体;">行是设置了一个与当前</span>
				<span lang="EN-US">text</span>
				<span style="font-family: 黑体;">文本相对应的行号显示组件变量，这里就不再多说了。真正的高亮渲染注入发生在第</span>
				<span lang="EN-US">5</span>
				<span style="font-family: 黑体;">行，通过以下的函数返回需要执行的指令集。</span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">1.proc
_tool_core_sortMap {fake args} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">2.<span style="">    </span>eval "set args $args"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">3.<span style="">    </span>switch -glob -- $args {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">4.<span style="">        </span>insert* {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">5.<span style="">            </span>set from [$fake index [lindex $args
1]]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">6. <span style="">           </span>set to "$from+[string length
[lindex $args 2]]c"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">7.<span style="">            </span>return "<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">8.<span style="">            </span>_tool_core_hiContent $fake $from
$to; <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">9.<span style="">            </span>_tool_incrLinum $fake;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">10.<span style="">           
</span>_tool_core_hiLine $fake<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">11.<span style="">            </span>"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">12.<span style="">        </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">13.<span style="">        </span>delete* {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">14.<span style="">            </span>set from [$fake
index [lindex $args 1]]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">15.<span style="">            </span>return "<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">16.<span style="">          </span><span style="">  </span>_tool_core_hiContent $fake $from $from;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">17.<span style="">            </span>_tool_decrLinum
$fake<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">18.<span style="">           
</span>_tool_core_hiLine $fake<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">19.<span style="">            </span>"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">20.<span style="">        </span>}<span style="">        </span><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">21.<span style="">        </span>{mark set insert*} {
return "_tool_core_hiLine $fake" }<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">22.<span style="">        </span>{see insert} {
return "_tool_core_hiLine $fake" }<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">23.<span style="">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">24.}<o:p></o:p></span>
		</p>
		<p class="MsoCaption" style="text-align: center;" align="center">
				<span lang="EN-US">_tool_core_sortMap</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 黑体;">第二行的作用是消除字符串外的大括号，将如“</span>
				<span lang="EN-US">{insert end nihao}</span>
				<span style="font-family: 黑体;">”变化为“</span>
				<span lang="EN-US">insert end nihao</span>
				<span style="font-family: 黑体;">”。之后使用</span>
				<span lang="EN-US">glob</span>
				<span style="font-family: 黑体;">匹配的</span>
				<span lang="EN-US">switch</span>
				<span style="font-family: 黑体;">来筛选命令参数。在</span>
				<st1:chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on">
						<span lang="EN-US">1.1.1</span>
				</st1:chsdate>
				<span style="font-family: 黑体;">版本的筛选函数中，首先我没有加入用于筛选高亮当前行显示的</span>
				<span lang="EN-US">insert</span>
				<span style="font-family: 黑体;">标记判断，而是在单独的模块中通过绑定事件来完成，这显然是累赘的；第二，最初使用</span>
				<span lang="EN-US">none</span>
				<span style="font-family: 黑体;">函数来处理非匹配的指令，这个自以为保证代码一致性的手法在事后证明是一个画蛇添足的举动，因为即使是一个空函数，也存在执行消耗，而大量累加执行的结果就是拖慢渲染的速度，这在</span>
				<span lang="EN-US">1.1.1</span>
				<span style="font-family: 黑体;">中已经被删除了；另外，在处理</span>
				<span lang="EN-US">insert</span>
				<span style="font-family: 黑体;">和</span>
				<span lang="EN-US">delete</span>
				<span style="font-family: 黑体;">时，存在值得商榷的渲染级别。在目前代码中可以看见，事实上渲染发生在以上代码的第</span>
				<span lang="EN-US">8</span>
				<span style="font-family: 黑体;">行和第</span>
				<span lang="EN-US">16</span>
				<span style="font-family: 黑体;">行里的</span>
				<span lang="EN-US">_tool_core_hiContent</span>
				<span style="font-family: 黑体;">函数里。顺便提一下，在该函数以下的两个命令，跟行号和当前行指示有关，这里不做详解。</span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">1.proc _tool_core_hiContent {fake from to} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">2.<span style="">    </span>set temp $from<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">3.<span style="">    </span>set temp
[_tool_core_hiWord $fake $temp]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">4.<span style="">    </span>while {[$fake compare
$temp &lt;= $to]} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">5.<span style="">        </span>set temp
[_tool_core_hiWord $fake $temp]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">6.<span style="">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">7.<span style="">    </span>_tool_core_hiQuoteContext
$fake<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">8.<span style="">   
</span>_tool_core_hiCommentContext $fake $from $to<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">9.}<o:p></o:p></span>
		</p>
		<p class="MsoCaption" style="text-align: center;" align="center">
				<span lang="EN-US">_tool_core_hiContent</span>
				<span style="font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-indent: 17.95pt;">
				<span style="font-family: 黑体;">在</span>
				<span lang="EN-US">_tool_core_hiConetnt</span>
				<span style="font-family: 黑体;">的文本渲染函数中，包含了三个同层次的渲染，分别是处于</span>
				<span lang="EN-US">index</span>
				<span style="font-family: 黑体;">位于</span>
				<span lang="EN-US">from</span>
				<span style="font-family: 黑体;">和</span>
				<span lang="EN-US">to</span>
				<span style="font-family: 黑体;">之间的单词循环渲染和各行注解渲染，以及一次全文引号渲染。这么安排的道理在于，一般情况系关键词和变量都是以单词的形式出现的，可以统一在</span>
				<span lang="EN-US">_tool_core_hiWord</span>
				<span style="font-family: 黑体;">中处理；注解可能占据一行或者后半行，与其在每次单词渲染时判断是否存在注解起始符，不如在处理完所有的单词之后统一检索当前文本段，前者是单词数量级的运算，而后者是行数量级的运算，显然后者更为高效；引号数量的单双数变化，会造成全文渲染范围的颠倒，但考虑到引号数量与单词相比可能相差两三个数量级，因此这种全文渲染变化是很快速的，尤其是我更引入了延迟渲染的机制，消耗更是可以忽略不计。以下是这三个函数。</span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">1.proc
_tool_core_hiWord {fake id} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">2.<span style="">    </span>if [_tool_ifInWord $fake $id] {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>3.<span style="">       </span>set head [_tool_indexWordHead $fake $id]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>4.<span style="">  </span><span style="">     </span>set end<span style=""> 
</span>[_tool_indexWordEnd $fake $id]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>5.<span style="">       </span>foreach hi {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>6.<span style="">           </span>_tool_core_hiTextContext <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>7.<span style="">           </span>_tool_core_hiVariableContext <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>8.<span style="">       </span>} { $hi $fake $head $end}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>9.<span style="">       </span>return "$end +<st1:chmetcnv unitname="C" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">1c</st1:chmetcnv>"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">10.<span style="">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">11.<span style="">    </span>return "$id +<st1:chmetcnv unitname="C" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">1c</st1:chmetcnv>"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">12.}<o:p></o:p></span>
		</p>
		<p class="MsoCaption" style="text-align: center;" align="center">
				<span lang="EN-US">_tool_core_hiWord</span>
				<span style="font-family: Consolas;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">1</span>
				<span style="font-family: 黑体;">．</span>
				<span style="font-family: Consolas;" lang="EN-US">proc
_tool_core_hiCommentContext {fake from to} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>2.<span style="">   </span>set f [_tool_linum $fake $from]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>3.<span style="">   </span>set t [_tool_linum $fake $to]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>4.<span style="">   </span>while {$f &lt;= $t} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>5.<span style="">       </span>$fake tag remove Com "$f.0"
"$f.0 lineend"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>6.<span style="">       </span>if {[$fake search -regexp
$::hi_comment_regexp "$f.0" "$f.0 lineend"] != {}} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>7.<span style="">           </span>$fake tag add Com [$fake search
-regexp $::hi_comment_symbol "$f.0" "$f.0 lineend"]
"$f.0 lineend"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>8.<span style="">       </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">
						<span style=""> </span>9.<span style="">       </span>incr f<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">10.<span style="">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">11.}<o:p></o:p></span>
		</p>
		<p class="MsoCaption" style="text-align: center;" align="center">
				<span lang="EN-US">_tool_core_hiCommentContext</span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">1.proc
_tool_core_hiQuoteContext {fake} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">2. <span style="">   </span>after cancel [list _hiQuoteContext $fake]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">3. <span style=""> </span><span style="">  </span>after
1000 [list _hiQuoteContext $fake]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">4.}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">5.proc
_hiQuoteContext {fake} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">6.<span style="">    </span>if {[$fake get 1.0] == "\""}
{ set rid [list 1.0] } else { set rid {} }<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">7.<span style="">    </span>set qid [$fake search -nolinestop -overlap
-all -regexp {[^\\]\"} 1.0 end]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">8.<span style="">    </span>foreach id $qid { lappend rid [$fake index
[$fake index "$id + <st1:chmetcnv unitname="C" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">1c</st1:chmetcnv>"]]
}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; text-indent: 5.25pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">9.<span style="">    </span><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">10.<span style="">    </span>if ![set e [llength
$rid]] {return}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">11.<span style="">    </span>set now [lindex $rid 0]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">12.<span style="">    </span>$fake tag remove Quo 1.0
$now<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">13</span>
				<span style="font-family: 黑体;">．</span>
				<span style="font-family: Consolas;" lang="EN-US">
						<span style="">   </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">14.<span style="">    </span>set i 1<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">15.<span style="">    </span>while {$i &lt; $e} {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">16.<span style="">        </span>set old $now<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">17.<span style="">        </span>set now [lindex $rid
$i]<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">18.<span style="">        </span>if [expr $i % 2] {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">19.<span style="">            </span>$fake tag add
Quo $old "$now +<st1:chmetcnv unitname="C" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">1c</st1:chmetcnv>"<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">20.<span style="">        </span>} else {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">21.<span style="">            </span>$fake tag remove
Quo "$old +<st1:chmetcnv unitname="C" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">1c</st1:chmetcnv>" $now<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">22.<span style="">        </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">23.<span style="">        </span>incr i<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">24.<span style="">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">25.<span style="">    </span><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">26.<span style="">    </span>if [expr $e % 2] {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">27.<span style="">        </span>$fake tag add Quo
"$now +<st1:chmetcnv unitname="C" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">1c</st1:chmetcnv>" end<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">28.<span style="">    </span>} else {<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">29.<span style="">        </span>$fake tag remove Quo
"$now +<st1:chmetcnv unitname="C" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">1c</st1:chmetcnv>" end<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">30.<span style="">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">
				<span style="font-family: Consolas;" lang="EN-US">31.}<o:p></o:p></span>
		</p>
		<p class="MsoCaption" style="text-align: center;" align="center">
				<span lang="EN-US">_tool_core_hiQuoteContext</span>
		</p>
<img src ="http://www.cnitblog.com/gyn/aggbug/61556.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/gyn/" target="_blank">gyn_tadao</a> 2009-09-24 20:45 <a href="http://www.cnitblog.com/gyn/archive/2009/09/24/61556.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>cucumber2的工程</title><link>http://www.cnitblog.com/gyn/archive/2009/09/21/61510.html</link><dc:creator>gyn_tadao</dc:creator><author>gyn_tadao</author><pubDate>Mon, 21 Sep 2009 09:02:00 GMT</pubDate><guid>http://www.cnitblog.com/gyn/archive/2009/09/21/61510.html</guid><wfw:comment>http://www.cnitblog.com/gyn/comments/61510.html</wfw:comment><comments>http://www.cnitblog.com/gyn/archive/2009/09/21/61510.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/gyn/comments/commentRss/61510.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/gyn/services/trackbacks/61510.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<font face="黑体">最近一直在做<span lang="EN-US">cucuber</span>的第二个版本。为什么要做第二个呢？这是因为，在对<span lang="EN-US">cucuber</span>做了大量修改之后，目前稳定的版本是<span lang="EN-US">1.1.1</span>版，基本上应付日程的代码编写已经没有什么大问题了，支持包括语法高亮、自动补全、自动缩进和正则查找等，但是还是存在一些问题。比如说，绝大多数的函数直接使用了<span lang="EN-US">Tk</span>的组件路径，于是乎除非重写所有函数，不然无法支持多文档显示。另外，应该更清晰地割离不同语言的语法高亮，包括关键词，注解，变量等。还有一个最重要的待改进环节就是提升高亮的渲染速度。在早些时候写目前高亮引擎的时候，我采用了高亮的过程与快捷键绑定的方式，导致了代码非常臃肿且结构混杂。基本上就是一个打补丁的过程，哪个事件的高亮不对就修改哪个，虽然目前看来确实是对高亮支持地很好，但是代码已经面目全非，另外注解和字符串渲染的时机也有些问题，导致了很多重复的操作，降低了整体速度。现在在赛扬<span lang="EN-US">D3.33G</span>、<span lang="EN-US">512</span>兆内存的环境下<span lang="EN-US">,</span>打开一个<span lang="EN-US">20k</span>左右的文件，渲染速度约为<span lang="EN-US">4</span>秒，即使对于<span lang="EN-US">TclTk</span>这样的脚本，这个时长也是很难让人满意的。</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<font face="黑体">所以这次工程的目标就此确定，重写所有函数为可复用，提高渲染速度，重新编写工程架构为可扩展多文档显示，最后添加一个整理代码的工具。目前的渲染部分代码工作基本完成，速度提高了<span lang="EN-US">4-5</span>倍，对于小文件基本上做到载入即可渲染完成，<span lang="EN-US">80k</span>左右的代码也只需<span lang="EN-US">4</span>秒。</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 17.95pt; mso-char-indent-count: 1.71">
				<font face="黑体">
						<a href="/Files/gyn/cucumber-release-1.1.1-source.rar">
								<span lang="EN-US">Cucumber1.1.1</span>代码下载</a>
				</font>
		</p>
<img src ="http://www.cnitblog.com/gyn/aggbug/61510.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/gyn/" target="_blank">gyn_tadao</a> 2009-09-21 17:02 <a href="http://www.cnitblog.com/gyn/archive/2009/09/21/61510.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>最近的学习情况</title><link>http://www.cnitblog.com/gyn/archive/2009/08/16/60818.html</link><dc:creator>gyn_tadao</dc:creator><author>gyn_tadao</author><pubDate>Sun, 16 Aug 2009 02:29:00 GMT</pubDate><guid>http://www.cnitblog.com/gyn/archive/2009/08/16/60818.html</guid><wfw:comment>http://www.cnitblog.com/gyn/comments/60818.html</wfw:comment><comments>http://www.cnitblog.com/gyn/archive/2009/08/16/60818.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/gyn/comments/commentRss/60818.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/gyn/services/trackbacks/60818.html</trackback:ping><description><![CDATA[
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="ProgId" content="Word.Document" />
		<meta name="Generator" content="Microsoft Word 11" />
		<meta name="Originator" content="Microsoft Word 11" />
		<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" />
		<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>0</w:Zoom>
  <w:PunctuationKerning/>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
		<!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
		<style>
				<!--
 /* Font Definitions */
 @font-face
	{font-family:黑体;
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-alt:SimHei;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:1 135135232 16 0 262144 0;}
@font-face
	{font-family:"\@黑体";
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:1 135135232 16 0 262144 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	font-size:10.5pt;
	font-family:"Courier New";
	mso-fareast-font-family:黑体;
	mso-bidi-font-family:"Times New Roman";
	mso-font-kerning:1.0pt;}
 /* Page Definitions */
 @page
	{mso-page-border-surround-header:no;
	mso-page-border-surround-footer:no;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:42.55pt;
	mso-footer-margin:49.6pt;
	mso-paper-source:0;
	layout-grid:15.6pt;}
div.Section1
	{page:Section1;}
-->
		</style>
		<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]-->
		<p class="MsoNormal">
				<span style="font-family: 黑体;">最近在看</span>
				<span lang="EN-US">WebOS</span>
				<span style="font-family: 黑体;">和</span>
				<span lang="EN-US">Android</span>
				<span style="font-family: 黑体;">的相关资料，也算是学习吧，虽然并没有作进一步的深入开发的打算。</span>
				<span lang="EN-US">WebOS</span>
				<span style="font-family: 黑体;">的资料很少，现在能看的除了官网的</span>
				<span lang="EN-US">document</span>
				<span style="font-family: 黑体;">之外，只有一本《</span>
				<span lang="EN-US">Palm WebOS</span>
				<span style="font-family: 黑体;">》，我看的是</span>
				<span lang="EN-US">Rough Cut</span>
				<span style="font-family: 黑体;">版本的。</span>
				<span lang="EN-US">Android</span>
				<span style="font-family: 黑体;">的书籍就比较多了，甚至国人也有些的，这里要提醒切勿上当的的是一本宝岛某人写的，纯</span>
				<span lang="EN-US">Java</span>
				<span style="font-family: 黑体;">介绍加官网</span>
				<span lang="EN-US">Doc</span>
				<span style="font-family: 黑体;">，很春哥。我现在看的是一本叫《</span>
				<span lang="EN-US">Beginning Android</span>
				<span style="font-family: 黑体;">》的书，除了不多久，而且由浅入较深。这里说是较深，是因为较本书的目的来说是为了入门，所以不能算深；但是仔细读完这本书，我相信对</span>
				<span lang="EN-US">Android</span>
				<span style="font-family: 黑体;">的开发肯定能得心应手，至少能自己解决一些问题了，所以算是深的范围里了，综上所述用较深。一向来，我是很喜欢这种书的，因为学习效率高，文笔好的，更是看着如沐春风。至于《</span>
				<span lang="EN-US">Palm WebOS</span>
				<span style="font-family: 黑体;">》，我只能用痛苦来形容。举个例子吧，其中大量引用了一个提供每日信息的类似于</span>
				<span lang="EN-US">RSS</span>
				<span style="font-family: 黑体;">的</span>
				<span lang="EN-US">News</span>
				<span style="font-family: 黑体;">案例。应该说，这算是开发中的一个综合性高级应用了，最好是将它单独立为一章，在书的最后几个章节种。可本书，从第二章开始开始介绍，写了一个基本框架。第三章，在介绍</span>
				<span lang="EN-US">list</span>
				<span style="font-family: 黑体;">组件的时候，又拿了出来，改了一些数据之后，一讲到底，连</span>
				<span lang="EN-US">Ajax</span>
				<span style="font-family: 黑体;">都顺便说完了，这是很不好的。首先，其中有很多概念还没涉及到，你就拿出来讲，读者看不懂；第二，看不懂，可还得硬着头皮看，因为有很多细节他是穿插在里面的，不看，以后就更看不懂了；第三，这样就增加了学习的难度，无异于拔苗助长，看过去了，恭喜你，但更多人会将此书束之高阁了。我的做法是两本书一起看，一本卡住了先看看另外一本，等心情平复了再回过来看，如此交叉前进。这里有个前提是，这两本书都是关于移动开发的，虽然所属系统不同，但终究是一个大类，有相通可比较之处，一起看有利于总接归纳，算是相得益彰了。</span>
		</p>
		<p class="MsoNormal">
				<span style="font-family: 黑体;">另外，</span>
				<span lang="EN-US">WebOS</span>
				<span style="font-family: 黑体;">的开发终究是少了点调试的工具，虽然我很讨厌</span>
				<span lang="EN-US">Java</span>
				<span style="font-family: 黑体;">，但是难以调试的</span>
				<span lang="EN-US">WebOS</span>
				<span style="font-family: 黑体;">更令人痛疼，虽然开发的过程显然是</span>
				<span lang="EN-US">Js</span>
				<span style="font-family: 黑体;">来的舒畅。</span>
		</p>
<img src ="http://www.cnitblog.com/gyn/aggbug/60818.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/gyn/" target="_blank">gyn_tadao</a> 2009-08-16 10:29 <a href="http://www.cnitblog.com/gyn/archive/2009/08/16/60818.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>