euporie 2.8.1__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.
Files changed (129) hide show
  1. euporie/console/_commands.py +143 -0
  2. euporie/console/_settings.py +58 -0
  3. euporie/console/app.py +25 -71
  4. euporie/console/tabs/console.py +267 -147
  5. euporie/core/__init__.py +1 -9
  6. euporie/core/__main__.py +31 -5
  7. euporie/core/_settings.py +104 -0
  8. euporie/core/app/__init__.py +3 -0
  9. euporie/core/app/_commands.py +70 -0
  10. euporie/core/app/_settings.py +427 -0
  11. euporie/core/{app.py → app/app.py} +214 -572
  12. euporie/core/app/base.py +51 -0
  13. euporie/core/{current.py → app/current.py} +13 -4
  14. euporie/core/app/cursor.py +35 -0
  15. euporie/core/app/dummy.py +12 -0
  16. euporie/core/app/launch.py +28 -0
  17. euporie/core/bars/__init__.py +11 -0
  18. euporie/core/bars/command.py +182 -0
  19. euporie/core/bars/menu.py +258 -0
  20. euporie/core/{widgets → bars}/search.py +154 -57
  21. euporie/core/{widgets → bars}/status.py +9 -26
  22. euporie/core/clipboard.py +19 -80
  23. euporie/core/comm/base.py +8 -6
  24. euporie/core/comm/ipywidgets.py +21 -12
  25. euporie/core/comm/registry.py +2 -1
  26. euporie/core/commands.py +11 -5
  27. euporie/core/completion.py +3 -2
  28. euporie/core/config.py +368 -341
  29. euporie/core/convert/__init__.py +0 -30
  30. euporie/core/convert/datum.py +131 -60
  31. euporie/core/convert/formats/__init__.py +31 -0
  32. euporie/core/convert/formats/ansi.py +46 -30
  33. euporie/core/convert/formats/common.py +11 -23
  34. euporie/core/convert/formats/html.py +45 -40
  35. euporie/core/convert/formats/pil.py +1 -1
  36. euporie/core/convert/formats/png.py +3 -5
  37. euporie/core/convert/formats/sixel.py +3 -3
  38. euporie/core/convert/registry.py +11 -8
  39. euporie/core/convert/utils.py +50 -23
  40. euporie/core/diagnostics.py +2 -2
  41. euporie/core/filters.py +72 -82
  42. euporie/core/format.py +13 -2
  43. euporie/core/ft/ansi.py +1 -1
  44. euporie/core/ft/html.py +36 -36
  45. euporie/core/ft/table.py +1 -3
  46. euporie/core/ft/utils.py +4 -1
  47. euporie/core/graphics.py +216 -124
  48. euporie/core/history.py +2 -2
  49. euporie/core/inspection.py +3 -2
  50. euporie/core/io.py +207 -28
  51. euporie/core/kernel/__init__.py +1 -0
  52. euporie/core/{kernel.py → kernel/client.py} +100 -139
  53. euporie/core/kernel/manager.py +114 -0
  54. euporie/core/key_binding/bindings/__init__.py +2 -8
  55. euporie/core/key_binding/bindings/basic.py +47 -7
  56. euporie/core/key_binding/bindings/completion.py +3 -8
  57. euporie/core/key_binding/bindings/micro.py +5 -7
  58. euporie/core/key_binding/bindings/mouse.py +26 -24
  59. euporie/core/key_binding/bindings/terminal.py +193 -0
  60. euporie/core/key_binding/bindings/vi.py +46 -0
  61. euporie/core/key_binding/key_processor.py +43 -2
  62. euporie/core/key_binding/registry.py +2 -0
  63. euporie/core/key_binding/utils.py +22 -2
  64. euporie/core/keys.py +7156 -93
  65. euporie/core/layout/cache.py +35 -25
  66. euporie/core/layout/containers.py +280 -74
  67. euporie/core/layout/decor.py +5 -5
  68. euporie/core/layout/mouse.py +1 -1
  69. euporie/core/layout/print.py +16 -3
  70. euporie/core/layout/scroll.py +26 -28
  71. euporie/core/log.py +75 -60
  72. euporie/core/lsp.py +118 -24
  73. euporie/core/margins.py +60 -31
  74. euporie/core/path.py +2 -1
  75. euporie/core/renderer.py +58 -17
  76. euporie/core/style.py +60 -40
  77. euporie/core/suggest.py +103 -85
  78. euporie/core/tabs/__init__.py +34 -0
  79. euporie/core/tabs/_settings.py +113 -0
  80. euporie/core/tabs/base.py +11 -435
  81. euporie/core/tabs/kernel.py +420 -0
  82. euporie/core/tabs/notebook.py +20 -54
  83. euporie/core/utils.py +98 -6
  84. euporie/core/validation.py +1 -1
  85. euporie/core/widgets/_settings.py +188 -0
  86. euporie/core/widgets/cell.py +90 -158
  87. euporie/core/widgets/cell_outputs.py +25 -36
  88. euporie/core/widgets/decor.py +11 -41
  89. euporie/core/widgets/dialog.py +55 -44
  90. euporie/core/widgets/display.py +27 -24
  91. euporie/core/widgets/file_browser.py +5 -26
  92. euporie/core/widgets/forms.py +16 -12
  93. euporie/core/widgets/inputs.py +37 -81
  94. euporie/core/widgets/layout.py +7 -6
  95. euporie/core/widgets/logo.py +49 -0
  96. euporie/core/widgets/menu.py +13 -11
  97. euporie/core/widgets/pager.py +8 -11
  98. euporie/core/widgets/palette.py +6 -6
  99. euporie/hub/app.py +52 -31
  100. euporie/notebook/_commands.py +24 -0
  101. euporie/notebook/_settings.py +107 -0
  102. euporie/notebook/app.py +109 -210
  103. euporie/notebook/filters.py +1 -1
  104. euporie/notebook/tabs/__init__.py +46 -7
  105. euporie/notebook/tabs/_commands.py +714 -0
  106. euporie/notebook/tabs/_settings.py +32 -0
  107. euporie/notebook/tabs/display.py +2 -2
  108. euporie/notebook/tabs/edit.py +12 -7
  109. euporie/notebook/tabs/json.py +3 -3
  110. euporie/notebook/tabs/log.py +1 -18
  111. euporie/notebook/tabs/notebook.py +21 -674
  112. euporie/notebook/widgets/_commands.py +11 -0
  113. euporie/notebook/widgets/_settings.py +19 -0
  114. euporie/notebook/widgets/side_bar.py +14 -34
  115. euporie/preview/_settings.py +104 -0
  116. euporie/preview/app.py +8 -30
  117. euporie/preview/tabs/notebook.py +15 -86
  118. euporie/web/tabs/web.py +4 -6
  119. euporie/web/widgets/webview.py +5 -12
  120. {euporie-2.8.1.dist-info → euporie-2.8.5.dist-info}/METADATA +11 -15
  121. euporie-2.8.5.dist-info/RECORD +172 -0
  122. {euporie-2.8.1.dist-info → euporie-2.8.5.dist-info}/WHEEL +1 -1
  123. {euporie-2.8.1.dist-info → euporie-2.8.5.dist-info}/entry_points.txt +2 -2
  124. {euporie-2.8.1.dist-info → euporie-2.8.5.dist-info}/licenses/LICENSE +1 -1
  125. euporie/core/launch.py +0 -59
  126. euporie/core/terminal.py +0 -527
  127. euporie-2.8.1.dist-info/RECORD +0 -146
  128. {euporie-2.8.1.data → euporie-2.8.5.data}/data/share/applications/euporie-console.desktop +0 -0
  129. {euporie-2.8.1.data → euporie-2.8.5.data}/data/share/applications/euporie-notebook.desktop +0 -0
