Make confirm dialog take arbitrary keys
Confirm now takes the list of options, list of keys to select them and the default value. Returned values are always a 1-based index into the list (like SelectFromList) or -1 to mean esc/ctrl-c. This uses a nice popup dialog in vim and a crappy input on neovim.
This commit is contained in:
parent
6b74e584d5
commit
154e727b96
6 changed files with 82 additions and 28 deletions
|
|
@ -14,7 +14,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
from vimspector.debug_session import DebugSession
|
||||
from vimspector import utils
|
||||
from vimspector import utils, settings
|
||||
|
||||
|
||||
class JavaDebugAdapter( object ):
|
||||
|
|
@ -36,8 +36,16 @@ class JavaDebugAdapter( object ):
|
|||
'arguments': {},
|
||||
} )
|
||||
|
||||
utils.Confirm( self.debug_session._api_prefix,
|
||||
'Code has changed, hot reload?',
|
||||
handler )
|
||||
mode = settings.Get( 'java_hotcodereplace_mode' )
|
||||
if mode == 'ask':
|
||||
utils.Confirm( self.debug_session._api_prefix,
|
||||
'Code has changed, hot reload?',
|
||||
handler,
|
||||
default_value = 1 )
|
||||
elif mode == 'always':
|
||||
self.debug_session._connection.DoRequest( None, {
|
||||
'command': 'redefineClasses',
|
||||
'arguments': {},
|
||||
} )
|
||||
elif body.get( 'message' ):
|
||||
utils.UserMessage( 'Hot code replace: ' + body[ 'message' ] )
|
||||
|
|
|
|||
|
|
@ -949,10 +949,12 @@ class DebugSession( object ):
|
|||
def handle_choice( choice ):
|
||||
arguments = {}
|
||||
if choice == 1:
|
||||
# yes
|
||||
arguments[ 'terminateDebuggee' ] = True
|
||||
elif choice == 0:
|
||||
elif choice == 2:
|
||||
# no
|
||||
arguments[ 'terminateDebuggee' ] = False
|
||||
elif choice == -1:
|
||||
else:
|
||||
# Abort
|
||||
return
|
||||
|
||||
|
|
@ -961,7 +963,9 @@ class DebugSession( object ):
|
|||
utils.Confirm( self._api_prefix,
|
||||
"Terminate debuggee?",
|
||||
handle_choice,
|
||||
default_value = 3 )
|
||||
default_value = 3,
|
||||
options = [ '(Y)es', '(N)o', '(D)efault' ],
|
||||
keys = [ 'y', 'n', 'd' ] )
|
||||
|
||||
|
||||
def _PrepareAttach( self, adapter_config, launch_config ):
|
||||
|
|
|
|||
|
|
@ -59,7 +59,10 @@ DEFAULTS = {
|
|||
'expand_or_jump': [ '<CR>', '<2-LeftMouse>' ],
|
||||
'focus_thread': [ '<leader><CR>' ],
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
# Custom
|
||||
'java_hotcodereplace_mode': 'ask',
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -390,18 +390,26 @@ def ConfirmCallback( confirm_id, result ):
|
|||
handler( result )
|
||||
|
||||
|
||||
def Confirm( api_prefix, prompt, handler, default_value = 3, options = None ):
|
||||
global CONFIRM_ID
|
||||
def Confirm( api_prefix,
|
||||
prompt,
|
||||
handler,
|
||||
default_value = 2,
|
||||
options: list = None,
|
||||
keys: list = None ):
|
||||
if not options:
|
||||
options = [ '(Y)es', '(N)o', '(D)efault' ]
|
||||
options = [ '(Y)es', '(N)o' ]
|
||||
if not keys:
|
||||
keys = [ 'y', 'n' ]
|
||||
|
||||
global CONFIRM_ID
|
||||
CONFIRM_ID += 1
|
||||
CONFIRM[ CONFIRM_ID ] = handler
|
||||
Call( f'vimspector#internal#{ api_prefix }popup#Confirm',
|
||||
CONFIRM_ID,
|
||||
prompt,
|
||||
options,
|
||||
default_value )
|
||||
default_value,
|
||||
keys )
|
||||
|
||||
|
||||
def AppendToBuffer( buf, line_or_lines, modified=False ):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue