Linux style commands, ANSI terminal control, and a fledgling text editor #9919
Replies: 2 comments 2 replies
-
Neat! You might be duplicating some effort from robert-hh/Micropython-Editor: Small on-board editor for PyBoard, WiPy, ESP8266, ESP32, RP2040, W60x, XBEE 3, Sipeed K210, as well as PyCom and Adafruit devices written in Python, though. (ah, connecting to the Vax cluster via an Atari ST terminal from an engineering lab, hoping that I could download my Archie ftp queue before my 512 KB — yes, kilobytes — disk quota kicked in for the day ... It was all a bit crap back then, wasn't it?) |
Beta Was this translation helpful? Give feedback.
-
Also perhaps duplicating official upysh a shell offering Linux-style commands. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
REPL Buddy
"Let me kick it like it's 1986 now." -- Portugal the Man
Do you ever get nostalgic for the old days? When 64K was a lot of RAM, home computers booted to a BASIC prompt on a green screen, and logging onto the VAX cluster meant a trek across campus to the Engineering building?
Just me? No?
If not, I've been working on something called REPL Buddy you might like.
There's a few parts to it:
command.py
Now you can do shell-like things:
cat()
,ls()
,grep()
, etc., albeit with function parameters rather than command-line arguments. Fifteen functions modeled after popular Linux shell commands.ansi.py
Now you have control over cursor position, text color, inverse and underline. You can also read keypresses such as arrow keys, home, end, page up/down, F1 .. F4, CTRL+key combinations, etc. All from MicroPython.
femto.py
Now you have a woefully incomplete, still in development, totally not ready for prime time, shamefully undocumented text editor in the style of GNU Nano (or University of Washington's Pico) implemented as a Python class.
But be warned, you can't actually edit anything at the moment, just read, write, and page through text files. I did mention it's still in development, didn't I?
How to Install It
You can install REPL Buddy with mip. The package includes command.py and ansi.py. You'll have to get femto.py separately since it's still incomplete.
Windows
Linux
How to Use It
After importing, command.py functions can be used any time at the REPL prompt. Available functions are listed in the project README
For ansi.py, you'll need an ANSI terminal emulator. PuTTY works well on Windows. Not sure about Linux, but if you find something that works, let me know. The ANSI class is not well documented at the moment, other than code comments. But, if you've programmed with ncurses before, you'll probably catch on.
Parting Thoughts
This whole thing is a bit outside the usual 'read a sensor; publish to mqtt; repeat' kind of MicroPython, but it's been an entertaining way to learn. I'm sharing because in this great big world, there might be someone else interested in this same kind of retro geekery. It really does take me back to my first computer and late night CompSci homework on VT100 terminals. And even though MicroPython is lightyears ahead of BASIC and Pascal, the same constraits of limited resources make all of this an interesting challenge.
Check it out and let me know what you think!
Beta Was this translation helpful? Give feedback.
All reactions