euporie 2.8.4__py3-none-any.whl → 2.8.6__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 (131) 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 +58 -62
  5. euporie/core/__init__.py +1 -1
  6. euporie/core/__main__.py +28 -11
  7. euporie/core/_settings.py +109 -0
  8. euporie/core/app/__init__.py +3 -0
  9. euporie/core/app/_commands.py +95 -0
  10. euporie/core/app/_settings.py +457 -0
  11. euporie/core/{app.py → app/app.py} +212 -576
  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 +205 -0
  19. euporie/core/bars/menu.py +258 -0
  20. euporie/core/{widgets → bars}/search.py +20 -16
  21. euporie/core/{widgets → bars}/status.py +6 -23
  22. euporie/core/clipboard.py +19 -80
  23. euporie/core/comm/base.py +8 -6
  24. euporie/core/comm/ipywidgets.py +16 -7
  25. euporie/core/comm/registry.py +2 -1
  26. euporie/core/commands.py +10 -20
  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 +116 -53
  31. euporie/core/convert/formats/__init__.py +31 -0
  32. euporie/core/convert/formats/ansi.py +9 -23
  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 +4 -6
  39. euporie/core/convert/utils.py +41 -4
  40. euporie/core/diagnostics.py +2 -2
  41. euporie/core/filters.py +98 -40
  42. euporie/core/format.py +2 -3
  43. euporie/core/ft/ansi.py +1 -1
  44. euporie/core/ft/html.py +12 -21
  45. euporie/core/ft/table.py +1 -3
  46. euporie/core/ft/utils.py +4 -1
  47. euporie/core/graphics.py +386 -133
  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} +45 -108
  53. euporie/core/kernel/manager.py +114 -0
  54. euporie/core/key_binding/bindings/__init__.py +1 -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 +1 -6
  58. euporie/core/key_binding/bindings/mouse.py +2 -2
  59. euporie/core/key_binding/bindings/terminal.py +193 -0
  60. euporie/core/key_binding/key_processor.py +43 -2
  61. euporie/core/key_binding/registry.py +2 -0
  62. euporie/core/key_binding/utils.py +22 -2
  63. euporie/core/keys.py +7156 -93
  64. euporie/core/layout/cache.py +3 -3
  65. euporie/core/layout/containers.py +48 -4
  66. euporie/core/layout/decor.py +2 -2
  67. euporie/core/layout/mouse.py +1 -1
  68. euporie/core/layout/print.py +2 -1
  69. euporie/core/layout/scroll.py +39 -34
  70. euporie/core/log.py +76 -64
  71. euporie/core/lsp.py +118 -24
  72. euporie/core/margins.py +1 -1
  73. euporie/core/path.py +62 -13
  74. euporie/core/renderer.py +58 -17
  75. euporie/core/style.py +57 -39
  76. euporie/core/suggest.py +103 -85
  77. euporie/core/tabs/__init__.py +32 -0
  78. euporie/core/tabs/_settings.py +113 -0
  79. euporie/core/tabs/base.py +80 -470
  80. euporie/core/tabs/kernel.py +419 -0
  81. euporie/core/tabs/notebook.py +24 -101
  82. euporie/core/utils.py +92 -15
  83. euporie/core/validation.py +1 -1
  84. euporie/core/widgets/_settings.py +188 -0
  85. euporie/core/widgets/cell.py +19 -50
  86. euporie/core/widgets/cell_outputs.py +25 -36
  87. euporie/core/widgets/decor.py +11 -41
  88. euporie/core/widgets/dialog.py +62 -27
  89. euporie/core/widgets/display.py +12 -15
  90. euporie/core/widgets/file_browser.py +2 -23
  91. euporie/core/widgets/forms.py +8 -5
  92. euporie/core/widgets/inputs.py +13 -70
  93. euporie/core/widgets/layout.py +2 -1
  94. euporie/core/widgets/logo.py +49 -0
  95. euporie/core/widgets/menu.py +10 -8
  96. euporie/core/widgets/pager.py +6 -10
  97. euporie/core/widgets/palette.py +6 -6
  98. euporie/hub/app.py +52 -35
  99. euporie/notebook/_commands.py +24 -0
  100. euporie/notebook/_settings.py +107 -0
  101. euporie/notebook/app.py +49 -171
  102. euporie/notebook/filters.py +1 -1
  103. euporie/notebook/tabs/__init__.py +46 -7
  104. euporie/notebook/tabs/_commands.py +714 -0
  105. euporie/notebook/tabs/_settings.py +32 -0
  106. euporie/notebook/tabs/display.py +4 -4
  107. euporie/notebook/tabs/edit.py +11 -44
  108. euporie/notebook/tabs/json.py +5 -5
  109. euporie/notebook/tabs/log.py +1 -18
  110. euporie/notebook/tabs/notebook.py +11 -660
  111. euporie/notebook/widgets/_commands.py +11 -0
  112. euporie/notebook/widgets/_settings.py +19 -0
  113. euporie/notebook/widgets/side_bar.py +14 -34
  114. euporie/preview/_settings.py +104 -0
  115. euporie/preview/app.py +6 -31
  116. euporie/preview/tabs/notebook.py +6 -72
  117. euporie/web/__init__.py +1 -0
  118. euporie/web/tabs/__init__.py +14 -0
  119. euporie/web/tabs/web.py +11 -6
  120. euporie/web/widgets/__init__.py +1 -0
  121. euporie/web/widgets/webview.py +5 -15
  122. {euporie-2.8.4.dist-info → euporie-2.8.6.dist-info}/METADATA +10 -8
  123. euporie-2.8.6.dist-info/RECORD +175 -0
  124. {euporie-2.8.4.dist-info → euporie-2.8.6.dist-info}/WHEEL +1 -1
  125. {euporie-2.8.4.dist-info → euporie-2.8.6.dist-info}/entry_points.txt +2 -2
  126. {euporie-2.8.4.dist-info → euporie-2.8.6.dist-info}/licenses/LICENSE +1 -1
  127. euporie/core/launch.py +0 -64
  128. euporie/core/terminal.py +0 -522
  129. euporie-2.8.4.dist-info/RECORD +0 -147
  130. {euporie-2.8.4.data → euporie-2.8.6.data}/data/share/applications/euporie-console.desktop +0 -0
  131. {euporie-2.8.4.data → euporie-2.8.6.data}/data/share/applications/euporie-notebook.desktop +0 -0
