<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>uxebu » blog &#187; tools</title>
	<atom:link href="http://uxebu.com/tag/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://uxebu.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 23 Apr 2012 19:10:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>&#8220;Duplicate line/selection&#8221; macro for Komodo</title>
		<link>http://uxebu.com/blog/2008/06/26/duplicate-lineselection-macro-for-komodo/</link>
		<comments>http://uxebu.com/blog/2008/06/26/duplicate-lineselection-macro-for-komodo/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 16:43:05 +0000</pubDate>
		<dc:creator>wolfram</dc:creator>
				<category><![CDATA[development tools]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[komodo]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=13</guid>
		<description><![CDATA[I don&#8217;t remember which IDE it was that made me learn to use the shortcuts (may be Turbo Pascal back then), and (almost) since then I am too lazy to learn new shortcuts. Now I always first customize the keyboard shortcuts. And already for a long time I am missing Ctrl+D/Apple+D for Komodo Edit which [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t remember which IDE it was that made me learn to use the shortcuts (may be Turbo Pascal back then), and (almost) since then I am too lazy to learn new shortcuts. Now I always first customize the keyboard shortcuts.<br />
And already for a long time I am missing Ctrl+D/Apple+D for <a href="http://www.activestate.com/Products/komodo_ide/komodo_edit.mhtml">Komodo Edit</a> which I use for editing JavaScript, CSS and HTML. This shortcut is supposed to duplicate either the current line or the entire selection. To make a long story short, here is <a href="http://www.vimeo.com/1237622">the screencast video</a> (1:04 min) that shows you how to apply the macro shown below.<br />
<span id="more-13"></span><br />
<script type="text/javascript">
// initHighlightOnLoad is deprecated.
// if parseOnLoad==true, the onLoad init stuff is run.
// if parseOnLoad==false, you can call dojox.highlight.init(domNode)
dojo.require("dojox.highlight");
dojo.require("dojox.highlight.languages.javascript");
dojo.addOnLoad(function(){
dojo.query("code").forEach(dojox.highlight.init);
});
</script></p>
<style type="text/css">
@import "http://blog.uxebu.com/js/dojo-1.1.1/dojox/highlight/resources/highlight.css";
</style>
<p>Since there seems to be no native implementation of that in Komodo I just took some JavaScript skills and the time to look into the macro stuff, and found out that it is actually pretty easy. After looking at the <a href="http://ASPN.ActiveState.com/ASPN/docs/Komodo/4.4/macroapi.html#macroapi_js">macro API doc</a> to find out how to differentiate if something is selected or not. It was as simple as recording the two macros and mixing them together, surrounded by an &#8220;if&#8221; that does the job right for the selection and the other for the current line. And I was done.</p>
<p>This is the end result. Just create a new macro and put the source there (the video shows how to do that in detail).</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// Duplicate line/selection macro, more info at</span><br />
<span style="color: #006600; font-style: italic;">// http://blog.uxebu.com/2008/06/26/duplicate-lineselection-macro-for-komodo/</span><br />
komodo.<span style="color: #660066;">assertMacroVersion</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>komodo.<span style="color: #660066;">view</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> komodo.<span style="color: #660066;">view</span>.<span style="color: #660066;">setFocus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ko.<span style="color: #660066;">views</span>.<span style="color: #660066;">manager</span>.<span style="color: #660066;">currentView</span>.<span style="color: #660066;">scimoz</span>.<span style="color: #660066;">selText</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Copy the current selection</span><br />
&nbsp; &nbsp; komodo.<span style="color: #660066;">doCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cmd_copy'</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; komodo.<span style="color: #660066;">doCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cmd_lineNext'</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; komodo.<span style="color: #660066;">doCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cmd_linePrevious'</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; komodo.<span style="color: #660066;">doCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cmd_paste'</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Copy the current line</span><br />
&nbsp; &nbsp; komodo.<span style="color: #660066;">doCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cmd_homeAbsolute'</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; komodo.<span style="color: #660066;">doCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cmd_selectLineNext'</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; komodo.<span style="color: #660066;">doCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cmd_copy'</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; komodo.<span style="color: #660066;">doCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cmd_paste'</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; komodo.<span style="color: #660066;">doCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cmd_paste'</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; komodo.<span style="color: #660066;">doCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cmd_linePrevious'</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><object width="499" height="436"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=1237622&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://www.vimeo.com/moogaloop.swf?clip_id=1237622&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="499" height="436"></embed></object></p>
<p>Have fun duplicating &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2008/06/26/duplicate-lineselection-macro-for-komodo/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

