docs
update yap_kernel lbfgs
This commit is contained in:
@@ -5,23 +5,34 @@ import sys
|
||||
|
||||
from yap_ipython.core.displayhook import DisplayHook
|
||||
|
||||
from prompt_toolkit.layout.utils import token_list_width
|
||||
from prompt_toolkit.formatted_text import fragment_list_width, PygmentsTokens
|
||||
from prompt_toolkit.shortcuts import print_formatted_text
|
||||
|
||||
|
||||
class Prompts(object):
|
||||
def __init__(self, shell):
|
||||
self.shell = shell
|
||||
|
||||
def in_prompt_tokens(self, cli=None):
|
||||
def vi_mode(self):
|
||||
if not hasattr(self.shell.pt_app, 'editing_mode'):
|
||||
return ''
|
||||
if self.shell.pt_app.editing_mode == 'VI':
|
||||
return '['+str(self.shell.pt_app.app.vi_state.input_mode)[3:6]+'] '
|
||||
return ''
|
||||
|
||||
|
||||
def in_prompt_tokens(self):
|
||||
return [
|
||||
(Token.Prompt, self.vi_mode() ),
|
||||
(Token.Prompt, 'In ['),
|
||||
(Token.PromptNum, str(self.shell.execution_count)),
|
||||
(Token.Prompt, ']: '),
|
||||
]
|
||||
|
||||
def _width(self):
|
||||
return token_list_width(self.in_prompt_tokens())
|
||||
return fragment_list_width(self.in_prompt_tokens())
|
||||
|
||||
def continuation_prompt_tokens(self, cli=None, width=None):
|
||||
def continuation_prompt_tokens(self, width=None):
|
||||
if width is None:
|
||||
width = self._width()
|
||||
return [
|
||||
@@ -42,12 +53,12 @@ class Prompts(object):
|
||||
]
|
||||
|
||||
class ClassicPrompts(Prompts):
|
||||
def in_prompt_tokens(self, cli=None):
|
||||
def in_prompt_tokens(self):
|
||||
return [
|
||||
(Token.Prompt, '>>> '),
|
||||
]
|
||||
|
||||
def continuation_prompt_tokens(self, cli=None, width=None):
|
||||
def continuation_prompt_tokens(self, width=None):
|
||||
return [
|
||||
(Token.Prompt, '... ')
|
||||
]
|
||||
@@ -73,7 +84,9 @@ class RichPromptDisplayHook(DisplayHook):
|
||||
# Ask for a newline before multiline output
|
||||
self.prompt_end_newline = False
|
||||
|
||||
if self.shell.pt_cli:
|
||||
self.shell.pt_cli.print_tokens(tokens)
|
||||
if self.shell.pt_app:
|
||||
print_formatted_text(PygmentsTokens(tokens),
|
||||
style=self.shell.pt_app.app.style, end='',
|
||||
)
|
||||
else:
|
||||
sys.stdout.write(prompt_txt)
|
||||
|
||||
Reference in New Issue
Block a user