##// END OF EJS Templates
attempt fix
Matthias Bussonnier -
Show More
@@ -588,6 +588,17 b' class TerminalInteractiveShell(InteractiveShell):'
588 588 help="Display the current vi mode (when using vi editing mode)."
589 589 ).tag(config=True)
590 590
591 prompt_line_number_format = Unicode(
592 "",
593 help="The format for line numbering, will be passed `line` (int, 1 based)"
594 " the current line number and `rel_line` the relative line number."
595 " for example to display both you can use the following template string :"
596 " c.TerminalInteractiveShell.prompt_line_number_format='{line: 4d}/{rel_line:+03d} | '"
597 " This will display the current line number, with leading space and a width of at least 4"
598 " character, as well as the relative line number 0 padded and always with a + or - sign."
599 " Note that when using Emacs mode the prompt of the first line may not update.",
600 ).tag(config=True)
601
591 602 @observe('term_title')
592 603 def init_term_title(self, change=None):
593 604 # Enable or disable the terminal title.
@@ -25,11 +25,20 b' class Prompts(object):'
25 25 return '['+mode+'] '
26 26 return ''
27 27
28 def current_line(self) -> int:
29 if self.shell.pt_app is not None:
30 return self.shell.pt_app.default_buffer.document.cursor_position_row or 0
31 return 0
28 32
29 33 def in_prompt_tokens(self):
30 34 return [
31 35 (Token.Prompt, self.vi_mode()),
32 (Token.Prompt, "1 | "),
36 (
37 Token.Prompt,
38 self.shell.prompt_line_number_format.format(
39 line=1, rel_line=-self.current_line()
40 ),
41 ),
33 42 (Token.Prompt, "In ["),
34 43 (Token.PromptNum, str(self.shell.execution_count)),
35 44 (Token.Prompt, ']: '),
@@ -41,7 +50,12 b' class Prompts(object):'
41 50 def continuation_prompt_tokens(self, width=None, *, lineno=None):
42 51 if width is None:
43 52 width = self._width()
44 prefix = " " * len(self.vi_mode()) + str(lineno + 1) + " | "
53 line = lineno + 1 if lineno is not None else 0
54 prefix = " " * len(
55 self.vi_mode()
56 ) + self.shell.prompt_line_number_format.format(
57 line=line, rel_line=line - self.current_line() - 1
58 )
45 59 return [
46 60 (
47 61 Token.Prompt,
General Comments 0
You need to be logged in to leave comments. Login now