view method integrated into ed module

This commit is contained in:
Luxferre
2025-12-21 15:04:06 +02:00
parent 35fbce85c9
commit 6f01d3752b
+10 -1
View File
@@ -1,9 +1,10 @@
# A simple line-oriented text editor for MicroPython/CircuitPython # A simple line-oriented text editor for MicroPython/CircuitPython
# implementing the POSIX 'ed' subset # implementing the POSIX 'ed' subset
# Usage: from app.ed import edit, unlock_rootfs, lock_rootfs # Usage: from app.ed import edit, view, unlock_rootfs, lock_rootfs
# Created by Luxferre in 2025, released into public domain # Created by Luxferre in 2025, released into public domain
from deck.input import input from deck.input import input
from deck.pager import print_paged
MCU_STORAGE = False MCU_STORAGE = False
try: try:
@@ -214,3 +215,11 @@ def lock_rootfs():
def edit(fname): def edit(fname):
editor = Ed(fname) editor = Ed(fname)
editor.run() editor.run()
def view(fname):
try:
with open(fname, 'r') as f:
text = f.read()
print_paged(text)
except:
print('Error opening the input file!')