mirror of
https://github.com/hexedtech/codemp-sublime.git
synced 2025-03-29 21:01:34 +01:00
chore: improved the generic input handlers
This commit is contained in:
parent
db033e7882
commit
dcb95a8cd8
1 changed files with 15 additions and 19 deletions
|
@ -6,12 +6,11 @@ from typing import Tuple, Union, List
|
||||||
# Input handlers
|
# Input handlers
|
||||||
############################################################
|
############################################################
|
||||||
class SimpleTextInput(sublime_plugin.TextInputHandler):
|
class SimpleTextInput(sublime_plugin.TextInputHandler):
|
||||||
def __init__(self, *args: Tuple[str, Union[str, List[str]]]):
|
def __init__(self, args):
|
||||||
self.input, *self.next_inputs = args
|
self.input, *self.next_inputs = args
|
||||||
self.argname = self.input[0]
|
self.argname, self.default = self.input
|
||||||
self.default = self.input[1]
|
|
||||||
|
|
||||||
def initial_text(self):
|
def placeholder(self):
|
||||||
if isinstance(self.default, str):
|
if isinstance(self.default, str):
|
||||||
return self.default
|
return self.default
|
||||||
else:
|
else:
|
||||||
|
@ -21,19 +20,17 @@ class SimpleTextInput(sublime_plugin.TextInputHandler):
|
||||||
return self.argname
|
return self.argname
|
||||||
|
|
||||||
def next_input(self, args):
|
def next_input(self, args):
|
||||||
if len(self.next_inputs) > 0:
|
if self.next_inputs:
|
||||||
if self.next_inputs[0][0] not in args:
|
if isinstance(self.next_inputs[0][1], list):
|
||||||
if isinstance(self.next_inputs[0][1], list):
|
return SimpleListInput(self.next_inputs)
|
||||||
return SimpleListInput(*self.next_inputs)
|
else:
|
||||||
else:
|
return SimpleTextInput(self.next_inputs)
|
||||||
return SimpleTextInput(*self.next_inputs)
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleListInput(sublime_plugin.ListInputHandler):
|
class SimpleListInput(sublime_plugin.ListInputHandler):
|
||||||
def __init__(self, *args: Tuple[str, Union[List[str], str]]):
|
def __init__(self, args):
|
||||||
self.input, *self.next_inputs = args
|
self.input, *self.next_inputs = args
|
||||||
self.argname = self.input[0]
|
self.argname, self.list = self.input
|
||||||
self.list = self.input[1]
|
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
return self.argname
|
return self.argname
|
||||||
|
@ -45,12 +42,11 @@ class SimpleListInput(sublime_plugin.ListInputHandler):
|
||||||
return [self.list]
|
return [self.list]
|
||||||
|
|
||||||
def next_input(self, args):
|
def next_input(self, args):
|
||||||
if len(self.next_inputs) > 0:
|
if self.next_inputs:
|
||||||
if self.next_inputs[0][0] not in args:
|
if isinstance(self.next_inputs[0][1], str):
|
||||||
if isinstance(self.next_inputs[0][1], str):
|
return SimpleTextInput(self.next_inputs)
|
||||||
return SimpleTextInput(*self.next_inputs)
|
else:
|
||||||
else:
|
return SimpleListInput(self.next_inputs)
|
||||||
return SimpleListInput(*self.next_inputs)
|
|
||||||
|
|
||||||
|
|
||||||
# class ActiveWorkspacesIdList(sublime_plugin.ListInputHandler):
|
# class ActiveWorkspacesIdList(sublime_plugin.ListInputHandler):
|
||||||
|
|
Loading…
Add table
Reference in a new issue