<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://community.activestate.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>ActiveState Community Site - Trigger - now with tabstop support! - Comments</title>
 <link>http://community.activestate.com/forum-topic/trigger-now-tabstop-support</link>
 <description>Comments for &quot;Trigger - now with tabstop support!&quot;</description>
 <language>en</language>
<item>
 <title>Trigger - now with tabstop support!</title>
 <link>http://community.activestate.com/forum-topic/trigger-now-tabstop-support</link>
 <description>&lt;p&gt;Based on a suggestion from Nat[1] I updated Trigger with some code to detect tabstops in the snippet and emulate hitting tab the first time:&lt;/p&gt;
&lt;div class=&quot;geshi-block&quot;&gt;
&lt;div class=&quot;geshifilter javascript&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; view = ko.&lt;span style=&quot;color: #006600;&quot;&gt;views&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;manager&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;currentView&lt;/span&gt;;&lt;br /&gt;
view.&lt;span style=&quot;color: #006600;&quot;&gt;setFocus&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
view.&lt;span style=&quot;color: #006600;&quot;&gt;scimoz&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;wordLeftExtend&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt; = ko.&lt;span style=&quot;color: #006600;&quot;&gt;interpolate&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;interpolateStrings&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;%s&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; snippet = ko.&lt;span style=&quot;color: #006600;&quot;&gt;projects&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;findPart&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;snippet&#039;&lt;/span&gt;, &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;, &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;container&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;snippet&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Snippet_insert&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;snippet&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; rx = &lt;span style=&quot;color: #0066FF;&quot;&gt;/&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Â«|\%tabstop\:&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;/g&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;rx.&lt;span style=&quot;color: #006600;&quot;&gt;test&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;snippet.&lt;span style=&quot;color: #006600;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ko.&lt;span style=&quot;color: #006600;&quot;&gt;commands&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;doCommand&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;cmd_indent&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; msg = &lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;no snippet found named &amp;quot;&lt;/span&gt; + snippet;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; StatusBar_AddMessage&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;msg,&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;debugger&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #CC0000;&quot;&gt;5000&lt;/span&gt;,&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000066;&quot;&gt;alert&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;geshi-plain&quot;&gt;try {
var view = ko.views.manager.currentView;
view.setFocus();
view.scimoz.wordLeftExtend();

var name = ko.interpolate.interpolateStrings(&#039;%s&#039;);
var snippet = ko.projects.findPart(&#039;snippet&#039;, name, &#039;container&#039;);

if(snippet) {
    Snippet_insert(snippet);
    var rx = /(Â«|\%tabstop\:)/g;
    if (rx.test(snippet.value)) {
        ko.commands.doCommand(&#039;cmd_indent&#039;);
    }
} else {
    var msg = &amp;quot;no snippet found named &amp;quot; + snippet;
    StatusBar_AddMessage(msg,&amp;quot;debugger&amp;quot;,5000,true);
}
} catch(e) {
    alert(e);
}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;[1] &lt;a href=&quot;http://community.activestate.com/forum-topic/snippets-problem-tabstops#comment-2598&quot; title=&quot;http://community.activestate.com/forum-topic/snippets-problem-tabstops#comment-2598&quot;&gt;http://community.activestate.com/forum-topic/snippets-problem-tabstops#c...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I corrected the code above to handle all tabstops, not just the older style ones I originally tested with =)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I updated the above snippet with re-written code that only uses the new ko.* api. This version of trigger wil only work with 4.2.0 Beta 7 and later.&lt;/p&gt;
</description>
 <comments>http://community.activestate.com/forum-topic/trigger-now-tabstop-support#comments</comments>
 <category domain="http://community.activestate.com/forums/komodo-extensions-0">Komodo Macros and Extensions</category>
 <category domain="http://community.activestate.com/os/all-any">All / Any</category>
 <enclosure url="http://community.activestate.com/files/trigger-tabstops.kpz" length="1257" type="application/octet-stream" />
 <pubDate>Wed, 15 Aug 2007 18:49:29 +0100</pubDate>
 <dc:creator>jeffg</dc:creator>
 <guid isPermaLink="false">1290 at http://community.activestate.com</guid>
</item>
</channel>
</rss>
