def menu(options): """ Accepts a list and causes TextMate to show an inline menu. If options is a list of strings, will return the selected index. If options is a list of (key, value) tuples, will return value of the selected key. Note that we don't use dicts, so that key-value options can be ordered. If you want to use a dict, try dict.items(). In either input case, a list item with value `None` causes tm_dialog to separator for that index. """ hashed_options = False if not options: return None if all_are_instance(options, (unicode, str, NoneType)): menu = dict(menuItems=[item(val) for val in options]) elif all_are_instance(options, (tuple, NoneType)): hashed_options = True menu = dict(menuItems=[item(pair) for pair in options]) plist = to_plist(menu) cmd = 'bash -c "%s -up %s"' % (sh_escape(dialog), sh_escape(plist)) result = from_plist(sh(cmd)) if not 'selectedIndex' in result: return None index = int(result['selectedIndex']) if hashed_options: return options[index][1] return options[index]
def html_header(page_title, sub_title, window_title=None): if not window_title: window_title = page_title sys.stdout.flush() return sh(""" export TM_SUPPORT_PATH="%(tm_support_path)s" "%(tm_ruby)s" -r"%(tm_support_path)s/lib/web_preview.rb" <<-'RUBY' puts html_head( :window_title => "%(window_title)s", :page_title => "%(page_title)s", :sub_title => "%(sub_title)s" ) RUBY """ % { "tm_ruby": tm_ruby, "tm_support_path": tm_support_path, "window_title": window_title, "page_title": page_title, "sub_title": sub_title, })
def html_header(page_title, sub_title, window_title=None): if not window_title: window_title = page_title sys.stdout.flush() return sh( """ export TM_SUPPORT_PATH="%(tm_support_path)s" "%(tm_ruby)s" -r"%(tm_support_path)s/lib/web_preview.rb" <<-'RUBY' puts html_head( :window_title => "%(window_title)s", :page_title => "%(page_title)s", :sub_title => "%(sub_title)s" ) RUBY """ % { "tm_ruby": tm_ruby, "tm_support_path": tm_support_path, "window_title": window_title, "page_title": page_title, "sub_title": sub_title, })
def html_header(title, subtitle): return sh('source %s; html_header %s %s' % (webpreview, sh_escape(title), sh_escape(subtitle)))
def html_footer(): return sh('source %s; html_footer' % webpreview)
def html_header(title, subtitle): return sh('source %s; html_header "%s" "%s"' % (webpreview, title, subtitle))
def html_footer(): return sh("source %s; html_footer" % webpreview)
# encoding: utf-8 import os env = os.environ.get import sys sys.path.append(env("TM_SUPPORT_PATH")+"/lib") import dialog from tm_helpers import sh import re word = env('TM_CURRENT_WORD') if not word: word = "" functions = sh('grep -i "^$TM_CURRENT_WORD" "$TM_BUNDLE_SUPPORT"/tags.txt').split("\n") functions.pop() if len(functions) > 1: skip_prefix = False if word and word[-1] == '-': # If the last char in the word is a _ we don't show the word in the completion list, # to enable the user to continue typing. See: array_⌥⎋ skip_prefix = True names = [] regex = re.compile(word+"(.*?)(%|$)") for line in functions :