@@ -0,0 +1,32 @@
1
+ """Define settings for the notebook app tabs."""
2
+
3
+ from euporie.core.config import add_setting
4
+
5
+ add_setting(
6
+ name="show_scroll_bar",
7
+ group="euporie.notebook.tabs.notebook",
8
+ title="scroll bar",
9
+ flags=["--show-scroll-bar"],
10
+ type_=bool,
11
+ help_="Show the scroll bar",
12
+ default=True,
13
+ description="""
14
+ Whether the scroll bar should be shown on the right of the screen.
15
+ """,
16
+ )
17
+
18
+ add_setting(
19
+ name="show_side_bar",
20
+ group="euporie.notebook.widgets.side_bar",
21
+ flags=["--show-side-bar"],
22
+ type_=bool,
23
+ title="side-bar",
24
+ help_="Show the side-bar",
25
+ default=False,
26
+ schema={
27
+ "type": "boolean",
28
+ },
29
+ description="""
30
+ Whether the side-bar should be shown at the side of the screen.
31
+ """,
32
+ )
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import asyncio
5
6
  import logging
6
7
  from typing import TYPE_CHECKING, ClassVar
7
8
 
@@ -12,7 +13,6 @@ from euporie.core.convert.datum import Datum
12
13
  from euporie.core.convert.mime import MIME_FORMATS, get_format
13
14
  from euporie.core.margins import MarginContainer, ScrollbarMargin
