1

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?

jwodder
  • 54,758
  • 12
  • 108
  • 124
vladvlad23
  • 55
  • 6
  • 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 Answers1

0

You might find the curses module useful.

wizzwizz4
  • 6,140
  • 2
  • 26
  • 62
  • 1
    There'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