txl_notebook_editor 0.2.5__tar.gz → 0.2.7__tar.gz

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.
@@ -2,6 +2,3 @@ __pycache__
2
2
 
3
3
  # pixi environments
4
4
  .pixi
5
- # pixi environments
6
- .pixi
7
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: txl_notebook_editor
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: TXL plugin for a notebook editor
5
5
  Project-URL: Source, https://github.com/davidbrochart/jpterm/plugins/notebook_editor
6
6
  Author-email: David Brochart <david.brochart@gmail.com>
@@ -0,0 +1 @@
1
+ __version__ = "0.2.7"
@@ -1,10 +1,10 @@
1
1
  import asyncio
2
2
  import json
3
3
  from functools import partial
4
+ from importlib.metadata import entry_points
4
5
  from typing import Any
5
6
 
6
7
  import anyio
7
- import pkg_resources
8
8
  from asphalt.core import Component, Context
9
9
  from httpx import AsyncClient
10
10
  from textual.containers import VerticalScroll
@@ -24,7 +24,7 @@ from txl.base import (
24
24
  MainArea,
25
25
  )
26
26
 
27
- ydocs = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyter_ydoc")}
27
+ ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")}
28
28
 
29
29
 
30
30
  class NotebookEditorMeta(type(Editor), type(VerticalScroll)):
@@ -152,7 +152,15 @@ class NotebookEditor(Editor, VerticalScroll, metaclass=NotebookEditorMeta):
152
152
  kernel_name = kernelspec.get("name")
153
153
  if kernel_name:
154
154
  self.kernel = self.kernels(kernel_name)
155
+ elif target == "state":
156
+ if "dirty" in events.keys:
157
+ dirty = events.keys["dirty"]["newValue"]
158
+ if dirty:
159
+ self.main_area.set_dirty(self)
160
+ else:
161
+ self.main_area.clear_dirty(self)
155
162
  elif target == "cells":
163
+ self.main_area.set_dirty(self)
156
164
  for event in events:
157
165
  if event.path:
158
166
  continue
@@ -229,6 +237,7 @@ class NotebookEditor(Editor, VerticalScroll, metaclass=NotebookEditorMeta):
229
237
  asyncio.create_task(do_later())
230
238
  elif event.key == Keys.ControlS:
231
239
  await self.contents.save(self.path, self.ynb)
240
+ self.main_area.clear_dirty(self)
232
241
  event.stop()
233
242
  elif event.key == Keys.Return or event.key == Keys.Enter:
234
243
  event.stop()
@@ -1 +0,0 @@
1
- __version__ = "0.2.5"