14
15
  from euporie.core.tabs.base import Tab
15
- from euporie.core.utils import run_in_thread_with_context
16
16
  from euporie.core.widgets.display import Display
17
17
 
18
18
  if TYPE_CHECKING:
@@ -20,8 +20,8 @@ if TYPE_CHECKING:
20
20
 
21
21
  from prompt_toolkit.layout.containers import AnyContainer
22
22
 
23
- from euporie.core.app import BaseApp
24
- from euporie.core.widgets.status import StatusBarFields
23
+ from euporie.core.app.app import BaseApp
24
+ from euporie.core.bars.status import StatusBarFields
25
25
 
26
26
  log = logging.getLogger(__name__)
27
27
 
@@ -44,7 +44,7 @@ class DisplayTab(Tab):
44
44
  self.app.layout.focus(self.container)
45
45
  self.app.invalidate()
46
46
 
47
- run_in_thread_with_context(_load)
47
+ app.create_background_task(asyncio.to_thread(_load))
48
48
 
49
49
  def __pt_status__(self) -> StatusBarFields | None:
50
50
  """Return a list of statusbar field values shown then this tab is active."""
@@ -9,11 +9,11 @@ from prompt_toolkit.layout.containers import HSplit
9
9
  from prompt_toolkit.layout.dimension import Dimension
10
10
 
11
11
  from euporie.core.filters import insert_mode, replace_mode
12
- from euporie.core.kernel import Kernel, MsgCallbacks
12
+ from euporie.core.kernel.client import Kernel, MsgCallbacks
13
13
  from euporie.core.key_binding.registry import load_registered_bindings
14
14
  from euporie.core.lexers import detect_lexer
15
15
  from euporie.core.path import UntitledPath
16
- from euporie.core.tabs.base import KernelTab
16
+ from euporie.core.tabs.kernel import KernelTab
17
17
  from euporie.core.widgets.inputs import KernelInput
18
18
 
19
19
  if TYPE_CHECKING:
@@ -22,9 +22,9 @@ if TYPE_CHECKING:
22
22
 
23
23
  from prompt_toolkit.layout.containers import AnyContainer
24
24
 
25
- from euporie.core.app import BaseApp
25
+ from euporie.core.app.app import BaseApp
26
+ from euporie.core.bars.status import StatusBarFields
26
27
  from euporie.core.comm.base import Comm
27
- from euporie.core.widgets.status import StatusBarFields
28
28
 
29
29
  log = logging.getLogger(__name__)
30
30
 
@@ -154,44 +154,11 @@ class EditorTab(KernelTab):
154
154
  ),
155
155
  )
156
156
 
157
- def save(self, path: Path | None = None, cb: Callable | None = None) -> None:
158
- """Save the current file."""
159
- if path is not None:
160
- self.path = path
157
+ def write_file(self, path: Path) -> None:
158
+ """Write the file's text data to a path.
161
159
 
162
- if isinstance(self.path, UntitledPath):
163
- if dialog := self.app.dialogs.get("save-as"):
164
- dialog.show(tab=self, cb=cb)
165
- else:
166
- log.debug("Saving file...")
167
- self.saving = True
168
- self.app.invalidate()
169
-
170
- # Save to a temp file, then replace the original
171
- temp_path = self.path.parent / f".{self.path.stem}.tmp{self.path.suffix}"
172
- log.debug("Using temporary file %s", temp_path.name)
173
- try:
174
- open_file = temp_path.open("w")
175
- except NotImplementedError:
176
- if dialog := self.app.dialogs.get("save-as"):
177
- dialog.show(tab=self, cb=cb)
178
- else:
179
- try:
180
- open_file.write(self.input_box.buffer.text)
181
- except Exception:
182
- if dialog := self.app.dialogs.get("save-as"):
183
- dialog.show(tab=self, cb=cb)
184
- else:
185
- try:
186
- temp_path.rename(self.path)
187
- except Exception:
188
- if dialog := self.app.dialogs.get("save-as"):
189
- dialog.show(tab=self, cb=cb)
190
- else:
191
- self.dirty = False
192
- self.saving = False
193
- self.app.invalidate()
194
- log.debug("File saved")
195
- # Run the callback
196
- if callable(cb):
197
- cb()
160
+ Args:
161
+ path: An path at which to save the file
162
+
163
+ """
164
+ path.write_text(self.input_box.buffer.text)
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import asyncio
5
6
  import json
