txl_notebook_editor 0.2.6__tar.gz → 0.2.8__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.
- {txl_notebook_editor-0.2.6 → txl_notebook_editor-0.2.8}/PKG-INFO +1 -1
- txl_notebook_editor-0.2.8/txl_notebook_editor/__init__.py +1 -0
- {txl_notebook_editor-0.2.6 → txl_notebook_editor-0.2.8}/txl_notebook_editor/components.py +44 -13
- txl_notebook_editor-0.2.6/txl_notebook_editor/__init__.py +0 -1
- {txl_notebook_editor-0.2.6 → txl_notebook_editor-0.2.8}/.gitignore +0 -0
- {txl_notebook_editor-0.2.6 → txl_notebook_editor-0.2.8}/LICENSE.txt +0 -0
- {txl_notebook_editor-0.2.6 → txl_notebook_editor-0.2.8}/README.md +0 -0
- {txl_notebook_editor-0.2.6 → txl_notebook_editor-0.2.8}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: txl_notebook_editor
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
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.8"
|
|
@@ -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
|
|
@@ -165,6 +173,13 @@ class NotebookEditor(Editor, VerticalScroll, metaclass=NotebookEditorMeta):
|
|
|
165
173
|
if delete is not None:
|
|
166
174
|
self.cells[idx].remove()
|
|
167
175
|
del self.cells[idx]
|
|
176
|
+
if self.cell_i == len(self.cells):
|
|
177
|
+
self.cell_i -= 1
|
|
178
|
+
self.current_cell.select()
|
|
179
|
+
self.current_cell.focus()
|
|
180
|
+
elif self.cell_i == 0:
|
|
181
|
+
self.current_cell.select()
|
|
182
|
+
self.current_cell.focus()
|
|
168
183
|
insert = d.get("insert")
|
|
169
184
|
if insert is not None:
|
|
170
185
|
for c in insert:
|
|
@@ -198,12 +213,7 @@ class NotebookEditor(Editor, VerticalScroll, metaclass=NotebookEditorMeta):
|
|
|
198
213
|
elif event.key == Keys.Down:
|
|
199
214
|
if not self.edit_mode:
|
|
200
215
|
event.stop()
|
|
201
|
-
|
|
202
|
-
self.current_cell.unselect()
|
|
203
|
-
self.cell_i += 1
|
|
204
|
-
self.current_cell.select()
|
|
205
|
-
self.current_cell.focus()
|
|
206
|
-
self.scroll_to_widget(self.current_cell)
|
|
216
|
+
self.go_down()
|
|
207
217
|
elif event.key == Keys.ControlUp:
|
|
208
218
|
event.stop()
|
|
209
219
|
if self.cell_i > 0:
|
|
@@ -229,6 +239,7 @@ class NotebookEditor(Editor, VerticalScroll, metaclass=NotebookEditorMeta):
|
|
|
229
239
|
asyncio.create_task(do_later())
|
|
230
240
|
elif event.key == Keys.ControlS:
|
|
231
241
|
await self.contents.save(self.path, self.ynb)
|
|
242
|
+
self.main_area.clear_dirty(self)
|
|
232
243
|
event.stop()
|
|
233
244
|
elif event.key == Keys.Return or event.key == Keys.Enter:
|
|
234
245
|
event.stop()
|
|
@@ -263,7 +274,8 @@ class NotebookEditor(Editor, VerticalScroll, metaclass=NotebookEditorMeta):
|
|
|
263
274
|
elif event.character == "x":
|
|
264
275
|
event.stop()
|
|
265
276
|
self.cell_copy = str(self.current_cell.ycell)
|
|
266
|
-
|
|
277
|
+
if len(self.cells) > 1:
|
|
278
|
+
del self.ynb.ycells[self.cell_i]
|
|
267
279
|
elif event.key == Keys.ControlV:
|
|
268
280
|
event.stop()
|
|
269
281
|
if self.cell_copy is not None:
|
|
@@ -305,13 +317,32 @@ class NotebookEditor(Editor, VerticalScroll, metaclass=NotebookEditorMeta):
|
|
|
305
317
|
)
|
|
306
318
|
else:
|
|
307
319
|
await self.kernel.execute(self.current_cell.ycell)
|
|
308
|
-
if self.cell_i
|
|
309
|
-
self.
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
320
|
+
if self.cell_i == len(self.cells) - 1:
|
|
321
|
+
ycell = self.ynb.create_ycell(
|
|
322
|
+
{
|
|
323
|
+
"cell_type": "code",
|
|
324
|
+
"execution_count": None,
|
|
325
|
+
"source": "",
|
|
326
|
+
}
|
|
327
|
+
)
|
|
328
|
+
self.ynb.ycells.append(ycell)
|
|
329
|
+
async def will_go_down():
|
|
330
|
+
while self.cell_i == len(self.cells) - 1:
|
|
331
|
+
await asyncio.sleep(0)
|
|
332
|
+
self.go_down(edit_mode=True)
|
|
333
|
+
asyncio.create_task(will_go_down())
|
|
334
|
+
|
|
335
|
+
def go_down(self, edit_mode: bool = False) -> None:
|
|
336
|
+
if self.cell_i < len(self.cells) - 1:
|
|
337
|
+
self.current_cell.unselect()
|
|
338
|
+
self.cell_i += 1
|
|
339
|
+
self.current_cell.select()
|
|
340
|
+
if edit_mode:
|
|
313
341
|
self.edit_mode = True
|
|
314
|
-
self.
|
|
342
|
+
self.current_cell.source.focus()
|
|
343
|
+
else:
|
|
344
|
+
self.current_cell.focus()
|
|
345
|
+
self.scroll_to_widget(self.current_cell)
|
|
315
346
|
|
|
316
347
|
def on_click(self) -> None:
|
|
317
348
|
for cell_i, cell in enumerate(self.cells):
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.6"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|