euporie/notebook/app.py CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import asyncio
6
5
  import logging
7
6
  from functools import partial
8
7
  from typing import TYPE_CHECKING, cast
@@ -12,17 +11,20 @@ from prompt_toolkit.formatted_text.base import to_formatted_text
12
11
  from prompt_toolkit.layout.containers import (
13
12
  ConditionalContainer,
14
13
  DynamicContainer,
14
+ Float,
15
15
  FloatContainer,
16
16
  WindowAlign,
17
17
  )
18
18
  from prompt_toolkit.layout.controls import FormattedTextControl
19
19
  from prompt_toolkit.layout.dimension import Dimension
20
- from upath import UPath
21
20
 
22
- from euporie.core import __logo__
23
- from euporie.core.app import BaseApp
24
- from euporie.core.commands import add_cmd, get_cmd
25
- from euporie.core.config import add_setting
21
+ from euporie.core.app.app import BaseApp
22
+ from euporie.core.bars.command import CommandBar
23
+ from euporie.core.bars.menu import ToolbarCompletionsMenu
24
+ from euporie.core.bars.search import SearchBar
25
+ from euporie.core.bars.status import StatusBar, StatusContainer
26
+ from euporie.core.commands import get_cmd
27
+ from euporie.core.filters import has_tabs
26
28
  from euporie.core.ft.utils import truncate
