Exemple #1
0
	def __str__(self):
		zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')
		zsh.eval('_POWERLINE_SHORTENED_PATH="${(%):-%~}"')
		segment_info = {
			'args': self.args,
			'environ': environ,
			'client_id': 1,
			'local_theme': self.theme,
			'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'),
			'shortened_path': zsh.getvalue('_POWERLINE_SHORTENED_PATH'),
		}
		zsh.setvalue('_POWERLINE_PARSER_STATE', None)
		zsh.setvalue('_POWERLINE_SHORTENED_PATH', None)
		try:
			zle_rprompt_indent = zsh.getvalue('ZLE_RPROMPT_INDENT')
		except IndexError:
			zle_rprompt_indent = 1
		r = ''
		if self.above:
			for line in self.powerline.render_above_lines(
				width=zsh.columns() - zle_rprompt_indent,
				segment_info=segment_info,
			):
				r += line + '\n'
		r += self.powerline.render(
			width=zsh.columns(),
			side=self.side,
			segment_info=segment_info,
		)
		if type(r) is not str:
			if type(r) is bytes:
				return r.decode(get_preferred_output_encoding(), 'replace')
			else:
				return r.encode(get_preferred_output_encoding(), 'replace')
		return r
Exemple #2
0
	def __str__(self):
		zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')
		segment_info = {
			'args': self.args,
			'environ': environ,
			'client_id': 1,
			'local_theme': self.theme,
			'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'),
			'shortened_path': zsh.getvalue('_POWERLINE_SHORTENED_PATH'),
		}
		r = ''
		if self.above:
			for line in self.powerline.render_above_lines(
				width=zsh.columns() - 1,
				segment_info=segment_info,
			):
				r += line + '\n'
		r += self.powerline.render(
			width=zsh.columns(),
			side=self.side,
			segment_info=segment_info,
		)
		if type(r) is not str:
			if type(r) is bytes:
				return r.decode('utf-8')
			else:
				return r.encode('utf-8')
		return r
Exemple #3
0
 def __str__(self):
     zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')
     segment_info = {
         'args': self.args,
         'environ': environ,
         'client_id': 1,
         'local_theme': self.theme,
         'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'),
         'shortened_path': zsh.getvalue('_POWERLINE_SHORTENED_PATH'),
     }
     r = ''
     if self.above:
         for line in self.powerline.render_above_lines(
                 width=zsh.columns() - 1,
                 segment_info=segment_info,
         ):
             r += line + '\n'
     r += self.powerline.render(
         width=zsh.columns(),
         side=self.side,
         segment_info=segment_info,
     )
     if type(r) is not str:
         if type(r) is bytes:
             return r.decode('utf-8')
         else:
             return r.encode('utf-8')
     return r
Exemple #4
0
def history(pl):
    import zsh
    zsh.eval('_POWERLINE_REPLY=$(print -P "%!")')
    history_num = zsh.getvalue('_POWERLINE_REPLY')
    zsh.setvalue('_POWERLINE_REPLY', None)
    ret = [ { 'contents': history_num } ]
    return ret
Exemple #5
0
 def __str__(self):
     zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')
     zsh.eval('_POWERLINE_SHORTENED_PATH="${(%):-%~}"')
     segment_info = {
         'args': self.args,
         'environ': environ,
         'client_id': 1,
         'local_theme': self.theme,
         'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'),
         'shortened_path': zsh.getvalue('_POWERLINE_SHORTENED_PATH'),
     }
     zsh.setvalue('_POWERLINE_PARSER_STATE', None)
     zsh.setvalue('_POWERLINE_SHORTENED_PATH', None)
     try:
         zle_rprompt_indent = zsh.getvalue('ZLE_RPROMPT_INDENT')
     except IndexError:
         zle_rprompt_indent = 1
     r = ''
     if self.above:
         for line in self.powerline.render_above_lines(
                 width=zsh.columns() - zle_rprompt_indent,
                 segment_info=segment_info,
         ):
             r += line + '\n'
     r += self.powerline.render(
         width=zsh.columns(),
         side=self.side,
         segment_info=segment_info,
     )
     if type(r) is not str:
         if type(r) is bytes:
             return r.decode(get_preferred_output_encoding(), 'replace')
         else:
             return r.encode(get_preferred_output_encoding(), 'replace')
     return r
Exemple #6
0
def set_prompt(powerline, psvar, side, theme, above=False):
	try:
		savedps = zsh.getvalue(psvar)
	except IndexError:
		savedps = None
	zpyvar = 'ZPYTHON_POWERLINE_' + psvar
	prompt = Prompt(powerline, side, theme, psvar, savedps, above)
	zsh.eval('unset ' + zpyvar)
	zsh.set_special_string(zpyvar, prompt)
	zsh.setvalue(psvar, '${' + zpyvar + '}')
	return ref(prompt)
Exemple #7
0
def set_prompt(powerline, psvar, side, theme, above=False):
    try:
        savedps = zsh.getvalue(psvar)
    except IndexError:
        savedps = None
    zpyvar = 'ZPYTHON_POWERLINE_' + psvar
    prompt = Prompt(powerline, side, theme, psvar, savedps, above)
    zsh.eval('unset ' + zpyvar)
    zsh.set_special_string(zpyvar, prompt)
    zsh.setvalue(psvar, '${' + zpyvar + '}')
    return ref(prompt)
Exemple #8
0
	def __str__(self):
		zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')
		segment_info = {
			'args': self.args,
			'environ': environ,
			'client_id': 1,
			'local_theme': self.theme,
			'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'),
		}
		r = self.powerline.render(
			width=zsh.columns(),
			side=self.side,
			segment_info=segment_info,
		)
		if type(r) is not str:
			if type(r) is bytes:
				return r.decode('utf-8')
			else:
				return r.encode('utf-8')
		return r
Exemple #9
0
	def jobnum(self):
		zsh.eval('integer _POWERLINE_JOBNUM=${(%):-%j}')
		return zsh.getvalue('_POWERLINE_JOBNUM')
Exemple #10
0
 def zsh_expand(s):
     zsh.eval('_POWERLINE_REPLY="' + s + '"')
     ret = zsh.getvalue('_POWERLINE_REPLY')
     zsh.setvalue('_POWERLINE_REPLY', None)
     return ret
Exemple #11
0
	def zsh_expand(s):
		zsh.eval('_POWERLINE_REPLY="' + s + '"')
		ret = zsh.getvalue('_POWERLINE_REPLY')
		zsh.setvalue('_POWERLINE_REPLY', None)
		return ret
Exemple #12
0
	def jobnum(self):
		zsh.eval('integer POWERLINE_JOBNUM=${(%):-%j}')
		return zsh.getvalue('POWERLINE_JOBNUM')
Exemple #13
0
	def precmd(self):
		self.args.last_pipe_status = zsh.pipestatus()
		self.args.last_exit_code = zsh.last_exit_code()
		zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')
Exemple #14
0
 def precmd(self):
     self.args.last_pipe_status = zsh.pipestatus()
     self.args.last_exit_code = zsh.last_exit_code()
     zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')