only interacts with .txt files for simplicity
This commit is contained in:
@@ -7,7 +7,7 @@ When using a file in CircuitPython, it needs to be renamed to "code.py" as this
|
|||||||
A mostly functional, but incredibly basic text editor.
|
A mostly functional, but incredibly basic text editor.
|
||||||
### Features
|
### Features
|
||||||
- Cursor-less text editing (remember how Minecraft book writing used to feel like? Yeah. That.)
|
- Cursor-less text editing (remember how Minecraft book writing used to feel like? Yeah. That.)
|
||||||
- Save file - You have to type in the filename and extension yourself. The good news is the "." key works on this screen.
|
- Save file - You only have to type the filename; the ".txt" extension will be automatically added.
|
||||||
- Open file - You can select from a list of files in the SD card. Still no line scrolling here, so only the first 7 files will be visible
|
- Open file - You can select from a list of files in the SD card. Still no line scrolling here, so only the first 7 files will be visible
|
||||||
- If you open a file, the save menu conveniently fills in the filename for you, so you don't have to write it again to re-save.
|
- If you open a file, the save menu conveniently fills in the filename for you, so you don't have to write it again to re-save.
|
||||||
### Dependencies
|
### Dependencies
|
||||||
@@ -15,5 +15,5 @@ A mostly functional, but incredibly basic text editor.
|
|||||||
- adafruit_display_text from the bundle
|
- adafruit_display_text from the bundle
|
||||||
### Issues
|
### Issues
|
||||||
- No line scrolling. Once you exceed 7 lines, you're guessing, bud
|
- No line scrolling. Once you exceed 7 lines, you're guessing, bud
|
||||||
- No folder support. Selecting folders in the SD card folder will break it.
|
- No folder support. It will only show text (.txt) files in the root /sd folder.
|
||||||
- There are no confirmation or warning messages. Use with caution and be sure that you aren't using a repeat filename, or it will overwrite the file without warning.
|
- There are no confirmation or warning messages. Use with caution and be sure that you aren't using a repeat filename, or it will overwrite the file without warning.
|
||||||
@@ -30,6 +30,7 @@ def file_menu():
|
|||||||
index = 0
|
index = 0
|
||||||
for file in os.listdir("/sd"):
|
for file in os.listdir("/sd"):
|
||||||
filename = str(file)
|
filename = str(file)
|
||||||
|
if ".txt" in filename:
|
||||||
if index == open_cursor:
|
if index == open_cursor:
|
||||||
filename = "> " + filename
|
filename = "> " + filename
|
||||||
files_text = files_text + filename+"\n"
|
files_text = files_text + filename+"\n"
|
||||||
@@ -151,11 +152,8 @@ while True:
|
|||||||
|
|
||||||
## The save file menu - for typing the filename
|
## The save file menu - for typing the filename
|
||||||
elif page == "save":
|
elif page == "save":
|
||||||
if key == "DOWN":
|
if key == "\n":
|
||||||
filename_text = filename_text + "."
|
with open("/sd/"+filename_text+".txt", "w") as f:
|
||||||
filename_group.text = filename_text
|
|
||||||
elif key == "\n":
|
|
||||||
with open("/sd/"+filename_text, "w") as f:
|
|
||||||
f.write(text)
|
f.write(text)
|
||||||
f.close()
|
f.close()
|
||||||
board.DISPLAY.root_group = intro_text_area
|
board.DISPLAY.root_group = intro_text_area
|
||||||
@@ -188,7 +186,7 @@ while True:
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
text = text + line
|
text = text + line
|
||||||
text_area.text = text
|
text_area.text = text
|
||||||
filename_text = fn
|
filename_text = fn.split(".txt")[0]
|
||||||
filename_group.text=filename_text
|
filename_group.text=filename_text
|
||||||
page = "editor"
|
page = "editor"
|
||||||
board.DISPLAY.root_group = intro_text_area
|
board.DISPLAY.root_group = intro_text_area
|
||||||
|
|||||||
Reference in New Issue
Block a user