27
29
  from euporie.core.key_binding.registry import register_bindings
28
30
  from euporie.core.layout.containers import HSplit, VSplit, Window
@@ -41,26 +43,27 @@ from euporie.core.widgets.dialog import (
41
43
  )
42
44
  from euporie.core.widgets.file_browser import FileBrowser
43
45
  from euporie.core.widgets.layout import TabBarControl, TabBarTab
46
+ from euporie.core.widgets.logo import Logo
44
47
  from euporie.core.widgets.menu import MenuBar, MenuItem
45
48
  from euporie.core.widgets.pager import Pager
46
49
  from euporie.core.widgets.palette import CommandPalette
47
- from euporie.core.widgets.search import SearchBar
48
- from euporie.core.widgets.status import StatusBar, StatusContainer
49
50
  from euporie.notebook.enums import TabMode
50
- from euporie.notebook.tabs import Notebook
51
51
  from euporie.notebook.widgets.side_bar import SideBar
52
52
 
53
53
  if TYPE_CHECKING:
54
54
  from asyncio import AbstractEventLoop
55
- from typing import Any, Callable, Sequence
55
+ from collections.abc import Sequence
56
+ from typing import Any, Callable
56
57
 
57
58
  from prompt_toolkit.application.application import Application
58
59
  from prompt_toolkit.formatted_text import StyleAndTextTuples
59
- from prompt_toolkit.layout.containers import AnyContainer, Float
60
+ from prompt_toolkit.layout.containers import AnyContainer
60
61
 
62
+ from euporie.core.bars.status import StatusBarFields
63
+ from euporie.core.tabs import TabRegistryEntry
61
64
  from euporie.core.tabs.base import Tab
62
65
  from euporie.core.widgets.cell import Cell
63
- from euporie.core.widgets.status import StatusBarFields
66
+ from euporie.notebook.tabs.notebook import Notebook
64
67
 
65
68
  log = logging.getLogger(__name__)
66
69
 
@@ -74,6 +77,8 @@ class NotebookApp(BaseApp):
74
77
  notebooks in the terminal.
