implemented app.ed.edbuf and app.blog.bloged

This commit is contained in:
Luxferre
2025-12-26 08:44:37 +02:00
parent e2ff2aaa47
commit 4718bd1844
4 changed files with 15 additions and 4 deletions
+4 -2
View File
@@ -218,6 +218,7 @@ A simple line-oriented text editor and page-oriented text viewer for MicroPython
Exports the following functions:
- `edit(filename)`: start an `ed`-like text editor (see below)
- `edbuf()`: create an empty buffer, run the editor interface on it and return the result as a string (without creating any files)
- `view(filename, lno=False)`: start a `more`-like pager for viewing a text file (pass an additional parameter to view it with line numbers)
The editor mode supports the following subset of POSIX ed commands in the standard `[range][command][param]` syntax:
@@ -261,8 +262,9 @@ Requires the following environment variables to be configured (for T-Deck, use t
Exports the following functions:
- `blogpost()`: wait for a (multiline) input and send the post,
- `blogpost_str(content)`: post the content in a non-interactive manner.
- `blogpost()`: wait for a (multiline) input and send the post
- `bloged()`: same as `blogpost()` but with a full-featured `app.ed` interface
- `blogpost_str(content)`: post the content in a non-interactive manner
## FAQ
+4
View File
@@ -36,3 +36,7 @@ def blogpost(content=None):
content = input_multi('> ')
print('Sending the post...')
return blogpost_str(content)
def bloged():
from app.ed import edbuf
return blogpost(edbuf())
+5
View File
@@ -201,6 +201,11 @@ def edit(fname):
editor = Ed(fname)
editor.run()
def edbuf():
editor = Ed()
editor.run()
return '\n'.join(editor.buffer)
def view(fname, lno=False):
try:
with open(fname, 'r') as f:
+2 -2
View File
@@ -12,8 +12,8 @@ from deck.hwinfo import board_id, battery_v, cpu_f, REAL_HW
from deck.http import wget, wput, http_fetch, http_set_ua
from deck.http import auth_header, url_escape, form_encode
from deck import xlat
from app.ed import edit, view
from app.blog import blogpost, blogpost_str
from app.ed import edit, view, edbuf
from app.blog import blogpost, blogpost_str, bloged
try:
from deck import net
requests = net.init_requests()