view method integrated into ed module
This commit is contained in:
@@ -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!')
|
||||
|
||||
Reference in New Issue
Block a user