75
78
  """
76
79
 
80
+ _tab_container: AnyContainer
81
+
77
82
  name = "notebook"
78
83
 
79
84
  def __init__(self, **kwargs: Any) -> None:
@@ -84,32 +89,35 @@ class NotebookApp(BaseApp):
84
89
  super().__init__(**kwargs)
85
90
  self.bindings_to_load.append("euporie.notebook.app.NotebookApp")
86
91
 
87
- # Register config hooks
88
- self.config.get_item("show_cell_borders").event += lambda x: self.refresh()
92
+ self.on_tabs_change += self.set_tab_container
89
93
 
90
- async def _poll_terminal_colors(self) -> None:
91
- """Repeatedly query the terminal for its background and foreground colours."""
92
- while self.config.terminal_polling_interval:
93
- await asyncio.sleep(self.config.terminal_polling_interval)
94
- self.term_info.colors.send()
94
+ # Register config hooks
95
+ self.config.events.show_cell_borders += lambda x: self.refresh()
96
+ self.config.events.tab_mode += self.set_tab_container
97
+ self.config.events.background_pattern += self.set_tab_container
98
+ self.config.events.background_character += self.set_tab_container
95
99
 
96
100
  def pre_run(self, app: Application | None = None) -> None:
97
101
  """Continue loading the app."""
98
102
  super().pre_run(app)
99
- # Ensure an opened tab is focused
100
- if self.tab:
101
- self.tab.focus()
103
+ # Add a toolbar completion menu
104
+ self.menus["toolbar_completions"] = Float(
105
+ content=ToolbarCompletionsMenu(), ycursor=True, transparent=True
106
+ )
107
+
108
+ @property
109
+ def tab_registry(self) -> list[TabRegistryEntry]:
110
+ """Return the tab registry."""
111
+ from euporie.notebook.tabs import _TAB_REGISTRY
102
112
 
103
- # Load style hooks and start polling terminal style
104
- if self.config.terminal_polling_interval and hasattr(
105
- self.input, "vt100_parser"
106
- ):
107
- self.create_background_task(self._poll_terminal_colors())
113
+ return _TAB_REGISTRY
108
114
 
109
115
  def format_title(self) -> StyleAndTextTuples:
110
116
  """Format the tab's title for display in the top right of the app."""
111
- if self.tab:
112
- title = truncate(to_formatted_text(self.tab.title, style="bold"), 30)
117
+ if self.tabs:
118
+ # Get tab without re-focusing it
119
+ tab = self.tabs[self._tab_idx]
120
+ title = truncate(to_formatted_text(tab.title, style="bold"), 30)
113
121
  return [("", " "), *title, ("", " ")]
114
122
  else:
115
123
  return []
@@ -118,29 +126,58 @@ class NotebookApp(BaseApp):
118
126
  """Return a container with all opened tabs.
119
127
 
120
128
  Returns:
121
- A layout displaying the opened tab containers.
122
-
129
+ A layout container displaying the opened tab containers.
123
130
  """
124
- if self.tabs:
125
- if TabMode(self.config.tab_mode) == TabMode.TILE_HORIZONTALLY:
126
- return HSplit(
127
- children=self.tabs,
128
- padding=1,
129
- padding_style="class:tab-padding",
130
- padding_char="─",
131
- )
132
- elif TabMode(self.config.tab_mode) == TabMode.TILE_VERTICALLY:
133
- return VSplit(
134
- children=self.tabs,
135
- padding=1,
136
- padding_style="class:tab-padding",
137
- padding_char="│",
138
- )
139
- else:
140
- return DynamicContainer(lambda: self.tabs[self._tab_idx])
131
+ try:
132
+ return self._tab_container
133
+ except AttributeError:
134
+ self.set_tab_container()
135
+ return self._tab_container
136
+
137
+ def set_tab_container(self, app: BaseApp | None = None) -> None:
138
+ """Set the container to use to display opened tabs."""
139
+ if not self.tabs:
140
+ self._tab_container = Pattern(
141
+ self.config.background_character,
142
+ self.config.background_pattern,
143
+ )
144
+ elif TabMode(self.config.tab_mode) == TabMode.TILE_HORIZONTALLY:
145
+ self._tab_container = HSplit(
146
+ children=self.tabs,
147
+ padding=1,
148
+ padding_style="class:tab-padding",
149
+ padding_char="─",
150
+ )
151
+ elif TabMode(self.config.tab_mode) == TabMode.TILE_VERTICALLY:
152
+ self._tab_container = VSplit(
153
+ children=self.tabs,
154
+ padding=1,
155
+ padding_style="class:tab-padding",
156
+ padding_char="│",
157
+ )
141
158
  else:
