I am working on a command line text editor(similar to nano) in python and i have run into an issue regarding file editing. I can read the file, i can print it, but the user has no way of editing the file once the print instructions have been executed. I need a way of reading the text into a buffer so it stays editable to the user so it can be navigated through the arrow keys and so on. I think i need a buffer, but it doesn't seem to help? How should i proceed?
Asked
Active
Viewed 720 times
1
-
Seems like you could use `subprocess.Popen()` to execute a separate command line process (and `wait()` for it to finish). When the process ends and `wait()` return you can the process the updated file as desired. Most OS's come with some sort of basic text editor, so you could pick an appropriate one based on `os.name`. – martineau Aug 19 '18 at 17:34
-
If it is windows you can use [something similar to this answer to open notepad](https://stackoverflow.com/questions/6178154/open-a-text-file-using-notepad-as-a-help-file-in-python/6178200#6178200). If it is another OS you can use those as an example and just change the program being opened. – LinkBerest Aug 19 '18 at 17:37
1 Answers
0
-
1There's also the text input widget named [`curses.textpad`](https://docs.python.org/3/library/curses.html#module-curses.textpad) that provides "elementary text editing". – martineau Aug 19 '18 at 17:47