Skip to content

Commit

Permalink
Fixed bug in list_commands where commands in unzipped packages would …
Browse files Browse the repository at this point in the history
…go heywire
  • Loading branch information
sublimator committed Feb 10, 2013
1 parent 059157b commit da8797d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
18 changes: 10 additions & 8 deletions README.creole
Expand Up @@ -15,20 +15,17 @@ Copy from the Default.sublime-keymap.template the last line that contains a
multitude of bindings with `insert_binding_repr` and place it in your User
keymap.

How it works is you press the modifiers, then PLUS, THEN the key, pressing in
total TWO key combinations (the latter a lonely combo of one)

You can't bind to just a modifier like alt, so plus seems a resaonable
key/mnemonic. Note that on a standard US keyboard `=` is on the same key as `+`
(plus)

So how would you insert alt+q? You can think of it like this:

* PRESS `alt` and hold it down
* PRESS `=` while thinking PLUS then lift all fingers
* PRESS `q`
In sublime `{"keys": [...]}` terms:
Note that on a standard US keyboard `=` is on the same key as `+` (plus) You
can't bind to just a modifier like alt, so plus seems a resaonable key/mnemonic.

In sublime `{"keys": [...]}` terms previous exmaple would be:

* PRESS `["alt+="]`
* PRESS `["q"]`
Expand Down Expand Up @@ -61,7 +58,7 @@ So how would you insert ctrl+alt+q? (In sublime terms)
* PRESS `ctrl+alt+=`
* PRESS `q`
=== Help? You can't press down/enter/up ? ===
=== Help? You can't insert_binding_repr for down|enter|up ? ===

Unfortunately, some bindings don't work as the second key due to the quickpanel
swallowing them:
Expand Down Expand Up @@ -119,3 +116,8 @@ The workaround is to type the first letter of the key you desire, eg:
"args": {"pref_type": "sublime-commands"}}
]
}}}

=== TODO ===

Set cyclic tab key for auto complete

5 changes: 3 additions & 2 deletions commands_base.py
Expand Up @@ -21,6 +21,7 @@ def glob_and_parse_package_json(pattern):
yield pkg, name, f, text, setting_dict

class IEditJSONPreference:
"Just factored out all overideables into this class for visibility"
format_cols = () # MUST_IMPLEMENT
settings_pattern = "*.sublime-json" # MUST OVERRIDE

Expand All @@ -30,11 +31,11 @@ def on_selection(self, setting):
"must implement"
def format_for_display(self, settings):
return settings # for quick panel

class EditJSONPreferenceBase(sublime_plugin.WindowCommand, IEditJSONPreference):
def format_for_display(self, settings):
return format_for_display(settings, cols=self.format_cols)

def run(self):
window = self.window
settings = []
Expand Down
6 changes: 4 additions & 2 deletions helpers.py
Expand Up @@ -30,9 +30,11 @@ def package_name_and_package_relative_path(fn):
d = m.groupdict()
return d['package'], d['relative']
else:
# TODO: fix this horrid code!
sep = os.path.sep
return (fn.split(sep)[len(sublime.packages_path().split(sep))],
fn[len(sublime.packages_path()):])
pkg = fn.split(sep)[len(sublime.packages_path().split(sep))]
return (pkg,
fn[len(sublime.packages_path()) + 1 + len(pkg) + 1:])

def get_zip_file_and_relative(fn):
m = PREFIX_ZIP_PACKAGE_RELATIVE.search(fn )
Expand Down
3 changes: 1 addition & 2 deletions list_commands.py
Expand Up @@ -38,10 +38,9 @@ def run(self, args=[]):
# TODO
# TODO: filename relative to package
# pkg = f.split(sep)[len(sublime.packages_path().split(sep))]

pkg, relative = package_name_and_package_relative_path(f)
pkg = "%s/%s" % (pkg, relative)

# print (pkg)

commands += [(
(cmd_type, pkg, cmd_name),
Expand Down

0 comments on commit da8797d

Please sign in to comment.