142
- return Pattern(
143
- self.config.background_character, self.config.background_pattern
159
+ self._tab_container = HSplit(
160
+ [
161
+ ConditionalContainer(
162
+ Window(
163
+ TabBarControl(
164
+ tabs=self.tab_bar_tabs,
165
+ active=lambda: self._tab_idx,
166
+ closeable=True,
167
+ ),
168
+ height=2,
169
+ style="class:app-tab-bar",
170
+ dont_extend_height=True,
171
+ ),
172
+ filter=Condition(
173
+ lambda: (
174
+ len(self.tabs) > 1 or self.config.always_show_tab_bar
175
+ )
176
+ and TabMode(self.config.tab_mode) == TabMode.STACK
177
+ ),
178
+ ),
179
+ DynamicContainer(lambda: self.tabs[self._tab_idx]),
180
+ ]
144
181
  )
145
182
 
146
183
  def _statusbar_defaults(self) -> StatusBarFields | None:
@@ -158,22 +195,7 @@ class NotebookApp(BaseApp):
158
195
 
159
196
  def load_container(self) -> FloatContainer:
160
197
  """Build the main application layout."""
161
- have_tabs = Condition(lambda: bool(self.tabs))
162
-
163
- self.logo = StatusContainer(
164
- body=Window(
165
- FormattedTextControl(
166
- [("", f" {__logo__} ")],
167
- focusable=~have_tabs,
168
- show_cursor=False,
169
- style="class:menu,logo",
170
- ),
171
- height=1,
172
- width=3,
173
- dont_extend_width=True,
174
- ),
175
- status=self._statusbar_defaults,
176
- )
198
+ self.logo = StatusContainer(body=Logo(), status=self._statusbar_defaults)
177
199
 
178
200
  title_bar = ConditionalContainer(
179
201
  Window(
@@ -183,29 +205,12 @@ class NotebookApp(BaseApp):
183
205
  dont_extend_width=True,
184
206
  align=WindowAlign.RIGHT,
185
207
  ),
186
- filter=have_tabs,
187
- )
188
-
189
- self.tab_bar_control = TabBarControl(
190
- tabs=self.tab_bar_tabs,
191
- active=lambda: self._tab_idx,
192
- closeable=True,
193
- )
194
- tab_bar = ConditionalContainer(
195
- Window(
196
- self.tab_bar_control,
197
- height=2,
198
- style="class:app-tab-bar",
199
- dont_extend_height=True,
200
- ),
201
- filter=Condition(
202
- lambda: (len(self.tabs) > 1 or self.config.always_show_tab_bar)
203
- and TabMode(self.config.tab_mode) == TabMode.STACK
204
- ),
208
+ filter=has_tabs,
205
209
  )
206
210
 
207
211
  self.pager = Pager()
208
212
  self.search_bar = SearchBar()
213
+ self.command_bar = CommandBar()
209
214
 
210
215
  self.dialogs["command-palette"] = CommandPalette(self)
211
216
  self.dialogs["about"] = AboutDialog(self)
@@ -227,7 +232,7 @@ class NotebookApp(BaseApp):
227
232
  title_bar,
228
233
  ]
229
234
  ),
230
- filter=self.config.filter("show_top_bar"),
235
+ filter=self.config.filters.show_top_bar,
231
236
  )
232
237
 
233
238
  titles: Sequence[str]
@@ -255,7 +260,6 @@ class NotebookApp(BaseApp):
255
260
  self.side_bar,
256
261
  HSplit(
257
262
  [
258
- tab_bar,
259
263
  DynamicContainer(self.tab_container),
260
264
  self.pager,
261
265
  ],
@@ -264,6 +268,7 @@ class NotebookApp(BaseApp):
264
268
  ],
265
269
  height=Dimension(min=1),
266
270
  ),
271
+ self.command_bar,
267
272
  self.search_bar,
268
273
  StatusBar(),
269
274
  ],
@@ -347,6 +352,8 @@ class NotebookApp(BaseApp):
347
352
  @property
348
353
  def notebook(self) -> Notebook | None:
349
354
  """Return the currently active notebook."""
355
+ from euporie.notebook.tabs.notebook import Notebook
356
+
350
357
  if isinstance(self.tab, Notebook):
351
358
  return self.tab
352
359
  return None
@@ -354,6 +361,8 @@ class NotebookApp(BaseApp):
354
361
  @property
355
362
  def cell(self) -> Cell | None:
356
363
  """Return the currently active cell."""
