mirror of
https://github.com/powerline/powerline.git
synced 2025-07-25 14:54:54 +02:00
Fix problems in mode segment
- It was impossible to configure visual block and select block mode strings: JSON strings can contain neither raw control characters nor escape sequences for them - It was impossible to override only some of the strings: missing key generates KeyError exception, not IndexError
This commit is contained in:
parent
f1976c2022
commit
b7d8495b9c
@ -22,10 +22,10 @@ vim_modes = {
|
|||||||
'no': u'N·OPER',
|
'no': u'N·OPER',
|
||||||
'v': u'VISUAL',
|
'v': u'VISUAL',
|
||||||
'V': u'V·LINE',
|
'V': u'V·LINE',
|
||||||
'': u'V·BLCK',
|
'^V': u'V·BLCK',
|
||||||
's': u'SELECT',
|
's': u'SELECT',
|
||||||
'S': u'S·LINE',
|
'S': u'S·LINE',
|
||||||
'': u'S·BLCK',
|
'^S': u'S·BLCK',
|
||||||
'i': u'INSERT',
|
'i': u'INSERT',
|
||||||
'R': u'REPLACE',
|
'R': u'REPLACE',
|
||||||
'Rv': u'V·RPLCE',
|
'Rv': u'V·RPLCE',
|
||||||
@ -38,6 +38,11 @@ vim_modes = {
|
|||||||
'!': u'SHELL',
|
'!': u'SHELL',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mode_translations = {
|
||||||
|
chr(ord('V')-0x40): '^V',
|
||||||
|
chr(ord('S')-0x40): '^S',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def mode(override=None):
|
def mode(override=None):
|
||||||
'''Return the current vim mode.
|
'''Return the current vim mode.
|
||||||
@ -49,11 +54,12 @@ def mode(override=None):
|
|||||||
mode = mode({ 'n': 'NORM' })
|
mode = mode({ 'n': 'NORM' })
|
||||||
'''
|
'''
|
||||||
mode = vim_funcs['mode']()
|
mode = vim_funcs['mode']()
|
||||||
|
mode = mode_translations.get(mode, mode)
|
||||||
if not override:
|
if not override:
|
||||||
return vim_modes[mode]
|
return vim_modes[mode]
|
||||||
try:
|
try:
|
||||||
return override[mode]
|
return override[mode]
|
||||||
except IndexError:
|
except KeyError:
|
||||||
return vim_modes[mode]
|
return vim_modes[mode]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user