6
7
  import logging
7
8
  from typing import TYPE_CHECKING, ClassVar
@@ -10,7 +11,6 @@ from prompt_toolkit.layout.containers import VSplit
10
11
  from prompt_toolkit.layout.dimension import Dimension
11
12
 
12
13
  from euporie.core.tabs.base import Tab
13
- from euporie.core.utils import run_in_thread_with_context
14
14
  from euporie.core.widgets.tree import JsonView
15
15
 
16
16
  if TYPE_CHECKING:
@@ -18,8 +18,8 @@ if TYPE_CHECKING:
18
18
 
19
19
  from prompt_toolkit.layout.containers import AnyContainer
20
20
 
21
- from euporie.core.app import BaseApp
22
- from euporie.core.widgets.status import StatusBarFields
21
+ from euporie.core.app.app import BaseApp
22
+ from euporie.core.bars.status import StatusBarFields
23
23
 
24
24
  log = logging.getLogger(__name__)
25
25
 
@@ -29,7 +29,7 @@ class JsonTab(Tab):
29
29
 
30
30
  name = "JSON Viewer"
31
31
  mime_types: ClassVar[set[str]] = {"*json"}
32
- filte_types: ClassVar[set[str]] = {".json"}
32
+ file_types: ClassVar[dict[str, None]] = {".json": None}
33
33
 
34
34
  def __init__(self, app: BaseApp, path: Path | None = None) -> None:
35
35
  """Call when the tab is created."""
@@ -43,7 +43,7 @@ class JsonTab(Tab):
43
43
  self.app.layout.focus(self.container)
44
44
  self.app.invalidate()
45
45
 
46
- run_in_thread_with_context(_load)
46
+ app.create_background_task(asyncio.to_thread(_load))
47
47
 
48
48
  def __pt_status__(self) -> StatusBarFields | None:
49
49
  """Return a list of statusbar field values shown then this tab is active."""
@@ -9,8 +9,6 @@ from prompt_toolkit.layout.containers import HSplit, VSplit
9
9
  from prompt_toolkit.layout.dimension import Dimension
10
10
  from prompt_toolkit.widgets import SearchToolbar
11
11
 
12
- from euporie.core.commands import add_cmd
13
- from euporie.core.current import get_app
14
12
  from euporie.core.log import LOG_QUEUE, QueueHandler
15
13
  from euporie.core.margins import MarginContainer, ScrollbarMargin
16
14
  from euporie.core.path import parse_path
@@ -23,7 +21,7 @@ if TYPE_CHECKING:
23
21
 
24
22
  from prompt_toolkit.formatted_text.base import FormattedText
25
23
 
26
- from euporie.core.app import BaseApp
24
+ from euporie.core.app.app import BaseApp
27
25
 
28
26
 
29
27
  class LogView(Tab):
@@ -93,18 +91,3 @@ class LogView(Tab):
93
91
  """Remove log queue handler hook on close."""
94
92
  QueueHandler.unhook(self.hook_id)
95
93
  super().close(cb=cb)
96
-
97
- # ################################### Commands ####################################
98
-
99
- @staticmethod
100
- @add_cmd()
101
- def _view_logs() -> None:
102
- """Open the logs in a new tab."""
103
- app = get_app()
104
- for tab in app.tabs:
105
- if isinstance(tab, LogView):
106
- break
107
- else:
108
- tab = LogView(app)
109
- app.add_tab(tab)
110
- tab.focus()