mirror of
https://github.com/powerline/powerline.git
synced 2025-07-28 08:14:41 +02:00
Merge pull request #1284 from ZyX-I/update-zpython
Update zpython bindings according to new zpython changes
This commit is contained in:
commit
9dfd40a6a7
@ -101,7 +101,20 @@ class Environment(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
environ = getattr(zsh, 'environ', Environment())
|
if hasattr(getattr(zsh, 'environ', None), '__contains__'):
|
||||||
|
environ = zsh.environ
|
||||||
|
else:
|
||||||
|
environ = Environment()
|
||||||
|
|
||||||
|
|
||||||
|
if hasattr(zsh, 'expand') and zsh.expand('${:-}') == '':
|
||||||
|
zsh_expand = zsh.expand
|
||||||
|
else:
|
||||||
|
def zsh_expand(s):
|
||||||
|
zsh.eval('_POWERLINE_REPLY="' + s + '"')
|
||||||
|
ret = zsh.getvalue('_POWERLINE_REPLY')
|
||||||
|
zsh.setvalue('_POWERLINE_REPLY', None)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
class ZshPowerline(ShellPowerline):
|
class ZshPowerline(ShellPowerline):
|
||||||
@ -135,8 +148,8 @@ class Prompt(object):
|
|||||||
self.theme = theme
|
self.theme = theme
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')
|
parser_state = u(zsh_expand('${(%):-%_}'))
|
||||||
zsh.eval('_POWERLINE_SHORTENED_PATH="${(%):-%~}"')
|
shortened_path = u(zsh_expand('${(%):-%~}'))
|
||||||
try:
|
try:
|
||||||
mode = u(zsh.getvalue('_POWERLINE_MODE'))
|
mode = u(zsh.getvalue('_POWERLINE_MODE'))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
@ -150,13 +163,11 @@ class Prompt(object):
|
|||||||
'environ': environ,
|
'environ': environ,
|
||||||
'client_id': 1,
|
'client_id': 1,
|
||||||
'local_theme': self.theme,
|
'local_theme': self.theme,
|
||||||
'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'),
|
'parser_state': parser_state,
|
||||||
'shortened_path': zsh.getvalue('_POWERLINE_SHORTENED_PATH'),
|
'shortened_path': shortened_path,
|
||||||
'mode': mode,
|
'mode': mode,
|
||||||
'default_mode': default_mode,
|
'default_mode': default_mode,
|
||||||
}
|
}
|
||||||
zsh.setvalue('_POWERLINE_PARSER_STATE', None)
|
|
||||||
zsh.setvalue('_POWERLINE_SHORTENED_PATH', None)
|
|
||||||
try:
|
try:
|
||||||
zle_rprompt_indent = zsh.getvalue('ZLE_RPROMPT_INDENT')
|
zle_rprompt_indent = zsh.getvalue('ZLE_RPROMPT_INDENT')
|
||||||
except IndexError:
|
except IndexError:
|
||||||
@ -194,7 +205,7 @@ def set_prompt(powerline, psvar, side, theme, above=False):
|
|||||||
savedps = None
|
savedps = None
|
||||||
zpyvar = 'ZPYTHON_POWERLINE_' + psvar
|
zpyvar = 'ZPYTHON_POWERLINE_' + psvar
|
||||||
prompt = Prompt(powerline, side, theme, psvar, savedps, above)
|
prompt = Prompt(powerline, side, theme, psvar, savedps, above)
|
||||||
zsh.eval('unset ' + zpyvar)
|
zsh.setvalue(zpyvar, None)
|
||||||
zsh.set_special_string(zpyvar, prompt)
|
zsh.set_special_string(zpyvar, prompt)
|
||||||
zsh.setvalue(psvar, '${' + zpyvar + '}')
|
zsh.setvalue(psvar, '${' + zpyvar + '}')
|
||||||
return ref(prompt)
|
return ref(prompt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user