364
+ from euporie.notebook.tabs.notebook import Notebook
365
+
357
366
  if isinstance(self.tab, Notebook):
358
367
  return self.tab.cell
359
368
  return None
@@ -422,7 +431,7 @@ class NotebookApp(BaseApp):
422
431
  "Tab mode",
423
432
  children=[
424
433
  get_cmd(f"set-tab-mode-{choice}").menu
425
- for choice in self.config.get_item("tab_mode").choices
434
+ for choice in self.config.choices.tab_mode
426
435
  ],
427
436
  ),
428
437
  ],
@@ -444,13 +453,21 @@ class NotebookApp(BaseApp):
444
453
  ],
445
454
  description="Turn elements of euporie's interface on or off",
446
455
  ),
447
- self.config.get_item("color_scheme").menu,
448
- self.config.get_item("syntax_theme").menu,
456
+ self.config.menus.color_scheme,
457
+ MenuItem(
458
+ "Syntax highlighting",
459
+ children=[
460
+ self.config.menus.syntax_highlighting,
461
+ separator,
462
+ *self.config.menus.syntax_theme.children,
463
+ ],
464
+ description="Configure syntax highlighting",
465
+ ),
449
466
  get_cmd("toggle-expand").menu,
450
467
  get_cmd("toggle-line-numbers").menu,
451
- self.config.get_item("set_cursor_shape").menu,
468
+ self.config.menus.set_cursor_shape,
452
469
  separator,
453
- self.config.get_item("edit_mode").menu,
470
+ self.config.menus.edit_mode,
454
471
  separator,
455
472
  MenuItem(
456
473
  "Code tools",
@@ -483,124 +500,6 @@ class NotebookApp(BaseApp):
483
500
  ),
484
501
  ]
485
502
 
486
- # ################################### Commands ####################################
487
-
488
- @staticmethod
489
- @add_cmd()
490
- def _new_notebook() -> None:
491
- """Create a new file."""
492
- from euporie.notebook.current import get_app
493
-
494
- app = get_app()
495
- app.tabs.append(Notebook(app, None))
496
- app.tabs[-1].focus()
497
-
498
- @staticmethod
499
- @add_cmd()
500
- def _view_documentation() -> None:
501
- """Open the documentation in a web-view tab."""
502
- from euporie.core.current import get_app
503
-
504
- get_app().open_file(UPath("https://euporie.readthedocs.io/"))
505
-
506
- # ################################### Settings ####################################
507
-
508
- add_setting(
509
- name="tab_mode",
510
- flags=["--tab-mode"],
511
- type_=str,
512
- choices=[mode.value for mode in TabMode],
513
- default="stack",
514
- help_="The method used to display multiple tabs",
515
- description="""
516
- Determines how multiple tabs are displayed when more than one tab is open.
517
- * ``stack`` displays one tab at a time with a tab-bar
518
- * ``tile_horizontally`` displays tabs side-by-side
519
- * ``tile_vertically`` displays tabs one-atop-the-next
520
- """,
521
- )
522
-
523
- add_setting(
524
- name="always_show_tab_bar",
525
- flags=["--always-show-tab-bar"],
526
- type_=bool,
527
- help_="Always show the tab bar",
528
- default=False,
529
- description="""
530
- When set, the tab bar will always be shown - otherwise the tab bar is only
531
- shown when multiple tabs are open.
532
- """,
533
- )
534
-
535
- add_setting(
536
- name="background_pattern",
537
- flags=["--background-pattern", "--bg-pattern"],
538
- type_=int,
539
- choices=list(range(6)),
540
- help_="The background pattern to use",
541
- default=2,
542
- schema={
543
- "minimum": 0,
544
- "maximum": 5,
545
- },
546
- description="""
547
- The background pattern to use when the notebook is narrower than the
548
- available width. Zero mean no pattern is used.
549
- """,
550
- )
551
-
552
- add_setting(
553
- name="background_character",
554
- flags=["--background-character", "--bg-char"],
555
- type_=str,
556
- help_="Character for background pattern",
557
- default="·",
558
- schema={
559
- "maxLength": 1,
560
- },
561
- description="""
562
- The character to use when drawing the background pattern.
563
-
564
- Recommended characters include: "·", "⬤", "╳", "╱", "╲", "░", "▒", "▓", "▞", "╬"
565
- """, # ,
566
- )
567
-
568
- add_setting(
569
- name="run_after_external_edit",
570
- flags=["--run-after-external-edit"],
571
- type_=bool,
572
- help_="Run cells after editing externally",
573
- default=False,
574
- description="""
575
- Whether to execute a cell immediately after editing in `$EDITOR`.
576
- """,
577
- )
578
-
579
- add_setting(
580
- name="run",
581
- flags=["--run"],
582
- type_=bool,
583
- help_="Run the notebook files when loaded",
584
- default=False,
585
- description="""
586
- If set, notebooks will be run automatically when opened, or if previewing a
587
- file, the notebooks will be run before being output.
588
- """,
589
- )
590
-
591
- add_setting(
592
- name="show_top_bar",
593
- flags=["--show-top-bar"],
594
- type_=bool,
595
- title="top bar",
596
- help_="Show the top bar",
597
- default=True,
598
- schema={"type": "boolean"},
599
- description="""
600
- Whether the top bar should be shown at the top of the screen.
601
- """,
602
- )
603
-
604
503
  # ################################# Key Bindings ##################################
