Skip to content
Browse files

Thrift: add struct snippet and accompanying struct field macro

git-svn-id: http://svn.textmate.org/trunk/Bundles/Thrift.tmbundle@10083 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
1 parent 0191ebe commit 111a13c68f2cfec52d7448c7d14d266062da986d @kballard kballard committed
Showing with 120 additions and 0 deletions.
  1. +34 −0 Commands/struct field.tmCommand
  2. +47 −0 Macros/struct field.tmMacro
  3. +18 −0 Snippets/struct.tmSnippet
  4. +21 −0 info.plist
View
34 Commands/struct field.tmCommand
@@ -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>
View
47 Macros/struct field.tmMacro
@@ -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>
View
18 Snippets/struct.tmSnippet
@@ -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>
View
21 info.plist
@@ -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>

0 comments on commit 111a13c

Please sign in to comment.
Something went wrong with that request. Please try again.