-
Notifications
You must be signed in to change notification settings - Fork 4
Add sublime_plugin stubs. #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import sublime | ||
| from typing import Optional, Union, List, Dict, Tuple | ||
|
|
||
|
|
||
| class CommandInputHandler(): | ||
| def name(self) -> str: ... | ||
| def next_input(self, args: dict) -> Optional[CommandInputHandler]: ... | ||
| def placeholder(self) -> str: ... | ||
| def initial_text(self) -> str: ... | ||
| def preview(self, arg: dict) -> Union[str, sublime.Html]: ... | ||
| def validate(self, arg: dict) -> bool: ... | ||
| def cancel(self) -> None: ... | ||
| def confirm(self, arg: dict) -> None: ... | ||
|
|
||
|
|
||
| class BackInputHandler(CommandInputHandler): | ||
| pass | ||
|
|
||
|
|
||
| class TextInputHandler(CommandInputHandler): | ||
| def description(self, text: str) -> str: ... | ||
|
|
||
|
|
||
| class ListInputHandler(CommandInputHandler): | ||
| def list_items(self) -> list: ... | ||
| def description(self, v: object, text: str) -> str: ... | ||
|
|
||
|
|
||
| class Command(): | ||
| def is_enabled(self) -> bool: ... | ||
| def is_visible(self) -> bool: ... | ||
| def is_checked(self) -> bool: ... | ||
| def description(self) -> str: ... | ||
| def input(self, args: dict) -> Optional[CommandInputHandler]: ... | ||
| def input_description(self) -> str: ... | ||
|
|
||
|
|
||
| class ApplicationCommand(Command): | ||
| def run(self) -> None: ... | ||
|
|
||
|
|
||
| class WindowCommand(Command): | ||
| window: sublime.Window | ||
|
|
||
| def run(self) -> None: ... | ||
|
|
||
|
|
||
| class TextCommand(Command): | ||
| view: sublime.View | ||
|
|
||
| def run(self, edit: sublime.Edit) -> None: ... | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is one is tricky. TextCommand can accepts more argument. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think just having |
||
| def want_event(self) -> bool: ... | ||
|
|
||
|
|
||
| class EventListener(): | ||
| def on_new(self, view: sublime.View) -> None: ... | ||
| def on_new_async(self, view: sublime.View) -> None: ... | ||
| def on_clone(self, view: sublime.View) -> None: ... | ||
| def on_clone_async(self, view: sublime.View) -> None: ... | ||
| def on_load(self, view: sublime.View) -> None: ... | ||
| def on_load_async(self, view: sublime.View) -> None: ... | ||
| def on_pre_close(self, view: sublime.View) -> None: ... | ||
| def on_close(self, view: sublime.View) -> None: ... | ||
| def on_pre_save(self, view: sublime.View) -> None: ... | ||
| def on_pre_save_async(self, view: sublime.View) -> None: ... | ||
| def on_post_save(self, view: sublime.View) -> None: ... | ||
| def on_post_save_async(self, view: sublime.View) -> None: ... | ||
| def on_modified(self, view: sublime.View) -> None: ... | ||
| def on_modified_async(self, view: sublime.View) -> None: ... | ||
| def on_selection_modified(self, view: sublime.View) -> None: ... | ||
| def on_selection_modified_async(self, view: sublime.View) -> None: ... | ||
| def on_activated(self, view: sublime.View) -> None: ... | ||
| def on_activated_async(self, view: sublime.View) -> None: ... | ||
| def on_deactivated(self, view: sublime.View) -> None: ... | ||
| def on_deactivated_async(self, view: sublime.View) -> None: ... | ||
| def on_hover(self, view: sublime.View, point: int, hover_zone: int) -> None: ... | ||
| def on_query_context(self, view: sublime.View, key: str, operator: int, operand: str, match_all: bool) -> Optional[None]: ... | ||
| def on_query_completions(self, view: sublime.View, prefix: str, locations: List[int]) -> Union[None, list, tuple]: ... | ||
| def on_text_command(self, view: sublime.View, command_name: str, args: dict) -> Tuple[str, dict]: ... | ||
| def on_post_text_command(self, view: sublime.View, command_name: str, args: dict) -> None: ... | ||
| def on_window_command(self, view: sublime.Window, command_name: str, args: dict) -> Tuple[str, dict]: ... | ||
| def on_post_window_command(self, view: sublime.Window, command_name: str, args: dict) -> None: ... | ||
|
|
||
|
|
||
| class ViewEventListener(): | ||
| view: sublime.View | ||
|
|
||
| @classmethod | ||
| def is_applicable(cls, settings: sublime.Settings) -> bool: ... | ||
|
|
||
| @classmethod | ||
| def applies_to_primary_view_only(cls) -> bool: ... | ||
|
|
||
| def on_load(self) -> None: ... | ||
| def on_load_async(self) -> None: ... | ||
| def on_pre_close(self) -> None: ... | ||
| def on_close(self) -> None: ... | ||
| def on_pre_save(self) -> None: ... | ||
| def on_pre_save_async(self) -> None: ... | ||
| def on_post_save(self) -> None: ... | ||
| def on_post_save_async(self) -> None: ... | ||
| def on_modified(self) -> None: ... | ||
| def on_modified_async(self) -> None: ... | ||
| def on_selection_modified(self) -> None: ... | ||
| def on_selection_modified_async(self) -> None: ... | ||
| def on_activated_modified(self) -> None: ... | ||
| def on_activated_modified_async(self) -> None: ... | ||
| def on_deactivated_modified(self) -> None: ... | ||
| def on_deactivated_modified_async(self) -> None: ... | ||
| def on_hover(self, point: int, hover_zone: int) -> None: ... | ||
| def on_query_context(self, key: str, operator: int, operand: str, match_all: bool) -> Optional[None]: ... | ||
| def on_query_completions(self, prefix: str, locations: List[int]) -> Union[None, list, tuple]: ... | ||
| def on_text_command(self, command_name: str, args: dict) -> Tuple[str, dict]: ... | ||
| def on_post_text_command(self, command_name: str, args: dict) -> None: ... | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
def preview(self, arg: str)def validate(self, arg: str)def confirm(self, arg: str)Also note that confirm can receive an event. Not sure how to handle this.
We could add
def confirm_(self, arg: str, event: sublime.Event)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't verified this right now, but from the documentation, the
argreceived should be the value of a ListInputHandler's list item, which may be any serializable, meaning ListInputHandler must be a generic class.TextInputHandler would then inherit
CommandInputHandler[str].This means that
ListInputItemneeds to be generic as well, but we don't have that at all currently since it's ST4 only.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. I only tried on TextInputHandler.
What's the plan for Python 3.8 and ST4? Is there a specific branch I should look at?