605
504
 
606
505
  register_bindings(
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  from prompt_toolkit.filters import Condition
6
6
 
7
- from euporie.core.current import get_app
7
+ from euporie.core.app.current import get_app
8
8
 
9
9
 
10
10
  @Condition
@@ -1,10 +1,49 @@
1
1
  """Tab for use in euporie notebook editor."""
2
2
 
3
- from euporie.notebook.tabs.display import DisplayTab
4
- from euporie.notebook.tabs.edit import EditorTab
5
- from euporie.notebook.tabs.json import JsonTab
6
- from euporie.notebook.tabs.log import LogView
7
- from euporie.notebook.tabs.notebook import Notebook
8
- from euporie.web.tabs.web import WebTab
3
+ from euporie.core.convert.mime import MIME_FORMATS
4
+ from euporie.core.tabs import _TAB_REGISTRY, TabRegistryEntry
9
5
 
10
- __all__ = ["DisplayTab", "EditorTab", "JsonTab", "LogView", "Notebook", "WebTab"]
6
+ _TAB_REGISTRY.extend(
7
+ [
8
+ TabRegistryEntry(
9
+ path="euporie.notebook.tabs.display:DisplayTab",
10
+ name="File Viewer",
11
+ mime_types=set(MIME_FORMATS.keys()),
12
+ ),
13
+ TabRegistryEntry(
14
+ path="euporie.notebook.tabs.edit:EditorTab",
15
+ name="Text Editor",
16
+ mime_types={"text/*"},
17
+ weight=1,
18
+ ),
19
+ TabRegistryEntry(
20
+ path="euporie.notebook.tabs.json:JsonTab",
21
+ name="JSON Viewer",
22
+ mime_types={"*json"},
23
+ file_extensions={".json": None},
24
+ ),
25
+ TabRegistryEntry(
26
+ path="euporie.notebook.tabs.notebook:Notebook",
27
+ name="Notebook Editor",
28
+ mime_types={"application/x-ipynb+json"},
29
+ file_extensions={".ipynb": None},
30
+ weight=3,
31
+ ),
32
+ TabRegistryEntry(
33
+ path="euporie.web.tabs.web:WebTab",
34
+ name="Web Viewer",
35
+ mime_types={"text/html", "text/markdown"},
36
+ weight=2,
37
+ ),
38
+ ]
39
+ )
40
+
41
+ try:
42
+ from jupytext.formats import NOTEBOOK_EXTENSIONS
43
+ except ModuleNotFoundError:
44
+ pass
45
+ else:
46
+ for entry in _TAB_REGISTRY:
47
+ if entry.path == "euporie.notebook.tabs.notebook:Notebook":
48
+ entry.file_extensions.update(dict.fromkeys(NOTEBOOK_EXTENSIONS))
49
+ break