Skip to content

Commit

Permalink
Thrift: add struct snippet and accompanying struct field macro
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.textmate.org/trunk/Bundles/Thrift.tmbundle@10083 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
lilyball committed Jun 30, 2008
1 parent 0191ebe commit 111a13c
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Commands/struct field.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby
# this command is intended to be used to generate the struct field macro
# the struct field macro is ^E followed by this command.
i = 1
if ENV['TM_CURRENT_LINE'] =~ /^\s*(\d+):/
i = $1.to_i + 1
end
puts
print "${1:#{i}}${1/.+/: /m}${2:i32} ${3:field}${4/.+/ = /m}${4:value},$0"
</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>none</string>
<key>name</key>
<string>struct field</string>
<key>output</key>
<string>insertAsSnippet</string>
<key>scope</key>
<string>meta.struct.thrift</string>
<key>uuid</key>
<string>9240E318-0643-4BF7-8EBA-DD947C8CB7B9</string>
</dict>
</plist>
47 changes: 47 additions & 0 deletions Macros/struct field.tmMacro
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>commands</key>
<array>
<dict>
<key>command</key>
<string>moveToEndOfParagraph:</string>
</dict>
<dict>
<key>argument</key>
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby

i = 1
if ENV['TM_CURRENT_LINE'] =~ /^\s*(\d+):/
i = $1.to_i + 1
end

puts
print "${1:#{i}}${1/.+/: /m}${2:i32} ${3:field}${4/.+/ = /m}${4:value},$0"
</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>none</string>
<key>output</key>
<string>insertAsSnippet</string>
</dict>
<key>command</key>
<string>executeCommandWithOptions:</string>
</dict>
</array>
<key>keyEquivalent</key>
<string></string>
<key>name</key>
<string>struct field</string>
<key>scope</key>
<string>meta.struct.thrift</string>
<key>uuid</key>
<string>ED84802A-BD69-4810-9F0B-547A9DA70033</string>
</dict>
</plist>
18 changes: 18 additions & 0 deletions Snippets/struct.tmSnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>content</key>
<string>struct ${1:Name} {
${2:1}${2/.+/: /m}${3:i32} ${4:field}${5/.+/ = /m}${5:value},$0
}</string>
<key>name</key>
<string>struct</string>
<key>scope</key>
<string>source.thrift -meta</string>
<key>tabTrigger</key>
<string>str</string>
<key>uuid</key>
<string>FA5FBCA2-12D6-4C3B-A9A0-5B9C9AD141AD</string>
</dict>
</plist>
21 changes: 21 additions & 0 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,29 @@
<string>Kevin Ballard</string>
<key>description</key>
<string>&lt;a href="http://incubator.apache.org/thrift/"&gt;Thrift&lt;/a&gt; is a cross-language serialization and RPC framework.</string>
<key>mainMenu</key>
<dict>
<key>excludedItems</key>
<array>
<string>9240E318-0643-4BF7-8EBA-DD947C8CB7B9</string>
<string>ED84802A-BD69-4810-9F0B-547A9DA70033</string>
</array>
<key>items</key>
<array>
<string>FA5FBCA2-12D6-4C3B-A9A0-5B9C9AD141AD</string>
</array>
<key>submenus</key>
<dict/>
</dict>
<key>name</key>
<string>Thrift</string>
<key>ordering</key>
<array>
<string>ED84802A-BD69-4810-9F0B-547A9DA70033</string>
<string>9E5704AC-54ED-4D7C-946C-6DC3727BDC4C</string>
<string>FA5FBCA2-12D6-4C3B-A9A0-5B9C9AD141AD</string>
<string>9240E318-0643-4BF7-8EBA-DD947C8CB7B9</string>
</array>
<key>uuid</key>
<string>503C9BCE-892F-420D-86B5-B6B8E34F6742</string>
</dict>
Expand Down

0 comments on commit 111a13c

Please sign in to comment.