示例#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."""
     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 = self.prompt_formatter(p)
     except Exception:  # pylint: disable=broad-except
         print_exception()
     self.settitle()
     return p
示例#3
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 = self.prompt_formatter(p)
     except Exception:  # pylint: disable=broad-except
         print_exception()
     self.settitle()
     return p
示例#4
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
示例#5
0
    def prompt(self):
        """Obtains the current prompt string."""

        # clear prompt level cache
        XSH.env["PROMPT_FIELDS"].reset()

        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 = XSH.env  # pylint: disable=no-member
        p = env.get("PROMPT")
        try:
            p = self.prompt_formatter(p)
        except Exception:  # pylint: disable=broad-except
            print_exception()
        self.settitle()
        return p