euporie 2.8.0__py3-none-any.whl → 2.8.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- euporie/console/_commands.py +143 -0
- euporie/console/_settings.py +58 -0
- euporie/console/app.py +25 -71
- euporie/console/tabs/console.py +267 -147
- euporie/core/__init__.py +1 -9
- euporie/core/__main__.py +31 -5
- euporie/core/_settings.py +104 -0
- euporie/core/app/__init__.py +3 -0
- euporie/core/app/_commands.py +70 -0
- euporie/core/app/_settings.py +427 -0
- euporie/core/{app.py → app/app.py} +214 -572
- euporie/core/app/base.py +51 -0
- euporie/core/{current.py → app/current.py} +13 -4
- euporie/core/app/cursor.py +35 -0
- euporie/core/app/dummy.py +12 -0
- euporie/core/app/launch.py +28 -0
- euporie/core/bars/__init__.py +11 -0
- euporie/core/bars/command.py +182 -0
- euporie/core/bars/menu.py +258 -0
- euporie/core/{widgets → bars}/search.py +154 -57
- euporie/core/{widgets → bars}/status.py +9 -26
- euporie/core/clipboard.py +19 -80
- euporie/core/comm/base.py +8 -6
- euporie/core/comm/ipywidgets.py +21 -12
- euporie/core/comm/registry.py +2 -1
- euporie/core/commands.py +11 -5
- euporie/core/completion.py +3 -2
- euporie/core/config.py +368 -341
- euporie/core/convert/__init__.py +0 -30
- euporie/core/convert/datum.py +131 -60
- euporie/core/convert/formats/__init__.py +31 -0
- euporie/core/convert/formats/ansi.py +46 -30
- euporie/core/convert/formats/common.py +11 -23
- euporie/core/convert/formats/html.py +45 -40
- euporie/core/convert/formats/pil.py +1 -1
- euporie/core/convert/formats/png.py +3 -5
- euporie/core/convert/formats/sixel.py +3 -3
- euporie/core/convert/registry.py +11 -8
- euporie/core/convert/utils.py +50 -23
- euporie/core/diagnostics.py +2 -2
- euporie/core/filters.py +72 -82
- euporie/core/format.py +13 -2
- euporie/core/ft/ansi.py +1 -1
- euporie/core/ft/html.py +36 -36
- euporie/core/ft/table.py +1 -3
- euporie/core/ft/utils.py +4 -1
- euporie/core/graphics.py +216 -124
- euporie/core/history.py +2 -2
- euporie/core/inspection.py +3 -2
- euporie/core/io.py +207 -28
- euporie/core/kernel/__init__.py +1 -0
- euporie/core/{kernel.py → kernel/client.py} +100 -139
- euporie/core/kernel/manager.py +114 -0
- euporie/core/key_binding/bindings/__init__.py +2 -8
- euporie/core/key_binding/bindings/basic.py +47 -7
- euporie/core/key_binding/bindings/completion.py +3 -8
- euporie/core/key_binding/bindings/micro.py +5 -7
- euporie/core/key_binding/bindings/mouse.py +26 -24
- euporie/core/key_binding/bindings/terminal.py +193 -0
- euporie/core/key_binding/bindings/vi.py +46 -0
- euporie/core/key_binding/key_processor.py +43 -2
- euporie/core/key_binding/registry.py +2 -0
- euporie/core/key_binding/utils.py +22 -2
- euporie/core/keys.py +7156 -92
- euporie/core/layout/cache.py +35 -25
- euporie/core/layout/containers.py +280 -74
- euporie/core/layout/decor.py +5 -5
- euporie/core/layout/mouse.py +1 -1
- euporie/core/layout/print.py +16 -3
- euporie/core/layout/scroll.py +26 -28
- euporie/core/log.py +75 -60
- euporie/core/lsp.py +118 -24
- euporie/core/margins.py +60 -31
- euporie/core/path.py +2 -1
- euporie/core/renderer.py +58 -17
- euporie/core/style.py +60 -40
- euporie/core/suggest.py +103 -85
- euporie/core/tabs/__init__.py +34 -0
- euporie/core/tabs/_settings.py +113 -0
- euporie/core/tabs/base.py +11 -435
- euporie/core/tabs/kernel.py +420 -0
- euporie/core/tabs/notebook.py +20 -54
- euporie/core/utils.py +98 -6
- euporie/core/validation.py +1 -1
- euporie/core/widgets/_settings.py +188 -0
- euporie/core/widgets/cell.py +90 -158
- euporie/core/widgets/cell_outputs.py +26 -37
- euporie/core/widgets/decor.py +11 -41
- euporie/core/widgets/dialog.py +55 -44
- euporie/core/widgets/display.py +27 -24
- euporie/core/widgets/file_browser.py +5 -26
- euporie/core/widgets/forms.py +16 -12
- euporie/core/widgets/inputs.py +37 -81
- euporie/core/widgets/layout.py +7 -6
- euporie/core/widgets/logo.py +49 -0
- euporie/core/widgets/menu.py +13 -11
- euporie/core/widgets/pager.py +9 -11
- euporie/core/widgets/palette.py +6 -6
- euporie/hub/app.py +52 -31
- euporie/notebook/_commands.py +24 -0
- euporie/notebook/_settings.py +107 -0
- euporie/notebook/app.py +109 -210
- euporie/notebook/filters.py +1 -1
- euporie/notebook/tabs/__init__.py +46 -7
- euporie/notebook/tabs/_commands.py +714 -0
- euporie/notebook/tabs/_settings.py +32 -0
- euporie/notebook/tabs/display.py +2 -2
- euporie/notebook/tabs/edit.py +12 -7
- euporie/notebook/tabs/json.py +3 -3
- euporie/notebook/tabs/log.py +1 -18
- euporie/notebook/tabs/notebook.py +21 -674
- euporie/notebook/widgets/_commands.py +11 -0
- euporie/notebook/widgets/_settings.py +19 -0
- euporie/notebook/widgets/side_bar.py +14 -34
- euporie/preview/_settings.py +104 -0
- euporie/preview/app.py +8 -30
- euporie/preview/tabs/notebook.py +15 -86
- euporie/web/tabs/web.py +4 -6
- euporie/web/widgets/webview.py +5 -12
- {euporie-2.8.0.dist-info → euporie-2.8.5.dist-info}/METADATA +11 -15
- euporie-2.8.5.dist-info/RECORD +172 -0
- {euporie-2.8.0.dist-info → euporie-2.8.5.dist-info}/WHEEL +1 -1
- {euporie-2.8.0.dist-info → euporie-2.8.5.dist-info}/entry_points.txt +2 -2
- {euporie-2.8.0.dist-info → euporie-2.8.5.dist-info}/licenses/LICENSE +1 -1
- euporie/core/launch.py +0 -59
- euporie/core/terminal.py +0 -527
- euporie-2.8.0.dist-info/RECORD +0 -146
- {euporie-2.8.0.data → euporie-2.8.5.data}/data/share/applications/euporie-console.desktop +0 -0
- {euporie-2.8.0.data → euporie-2.8.5.data}/data/share/applications/euporie-notebook.desktop +0 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
"""Define commands for widgets."""
|
2
|
+
|
3
|
+
from euporie.core.commands import add_cmd
|
4
|
+
|
5
|
+
|
6
|
+
@add_cmd()
|
7
|
+
def _toggle_side_bar_pane() -> None:
|
8
|
+
"""Open or close the current side-bar pane."""
|
9
|
+
from euporie.notebook.current import get_app
|
10
|
+
|
11
|
+
get_app().side_bar.toggle_pane()
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"""Define settings for the notebook app widgets."""
|
2
|
+
|
3
|
+
from euporie.core.config import add_setting
|
4
|
+
|
5
|
+
add_setting(
|
6
|
+
name="show_side_bar",
|
7
|
+
group="euporie.notebook.widgets.side_bar",
|
8
|
+
flags=["--show-side-bar"],
|
9
|
+
type_=bool,
|
10
|
+
title="side-bar",
|
11
|
+
help_="Show the side-bar",
|
12
|
+
default=False,
|
13
|
+
schema={
|
14
|
+
"type": "boolean",
|
15
|
+
},
|
16
|
+
description="""
|
17
|
+
Whether the side-bar should be shown at the side of the screen.
|
18
|
+
""",
|
19
|
+
)
|
@@ -16,14 +16,12 @@ from prompt_toolkit.layout.containers import (
|
|
16
16
|
)
|
17
17
|
from prompt_toolkit.layout.controls import FormattedTextControl
|
18
18
|
|
19
|
-
from euporie.core.commands import add_cmd
|
20
|
-
from euporie.core.config import add_setting
|
21
19
|
from euporie.core.key_binding.registry import register_bindings
|
22
20
|
from euporie.core.layout.decor import Line
|
23
21
|
from euporie.core.widgets.forms import ToggleButton, ToggleButtons
|
24
22
|
|
25
23
|
if TYPE_CHECKING:
|
26
|
-
from
|
24
|
+
from collections.abc import Sequence
|
27
25
|
|
28
26
|
from prompt_toolkit.layout.containers import AnyContainer
|
29
27
|
|
@@ -39,13 +37,22 @@ class SideBarButtons(ToggleButtons):
|
|
39
37
|
else:
|
40
38
|
return "class:side_bar,buttons,separator"
|
41
39
|
|
40
|
+
def _get_sep_char(self, i: int) -> str:
|
41
|
+
if self.index in {i, i - 1}:
|
42
|
+
return "▄"
|
43
|
+
return ""
|
44
|
+
|
42
45
|
def load_container(self) -> AnyContainer:
|
43
46
|
"""Load the widget's container."""
|
44
47
|
self.buttons: list[ToggleButton] = []
|
45
48
|
children: list[AnyContainer] = []
|
46
49
|
for i, (label, selected) in enumerate(zip(self.labels, self.mask)):
|
47
50
|
children.append(
|
48
|
-
Window(
|
51
|
+
Window(
|
52
|
+
char=partial(self._get_sep_char, i),
|
53
|
+
height=1,
|
54
|
+
style=partial(self._get_sep_style, i),
|
55
|
+
)
|
49
56
|
)
|
50
57
|
button = ToggleButton(
|
51
58
|
text=label,
|
@@ -60,7 +67,7 @@ class SideBarButtons(ToggleButtons):
|
|
60
67
|
children.extend(
|
61
68
|
[
|
62
69
|
Window(
|
63
|
-
char=
|
70
|
+
char=partial(self._get_sep_char, i),
|
64
71
|
height=1,
|
65
72
|
style=partial(self._get_sep_style, len(self.options)),
|
66
73
|
),
|
@@ -85,7 +92,7 @@ class SideBar:
|
|
85
92
|
panels: Sequence[AnyContainer],
|
86
93
|
) -> None:
|
87
94
|
"""Initialize a new side-bar object."""
|
88
|
-
from euporie.core.current import get_app
|
95
|
+
from euporie.core.app.current import get_app
|
89
96
|
|
90
97
|
self.side_bar_buttons = SideBarButtons(
|
91
98
|
options=list(icons),
|
@@ -158,7 +165,7 @@ class SideBar:
|
|
158
165
|
],
|
159
166
|
style="class:side_bar",
|
160
167
|
),
|
161
|
-
filter=get_app().config.
|
168
|
+
filter=get_app().config.filters.show_side_bar,
|
162
169
|
)
|
163
170
|
|
164
171
|
def toggle_pane(self) -> None:
|
@@ -172,33 +179,6 @@ class SideBar:
|
|
172
179
|
"""Return the side_bar's main container."""
|
173
180
|
return self.container
|
174
181
|
|
175
|
-
# ################################### Settings ####################################
|
176
|
-
|
177
|
-
add_setting(
|
178
|
-
name="show_side_bar",
|
179
|
-
flags=["--show-side-bar"],
|
180
|
-
type_=bool,
|
181
|
-
title="side-bar",
|
182
|
-
help_="Show the side-bar",
|
183
|
-
default=False,
|
184
|
-
schema={
|
185
|
-
"type": "boolean",
|
186
|
-
},
|
187
|
-
description="""
|
188
|
-
Whether the side-bar should be shown at the side of the screen.
|
189
|
-
""",
|
190
|
-
)
|
191
|
-
|
192
|
-
# ################################### Commands ####################################
|
193
|
-
|
194
|
-
@staticmethod
|
195
|
-
@add_cmd()
|
196
|
-
def _toggle_side_bar_pane() -> None:
|
197
|
-
"""Open or close the current side-bar pane."""
|
198
|
-
from euporie.notebook.current import get_app
|
199
|
-
|
200
|
-
get_app().side_bar.toggle_pane()
|
201
|
-
|
202
182
|
# ################################# Key Bindings ##################################
|
203
183
|
|
204
184
|
register_bindings(
|
@@ -0,0 +1,104 @@
|
|
1
|
+
"""Define settings for the preview app."""
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
import logging
|
6
|
+
|
7
|
+
from upath import UPath
|
8
|
+
|
9
|
+
from euporie.core.config import add_setting
|
10
|
+
|
11
|
+
log = logging.getLogger(__name__)
|
12
|
+
|
13
|
+
|
14
|
+
add_setting(
|
15
|
+
name="output_file",
|
16
|
+
group="euporie.preview.app",
|
17
|
+
flags=["--output-file"],
|
18
|
+
nargs="?",
|
19
|
+
default="-",
|
20
|
+
const="-",
|
21
|
+
type_=UPath,
|
22
|
+
help_="Output path when previewing file",
|
23
|
+
description="""
|
24
|
+
When set to a file path, the formatted output will be written to the
|
25
|
+
given path. If no value is given (or the default "-" is passed) output
|
26
|
+
will be printed to standard output.
|
27
|
+
""",
|
28
|
+
)
|
29
|
+
|
30
|
+
add_setting(
|
31
|
+
name="page",
|
32
|
+
group="euporie.preview.app",
|
33
|
+
flags=["--page"],
|
34
|
+
type_=bool,
|
35
|
+
help_="Pass output to pager",
|
36
|
+
default=False,
|
37
|
+
description="""
|
38
|
+
Whether to pipe output to the system pager when previewing a notebook.
|
39
|
+
""",
|
40
|
+
)
|
41
|
+
|
42
|
+
|
43
|
+
add_setting(
|
44
|
+
name="run",
|
45
|
+
group="euporie.preview.app",
|
46
|
+
flags=["--run"],
|
47
|
+
type_=bool,
|
48
|
+
help_="Run the notebook files when loaded",
|
49
|
+
default=False,
|
50
|
+
description="""
|
51
|
+
If set, notebooks will be run automatically when opened, or if previewing a
|
52
|
+
file, the notebooks will be run before being output.
|
53
|
+
""",
|
54
|
+
)
|
55
|
+
|
56
|
+
add_setting(
|
57
|
+
name="save",
|
58
|
+
group="euporie.preview.app",
|
59
|
+
flags=["--save"],
|
60
|
+
type_=bool,
|
61
|
+
help_="Save the notebook after running it",
|
62
|
+
default=False,
|
63
|
+
description="""
|
64
|
+
If set, notebooks will be saved after they have been run. This setting only
|
65
|
+
has any affect if the :option:`run` setting is active.
|
66
|
+
""",
|
67
|
+
)
|
68
|
+
|
69
|
+
add_setting(
|
70
|
+
name="show_filenames",
|
71
|
+
group="euporie.preview.app",
|
72
|
+
flags=["--show-filenames"],
|
73
|
+
type_=bool,
|
74
|
+
help_="Show the notebook filenames when previewing multiple notebooks",
|
75
|
+
default=False,
|
76
|
+
description="""
|
77
|
+
If set, the notebook filenames will be printed above each notebook's output
|
78
|
+
when multiple notebooks are being previewed.
|
79
|
+
""",
|
80
|
+
)
|
81
|
+
|
82
|
+
add_setting(
|
83
|
+
name="cell_start",
|
84
|
+
group="euporie.preview.app",
|
85
|
+
flags=["--cell-start"],
|
86
|
+
type_=int,
|
87
|
+
help_="The first cell to include in the preview",
|
88
|
+
default=None,
|
89
|
+
description="""
|
90
|
+
When set, only cells after the given cell index will be shown.
|
91
|
+
""",
|
92
|
+
)
|
93
|
+
|
94
|
+
add_setting(
|
95
|
+
name="cell_stop",
|
96
|
+
group="euporie.preview.app",
|
97
|
+
flags=["--cell-stop"],
|
98
|
+
type_=int,
|
99
|
+
help_="The last cell to include in the preview",
|
100
|
+
default=None,
|
101
|
+
description="""
|
102
|
+
When set, only cells before the given cell index will be shown.
|
103
|
+
""",
|
104
|
+
)
|
euporie/preview/app.py
CHANGED
@@ -12,10 +12,9 @@ from typing import TYPE_CHECKING, cast
|
|
12
12
|
from prompt_toolkit.layout.containers import DynamicContainer, FloatContainer, Window
|
13
13
|
from prompt_toolkit.output.defaults import create_output
|
14
14
|
from prompt_toolkit.output.vt100 import Vt100_Output
|
15
|
-
from upath import UPath
|
16
15
|
|
17
|
-
from euporie.core.app import BaseApp
|
18
|
-
from euporie.core.
|
16
|
+
from euporie.core.app.app import BaseApp
|
17
|
+
from euporie.core.app.current import get_app
|
19
18
|
from euporie.core.io import PseudoTTY
|
20
19
|
from euporie.core.key_binding.registry import register_bindings
|
21
20
|
from euporie.preview.tabs.notebook import PreviewNotebook
|
@@ -55,6 +54,7 @@ class PreviewApp(BaseApp):
|
|
55
54
|
kwargs.setdefault("max_render_postpone_time", 0)
|
56
55
|
kwargs.setdefault("min_redraw_interval", 0)
|
57
56
|
kwargs.setdefault("extend_renderer_height", True)
|
57
|
+
kwargs.setdefault("enable_page_navigation_bindings", False)
|
58
58
|
# Adjust options if we are paging output
|
59
59
|
if self.config.page:
|
60
60
|
kwargs.setdefault("set_title", False)
|
@@ -126,7 +126,7 @@ class PreviewApp(BaseApp):
|
|
126
126
|
# Use a temporary file as display output if we are going to page the output
|
127
127
|
from tempfile import TemporaryFile
|
128
128
|
|
129
|
-
output_file = TemporaryFile("w+")
|
129
|
+
output_file = TemporaryFile("w+") # noqa: SIM115
|
130
130
|
# Make this file look like a tty so we get colorful output
|
131
131
|
output_file = cast("TextIO", PseudoTTY(output_file, isatty=True))
|
132
132
|
|
@@ -189,33 +189,11 @@ class PreviewApp(BaseApp):
|
|
189
189
|
# time.sleep(0.1)
|
190
190
|
super()._redraw(render_as_done=True)
|
191
191
|
|
192
|
-
|
193
|
-
|
194
|
-
add_setting(
|
195
|
-
name="output_file",
|
196
|
-
flags=["--output-file"],
|
197
|
-
nargs="?",
|
198
|
-
default="-",
|
199
|
-
const="-",
|
200
|
-
type_=UPath,
|
201
|
-
help_="Output path when previewing file",
|
202
|
-
description="""
|
203
|
-
When set to a file path, the formatted output will be written to the
|
204
|
-
given path. If no value is given (or the default "-" is passed) output
|
205
|
-
will be printed to standard output.
|
206
|
-
""",
|
207
|
-
)
|
192
|
+
def _update_invalidate_events(self) -> None:
|
193
|
+
"""Do nothing, as we don't need invalidation events for the preview app."""
|
208
194
|
|
209
|
-
|
210
|
-
|
211
|
-
flags=["--page"],
|
212
|
-
type_=bool,
|
213
|
-
help_="Pass output to pager",
|
214
|
-
default=False,
|
215
|
-
description="""
|
216
|
-
Whether to pipe output to the system pager when previewing a notebook.
|
217
|
-
""",
|
218
|
-
)
|
195
|
+
# def load_key_bindings(self) -> None:
|
196
|
+
# """Do no load any additional key-bindings for the preview app."""
|
219
197
|
|
220
198
|
# ################################# Key Bindings ##################################
|
221
199
|
|
euporie/preview/tabs/notebook.py
CHANGED
@@ -5,14 +5,12 @@ from __future__ import annotations
|
|
5
5
|
import logging
|
6
6
|
from typing import TYPE_CHECKING
|
7
7
|
|
8
|
-
from prompt_toolkit.cache import FastDictCache
|
9
8
|
from prompt_toolkit.layout.containers import (
|
10
9
|
ConditionalContainer,
|
11
10
|
DynamicContainer,
|
12
11
|
)
|
13
12
|
from prompt_toolkit.layout.dimension import Dimension
|
14
13
|
|
15
|
-
from euporie.core.config import add_setting
|
16
14
|
from euporie.core.layout.containers import VSplit, Window
|
17
15
|
from euporie.core.layout.print import PrintingContainer
|
18
16
|
from euporie.core.tabs.notebook import BaseNotebook
|
@@ -27,9 +25,9 @@ if TYPE_CHECKING:
|
|
27
25
|
from prompt_toolkit.formatted_text.base import StyleAndTextTuples
|
28
26
|
from prompt_toolkit.layout.containers import AnyContainer
|
29
27
|
|
30
|
-
from euporie.core.app import BaseApp
|
28
|
+
from euporie.core.app.app import BaseApp
|
31
29
|
from euporie.core.comm.base import Comm
|
32
|
-
from euporie.core.kernel import Kernel
|
30
|
+
from euporie.core.kernel.client import Kernel
|
33
31
|
|
34
32
|
log = logging.getLogger(__name__)
|
35
33
|
|
@@ -37,8 +35,6 @@ log = logging.getLogger(__name__)
|
|
37
35
|
class PreviewNotebook(BaseNotebook):
|
38
36
|
"""A notebook tab which renders cells sequentially."""
|
39
37
|
|
40
|
-
bg_init = False
|
41
|
-
|
42
38
|
def __init__(
|
43
39
|
self,
|
44
40
|
app: BaseApp,
|
@@ -47,15 +43,13 @@ class PreviewNotebook(BaseNotebook):
|
|
47
43
|
) -> None:
|
48
44
|
"""Create a new instance."""
|
49
45
|
self.cell_index = 0
|
50
|
-
self.cells: FastDictCache[tuple[int], Cell] = FastDictCache(
|
51
|
-
get_value=self.get_cell
|
52
|
-
)
|
53
|
-
|
54
46
|
super().__init__(app, path, use_kernel_history=use_kernel_history)
|
55
47
|
|
56
48
|
self.app.before_render += self.before_render
|
57
49
|
self.app.after_render += self.after_render
|
58
50
|
|
51
|
+
self._cell = Cell(0, {}, self)
|
52
|
+
|
59
53
|
def pre_init_kernel(self) -> None:
|
60
54
|
"""Filter cells before kernel is loaded."""
|
61
55
|
super().pre_init_kernel()
|
@@ -135,7 +129,7 @@ class PreviewNotebook(BaseNotebook):
|
|
135
129
|
):
|
136
130
|
self.print_title()
|
137
131
|
|
138
|
-
if not self.json
|
132
|
+
if not self.json.get("cells", []):
|
139
133
|
log.error("No cells")
|
140
134
|
self.app.print_text([("", "(No cells to display)\n")])
|
141
135
|
self.app.close_tab(self)
|
@@ -156,27 +150,24 @@ class PreviewNotebook(BaseNotebook):
|
|
156
150
|
# Trigger a re-draw of the app right away, now with the next cell
|
157
151
|
self.app.invalidate()
|
158
152
|
|
159
|
-
def get_cell(self, index: int) -> Cell:
|
160
|
-
"""Render a cell by its index."""
|
161
|
-
if index < len(self.json["cells"]):
|
162
|
-
return Cell(index, self.json["cells"][index], self)
|
163
|
-
else:
|
164
|
-
return Cell(0, {}, self)
|
165
|
-
|
166
153
|
@property
|
167
154
|
def cell(self) -> Cell:
|
168
|
-
"""
|
169
|
-
|
155
|
+
"""Load the current cell's data into our cell instance."""
|
156
|
+
cell = self._cell
|
157
|
+
cell_json = self.json["cells"][self.cell_index]
|
158
|
+
cell.json = cell_json
|
159
|
+
cell.input = cell_json["source"]
|
160
|
+
cell.output_area.json = cell.output_json
|
161
|
+
return cell
|
170
162
|
|
171
163
|
def load_container(self) -> AnyContainer:
|
172
164
|
"""Load the notebook's main container."""
|
165
|
+
no_expand = ~self.app.config.filters.expand
|
173
166
|
return PrintingContainer(
|
174
167
|
[
|
175
168
|
VSplit(
|
176
169
|
[
|
177
|
-
ConditionalContainer(
|
178
|
-
Window(), filter=~self.app.config.filter("expand")
|
179
|
-
),
|
170
|
+
ConditionalContainer(Window(), filter=no_expand),
|
180
171
|
Box(
|
181
172
|
body=DynamicContainer(lambda: self.cell),
|
182
173
|
padding=0,
|
@@ -184,70 +175,8 @@ class PreviewNotebook(BaseNotebook):
|
|
184
175
|
preferred=self.app.config.max_notebook_width
|
185
176
|
),
|
186
177
|
),
|
187
|
-
ConditionalContainer(
|
188
|
-
Window(), filter=~self.app.config.filter("expand")
|
189
|
-
),
|
178
|
+
ConditionalContainer(Window(), filter=no_expand),
|
190
179
|
]
|
191
180
|
)
|
192
181
|
]
|
193
182
|
)
|
194
|
-
|
195
|
-
# ################################### Settings ####################################
|
196
|
-
|
197
|
-
add_setting(
|
198
|
-
name="run",
|
199
|
-
flags=["--run"],
|
200
|
-
type_=bool,
|
201
|
-
help_="Run the notebook files when loaded",
|
202
|
-
default=False,
|
203
|
-
description="""
|
204
|
-
If set, notebooks will be run automatically when opened, or if previewing a
|
205
|
-
file, the notebooks will be run before being output.
|
206
|
-
""",
|
207
|
-
)
|
208
|
-
|
209
|
-
add_setting(
|
210
|
-
name="save",
|
211
|
-
flags=["--save"],
|
212
|
-
type_=bool,
|
213
|
-
help_="Save the notebook after running it",
|
214
|
-
default=False,
|
215
|
-
description="""
|
216
|
-
If set, notebooks will be saved after they have been run. This setting only
|
217
|
-
has any affect if the :option:`run` setting is active.
|
218
|
-
""",
|
219
|
-
)
|
220
|
-
|
221
|
-
add_setting(
|
222
|
-
name="show_filenames",
|
223
|
-
flags=["--show-filenames"],
|
224
|
-
type_=bool,
|
225
|
-
help_="Show the notebook filenames when previewing multiple notebooks",
|
226
|
-
default=False,
|
227
|
-
description="""
|
228
|
-
If set, the notebook filenames will be printed above each notebook's output
|
229
|
-
when multiple notebooks are being previewed.
|
230
|
-
""",
|
231
|
-
)
|
232
|
-
|
233
|
-
add_setting(
|
234
|
-
name="cell_start",
|
235
|
-
flags=["--cell-start"],
|
236
|
-
type_=int,
|
237
|
-
help_="The first cell to include in the preview",
|
238
|
-
default=None,
|
239
|
-
description="""
|
240
|
-
When set, only cells after the given cell index will be shown.
|
241
|
-
""",
|
242
|
-
)
|
243
|
-
|
244
|
-
add_setting(
|
245
|
-
name="cell_stop",
|
246
|
-
flags=["--cell-stop"],
|
247
|
-
type_=int,
|
248
|
-
help_="The last cell to include in the preview",
|
249
|
-
default=None,
|
250
|
-
description="""
|
251
|
-
When set, only cells before the given cell index will be shown.
|
252
|
-
""",
|
253
|
-
)
|
euporie/web/tabs/web.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
"""Defines a web-view tab."""
|
2
2
|
|
3
|
-
|
4
3
|
from __future__ import annotations
|
5
4
|
|
6
5
|
import logging
|
@@ -11,8 +10,8 @@ from prompt_toolkit.layout.containers import HSplit, VSplit
|
|
11
10
|
from prompt_toolkit.layout.dimension import Dimension
|
12
11
|
from upath import UPath
|
13
12
|
|
13
|
+
from euporie.core.app.current import get_app
|
14
14
|
from euporie.core.convert.mime import get_mime
|
15
|
-
from euporie.core.current import get_app
|
16
15
|
from euporie.core.data_structures import DiBool
|
17
16
|
from euporie.core.layout.decor import FocusedStyle
|
18
17
|
from euporie.core.margins import MarginContainer, ScrollbarMargin
|
@@ -24,12 +23,12 @@ from euporie.web.widgets.webview import WebViewControl
|
|
24
23
|
|
25
24
|
if TYPE_CHECKING:
|
26
25
|
from pathlib import Path
|
27
|
-
from typing import Any, Callable
|
26
|
+
from typing import Any, Callable
|
28
27
|
|
29
28
|
from prompt_toolkit.layout.containers import AnyContainer
|
30
29
|
|
31
|
-
from euporie.core.app import BaseApp
|
32
|
-
from euporie.core.
|
30
|
+
from euporie.core.app.app import BaseApp
|
31
|
+
from euporie.core.bars.status import StatusBarFields
|
33
32
|
|
34
33
|
log = logging.getLogger(__name__)
|
35
34
|
|
@@ -39,7 +38,6 @@ class WebTab(Tab):
|
|
39
38
|
|
40
39
|
name = "Web Viewer"
|
41
40
|
weight = 2
|
42
|
-
mime_types: ClassVar[set[str]] = {"text/html", "text/markdown"}
|
43
41
|
|
44
42
|
def __init__(self, app: BaseApp, path: Path | None) -> None:
|
45
43
|
"""Call when the tab is created."""
|
euporie/web/widgets/webview.py
CHANGED
@@ -17,10 +17,10 @@ from prompt_toolkit.mouse_events import MouseButton, MouseEvent, MouseEventType
|
|
17
17
|
from prompt_toolkit.utils import Event
|
18
18
|
from upath import UPath
|
19
19
|
|
20
|
+
from euporie.core.app.current import get_app
|
20
21
|
from euporie.core.commands import add_cmd
|
21
22
|
from euporie.core.convert.datum import Datum, get_loop
|
22
23
|
from euporie.core.convert.mime import get_format
|
23
|
-
from euporie.core.current import get_app
|
24
24
|
from euporie.core.ft.html import HTML, Node
|
25
25
|
from euporie.core.ft.utils import fragment_list_width, paste
|
26
26
|
from euporie.core.graphics import GraphicProcessor
|
@@ -31,9 +31,10 @@ from euporie.core.key_binding.registry import (
|
|
31
31
|
from euporie.core.path import parse_path
|
32
32
|
|
33
33
|
if TYPE_CHECKING:
|
34
|
+
from collections.abc import Iterable
|
34
35
|
from concurrent.futures._base import Future
|
35
36
|
from pathlib import Path
|
36
|
-
from typing import Any, Callable
|
37
|
+
from typing import Any, Callable
|
37
38
|
|
38
39
|
from prompt_toolkit.formatted_text.base import AnyFormattedText, StyleAndTextTuples
|
39
40
|
from prompt_toolkit.key_binding.key_bindings import (
|
@@ -95,15 +96,13 @@ class WebViewControl(UIControl):
|
|
95
96
|
self.render_thread = Thread(target=self.loop.run_forever, daemon=True)
|
96
97
|
|
97
98
|
self.key_bindings = load_registered_bindings(
|
98
|
-
"euporie.web.widgets.webview.WebViewControl"
|
99
|
+
"euporie.web.widgets.webview.WebViewControl",
|
100
|
+
config=get_app().config,
|
99
101
|
)
|
100
102
|
|
101
103
|
self._dom_cache: FastDictCache[tuple[Path], HTML] = FastDictCache(
|
102
104
|
get_value=self.get_dom, size=100
|
103
105
|
)
|
104
|
-
self._line_cache: FastDictCache[
|
105
|
-
tuple[HTML, int, int], list[StyleAndTextTuples]
|
106
|
-
] = FastDictCache(get_value=self.get_lines, size=100_000)
|
107
106
|
self._content_cache: FastDictCache = FastDictCache(self.get_content, size=1_000)
|
108
107
|
|
109
108
|
self.load_url(url)
|
@@ -173,12 +172,6 @@ class WebViewControl(UIControl):
|
|
173
172
|
return dom.title
|
174
173
|
return ""
|
175
174
|
|
176
|
-
def get_lines(
|
177
|
-
self, dom: HTML, width: int, height: int, assets_loaded: bool = False
|
178
|
-
) -> list[StyleAndTextTuples]:
|
179
|
-
"""Render a HTML page as lines of formatted text."""
|
180
|
-
return list(split_lines(dom.render(width, height)))
|
181
|
-
|
182
175
|
def load_url(self, url: str | Path, **kwargs: Any) -> None:
|
183
176
|
"""Load a new URL."""
|
184
177
|
save_to_history = kwargs.get("save_to_history", True)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: euporie
|
3
|
-
Version: 2.8.
|
3
|
+
Version: 2.8.5
|
4
4
|
Summary: Euporie is a suite of terminal applications for interacting with Jupyter kernels
|
5
5
|
Project-URL: Documentation, https://euporie.readthedocs.io/en/latest
|
6
6
|
Project-URL: Issues, https://github.com/joouha/euporie/issues
|
@@ -13,40 +13,36 @@ Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Environment :: Console
|
14
14
|
Classifier: Framework :: Jupyter
|
15
15
|
Classifier: Programming Language :: Python
|
16
|
-
Classifier: Programming Language :: Python :: 3.8
|
17
16
|
Classifier: Programming Language :: Python :: 3.9
|
18
17
|
Classifier: Programming Language :: Python :: 3.10
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
20
21
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
21
22
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
22
23
|
Classifier: Topic :: Scientific/Engineering
|
23
|
-
Requires-Python: >=3.
|
24
|
-
Requires-Dist: aenum<=3.1.12,~=3.1
|
24
|
+
Requires-Python: >=3.9
|
25
25
|
Requires-Dist: fastjsonschema~=2.15
|
26
26
|
Requires-Dist: flatlatex~=0.15
|
27
27
|
Requires-Dist: fsspec[http]>=2022.12.0
|
28
28
|
Requires-Dist: imagesize~=1.3
|
29
29
|
Requires-Dist: jupyter-client>=7.1
|
30
30
|
Requires-Dist: jupytext>=1.14.0
|
31
|
-
Requires-Dist: linkify-it-py~=
|
32
|
-
Requires-Dist: markdown-it-py~=
|
33
|
-
Requires-Dist: mdit-py-plugins~=0.
|
31
|
+
Requires-Dist: linkify-it-py~=2.0
|
32
|
+
Requires-Dist: markdown-it-py~=3.0
|
33
|
+
Requires-Dist: mdit-py-plugins~=0.4.2
|
34
34
|
Requires-Dist: nbformat~=5.0
|
35
|
-
Requires-Dist: pillow
|
35
|
+
Requires-Dist: pillow>=9.0
|
36
36
|
Requires-Dist: platformdirs~=3.5
|
37
37
|
Requires-Dist: prompt-toolkit~=3.0.36
|
38
38
|
Requires-Dist: pygments~=2.11
|
39
39
|
Requires-Dist: pyperclip~=1.8
|
40
|
-
Requires-Dist: sixelcrop~=0.1.
|
40
|
+
Requires-Dist: sixelcrop~=0.1.9
|
41
41
|
Requires-Dist: timg~=1.1.6
|
42
42
|
Requires-Dist: typing-extensions~=4.5
|
43
43
|
Requires-Dist: universal-pathlib~=0.2.1
|
44
|
-
Provides-Extra: format
|
45
|
-
Requires-Dist: black>=19.3.b0; extra == 'format'
|
46
|
-
Requires-Dist: isort~=5.10.1; extra == 'format'
|
47
|
-
Requires-Dist: ruff~=0.1.0; extra == 'format'
|
48
44
|
Provides-Extra: hub
|
49
|
-
Requires-Dist: asyncssh~=2.
|
45
|
+
Requires-Dist: asyncssh~=2.18; extra == 'hub'
|
50
46
|
Description-Content-Type: text/x-rst
|
51
47
|
|
52
48
|
|logo|
|