##// END OF EJS Templates
Add line numbers to default prompt.
Chris Hamill -
Show More
@@ -753,7 +753,7 b' class TerminalInteractiveShell(InteractiveShell):'
753 "message": get_message,
753 "message": get_message,
754 "prompt_continuation": (
754 "prompt_continuation": (
755 lambda width, lineno, is_soft_wrap: PygmentsTokens(
755 lambda width, lineno, is_soft_wrap: PygmentsTokens(
756 self.prompts.continuation_prompt_tokens(width)
756 self.prompts.continuation_prompt_tokens(width, lineno=lineno)
757 )
757 )
758 ),
758 ),
759 "multiline": True,
759 "multiline": True,
@@ -28,8 +28,9 b' class Prompts(object):'
28
28
29 def in_prompt_tokens(self):
29 def in_prompt_tokens(self):
30 return [
30 return [
31 (Token.Prompt, self.vi_mode() ),
31 (Token.Prompt, self.vi_mode()),
32 (Token.Prompt, 'In ['),
32 (Token.Prompt, "1 | "),
33 (Token.Prompt, "In ["),
33 (Token.PromptNum, str(self.shell.execution_count)),
34 (Token.PromptNum, str(self.shell.execution_count)),
34 (Token.Prompt, ']: '),
35 (Token.Prompt, ']: '),
35 ]
36 ]
@@ -37,11 +38,15 b' class Prompts(object):'
37 def _width(self):
38 def _width(self):
38 return fragment_list_width(self.in_prompt_tokens())
39 return fragment_list_width(self.in_prompt_tokens())
39
40
40 def continuation_prompt_tokens(self, width=None):
41 def continuation_prompt_tokens(self, width=None, *, lineno=None):
41 if width is None:
42 if width is None:
42 width = self._width()
43 width = self._width()
44 prefix = " " * len(self.vi_mode()) + str(lineno + 1) + " | "
43 return [
45 return [
44 (Token.Prompt, (' ' * (width - 5)) + '...: '),
46 (
47 Token.Prompt,
48 prefix + (" " * (width - len(prefix) - 5)) + "...: ",
49 ),
45 ]
50 ]
46
51
47 def rewrite_prompt_tokens(self):
52 def rewrite_prompt_tokens(self):
General Comments 0
You need to be logged in to leave comments. Login now