From 6f01d3752bcc12c9a950e63f74a846d6d3b31b91 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Sun, 21 Dec 2025 15:04:06 +0200 Subject: [PATCH] view method integrated into ed module --- app/ed.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/ed.py b/app/ed.py index 002f7c7..de1fbe5 100644 --- a/app/ed.py +++ b/app/ed.py @@ -1,9 +1,10 @@ # A simple line-oriented text editor for MicroPython/CircuitPython # 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 from deck.input import input +from deck.pager import print_paged MCU_STORAGE = False try: @@ -214,3 +215,11 @@ def lock_rootfs(): def edit(fname): editor = Ed(fname) 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!')