示例#1
0
 def prompt(self):
     """Obtains the current prompt string."""
     global RL_LIB, RL_CAN_RESIZE
     if RL_CAN_RESIZE:
         # This is needed to support some system where line-wrapping doesn't
         # work. This is a bug in upstream Python, or possibly readline.
         RL_LIB.rl_reset_screen_size()
     if self.need_more_lines:
         if self.mlprompt is None:
             try:
                 self.mlprompt = multiline_prompt(curr=self._current_prompt)
             except Exception:  # pylint: disable=broad-except
                 print_exception()
                 self.mlprompt = '<multiline prompt error> '
         return self.mlprompt
     env = builtins.__xonsh_env__  # pylint: disable=no-member
     p = env.get('PROMPT')
     try:
         p = partial_format_prompt(p)
     except Exception:  # pylint: disable=broad-except
         print_exception()
     hide = True if self._force_hide is None else self._force_hide
     p = ansi_partial_color_format(p, style=env.get('XONSH_COLOR_STYLE'),
                                   hide=hide)
     self._current_prompt = p
     self.settitle()
     return p
示例#2
0
 def prompt(self):
     """Obtains the current prompt string."""
     global RL_LIB, RL_CAN_RESIZE
     if RL_CAN_RESIZE:
         # This is needed to support some system where line-wrapping doesn't
         # work. This is a bug in upstream Python, or possibly readline.
         RL_LIB.rl_reset_screen_size()
     #return super().prompt
     if self.need_more_lines:
         if self.mlprompt is None:
             try:
                 self.mlprompt = multiline_prompt(curr=self._current_prompt)
             except Exception:  # pylint: disable=broad-except
                 print_exception()
                 self.mlprompt = '<multiline prompt error> '
         return self.mlprompt
     env = builtins.__xonsh_env__  # pylint: disable=no-member
     p = env.get('PROMPT')
     try:
         p = partial_format_prompt(p)
     except Exception:  # pylint: disable=broad-except
         print_exception()
     p = partial_color_format(p,
                              style=env.get('XONSH_COLOR_STYLE'),
                              hide=True)
     self._current_prompt = p
     self.settitle()
     return p
示例#3
0
 def prompt(self):
     """Obtains the current prompt string."""
     if self.need_more_lines:
         if self.mlprompt is None:
             self.mlprompt = multiline_prompt()
         return self.mlprompt
     env = builtins.__xonsh_env__
     if 'PROMPT' in env:
         p = env['PROMPT']
         p = format_prompt(p)
     else:
         p = "set '$PROMPT = ...' $ "
     self.settitle()
     return p
示例#4
0
 def prompt(self):
     """Obtains the current prompt string."""
     if self.need_more_lines:
         if self.mlprompt is None:
             self.mlprompt = multiline_prompt()
         return self.mlprompt
     env = builtins.__xonsh_env__
     if 'PROMPT' in env:
         p = env['PROMPT']
         p = format_prompt(p)
     else:
         p = "set '$PROMPT = ...' $ "
     self.settitle()
     return p
示例#5
0
 def prompt(self):
     """Obtains the current prompt string."""
     if self.need_more_lines:
         if self.mlprompt is None:
             try:
                 self.mlprompt = multiline_prompt()
             except Exception:  # pylint: disable=broad-except
                 print_exception()
                 self.mlprompt = '<multiline prompt error> '
         return self.mlprompt
     env = builtins.__xonsh_env__  # pylint: disable=no-member
     p = env.get('PROMPT')
     try:
         p = partial_format_prompt(p)
     except Exception:  # pylint: disable=broad-except
         print_exception()
     self.settitle()
     return p
示例#6
0
 def prompt(self):
     """Obtains the current prompt string."""
     if self.need_more_lines:
         if self.mlprompt is None:
             try:
                 self.mlprompt = multiline_prompt()
             except Exception:  # pylint: disable=broad-except
                 print_exception()
                 self.mlprompt = '<multiline prompt error> '
         return self.mlprompt
     env = builtins.__xonsh_env__  # pylint: disable=no-member
     p = env.get('PROMPT')
     try:
         p = partial_format_prompt(p)
     except Exception:  # pylint: disable=broad-except
         print_exception()
     self.settitle()
     return p
