Skip to content

Commit

Permalink
remove need for 'xiki' view setting, and enable double-click support
Browse files Browse the repository at this point in the history
  • Loading branch information
lunixbochs committed Oct 30, 2012
1 parent 8e5e1a9 commit 5183e32
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
6 changes: 3 additions & 3 deletions Default (OSX).sublime-keymap
@@ -1,4 +1,4 @@
[ [
{"keys": ["super+enter"], "command": "xiki", "context": [{ "key": "setting.xiki" }]}, {"keys": ["super+enter"], "command": "xiki", "context": [{"key": "xiki"}]},
{"keys": ["super+shift+enter"], "command": "xiki_continue", "context": [{ "key": "setting.xiki" }]} {"keys": ["super+shift+enter"], "command": "xiki_continue", "context": [{"key": "xiki"}]}
] ]
6 changes: 3 additions & 3 deletions Default.sublime-keymap
@@ -1,4 +1,4 @@
[ [
{"keys": ["ctrl+enter"], "command": "xiki", "context": [{ "key": "setting.xiki" }]}, {"keys": ["ctrl+enter"], "command": "xiki", "context": [{"key": "xiki"}]},
{"keys": ["ctrl+shift+enter"], "command": "xiki_continue", "context": [{ "key": "setting.xiki" }]} {"keys": ["ctrl+shift+enter"], "command": "xiki_continue", "context": [{"key": "xiki"}]}
] ]
10 changes: 5 additions & 5 deletions Default.sublime-mousemap
@@ -1,9 +1,9 @@
[ [
/*
{ {
"button": "button1", "count": 2, "button": "button1", "count": 2,
"command": "xiki_click", "press_command": "drag_select",
"context": [{"key": "setting.xiki"}] "press_args": {"by": "words"},

"command": "xiki_click"
} }
*/ ]
]
29 changes: 13 additions & 16 deletions xiki.py
Expand Up @@ -447,17 +447,9 @@ def on_query_completions(self, view, prefix, locations):
target, partial = os.path.split(dirname(path, tree, tag)) target, partial = os.path.split(dirname(path, tree, tag))
return completions(target, partial) return completions(target, partial)


def set_xiki(self, view): def on_query_context(self, view, key, operator, operand, match_all):
if is_xiki_buffer(view): if key == 'xiki' and is_xiki_buffer(view):
view.settings().set('xiki', True) return True
else:
view.settings().set('xiki', False)

def on_activated(self, view):
self.set_xiki(view)

def on_load(self, view):
self.set_xiki(view)


def on_close(self, view): def on_close(self, view):
vid = view.id() vid = view.id()
Expand Down Expand Up @@ -487,7 +479,6 @@ def run(self):
view = self.window.new_file() view = self.window.new_file()
settings = view.settings() settings = view.settings()


settings.set('xiki', True)
settings.set('tab_size', 2) settings.set('tab_size', 2)
settings.set('translate_tabs_to_spaces', True) settings.set('translate_tabs_to_spaces', True)
settings.set('syntax', 'Packages/SublimeXiki/Xiki.tmLanguage') settings.set('syntax', 'Packages/SublimeXiki/Xiki.tmLanguage')
Expand All @@ -496,8 +487,14 @@ class XikiClick(sublime_plugin.WindowCommand):
def run(self): def run(self):
view = self.window.active_view() view = self.window.active_view()
if is_xiki_buffer(view): if is_xiki_buffer(view):
sel = view.sel()
s = sel[0]

text = view.substr(s)
is_word = r'^(\w+|[^\w]+)$'
if not re.match(is_word, text.strip('\n')):
return

sel.clear()
sel.add(sublime.Region(s.b, s.a))
xiki(view) xiki(view)
else:
# emulate the default double-click behavior
# if we're not in a xiki buffer
view.run_command('expand_selection', {'to': 'word'})

0 comments on commit 5183e32

Please sign in to comment.