示例#7
0
 def prompt(self):
     """Obtains the current prompt string."""
     if self.need_more_lines:
         if self.mlprompt is None:
             try:
                 self.mlprompt = multiline_prompt()
             except Exception:
                 print_exception()
                 self.mlprompt = '<multiline prompt error> '
         return self.mlprompt
     env = builtins.__xonsh_env__
     p = env.get('PROMPT')
     try:
         p = format_prompt(p)
     except Exception:
         print_exception()
     self.settitle()
     return p
示例#8
0
 def prompt(self):
     """Obtains the current prompt string."""
     if self.need_more_lines:
         if self.mlprompt is None:
             try:
                 self.mlprompt = multiline_prompt()
             except Exception:
                 print_exception()
                 self.mlprompt = '<multiline prompt error> '
         return self.mlprompt
     env = builtins.__xonsh_env__
     p = env.get('PROMPT')
     try:
         p = format_prompt(p)
     except Exception:
         print_exception()
     self.settitle()
     return p
示例#9
0
文件: shell.py 项目: aig787/xonsh
 def prompt(self):
     """Obtains the current prompt string."""
     global RL_LIB, RL_CAN_RESIZE
     if RL_CAN_RESIZE:
         # This is needed to support some system where line-wrapping doesn't
         # work. This is a bug in upstream Python, or possibly readline.
         RL_LIB.rl_reset_screen_size()
     if self.need_more_lines:
         if self.mlprompt is None:
             self.mlprompt = multiline_prompt()
         return self.mlprompt
     env = builtins.__xonsh_env__
     if 'PROMPT' in env:
         p = env['PROMPT']
         p = format_prompt(p)
     else:
         p = "set '$PROMPT = ...' $ "
     self.settitle()
     return p
示例#10
0
 def prompt(self):
     """Obtains the current prompt string."""
     if self.need_more_lines:
         if self.mlprompt is None:
             try:
                 self.mlprompt = multiline_prompt()
             except Exception:
                 _print_exception()
                 self.mlprompt = '<multiline prompt error> '
         return self.mlprompt
     env = builtins.__xonsh_env__
     if 'PROMPT' in env:
         p = env['PROMPT']
         try:
             p = format_prompt(p)
         except Exception:
             _print_exception()
     else:
         p = "set '$PROMPT = ...' $ "
     self.settitle()
     return p
示例#11
0
 def prompt(self):
     """Obtains the current prompt string."""
     global RL_LIB, RL_CAN_RESIZE
     if RL_CAN_RESIZE:
         # This is needed to support some system where line-wrapping doesn't
         # work. This is a bug in upstream Python, or possibly readline.
         RL_LIB.rl_reset_screen_size()
     if self.need_more_lines:
         if self.mlprompt is None:
             self.mlprompt = multiline_prompt()
         return self.mlprompt
     env = builtins.__xonsh_env__
     if 'PROMPT' in env:
         p = env['PROMPT']
         if callable(p):
             p = p()
         p = format_prompt(p)
     else:
         p = "set '$PROMPT = ...' $ "
     self.settitle()
     return p
示例#12
0
 def prompt(self):
     """Obtains the current prompt string."""
     if self.need_more_lines:
         if self.mlprompt is None:
             try:
                 self.mlprompt = multiline_prompt()
             except Exception:
                 _print_exception()
                 self.mlprompt = '<multiline prompt error> '
         return self.mlprompt
     env = builtins.__xonsh_env__
     if 'PROMPT' in env:
         p = env['PROMPT']
         try:
             p = format_prompt(p)
         except Exception:
             _print_exception()
     else:
         p = "set '$PROMPT = ...' $ "
     self.settitle()
     return p