Forum Archive

Editor observations

Phuket2

@omz, it would be nice if editor.open_file(name) could open in a new tab instead of the active tab when called from the tools menu.

The documentation for this method is a bit misleading for me. When I read it I was under the impression I could not pass a absolute file spec as a param, but I could.

Help text:
editor.open_file(name)
Open the file with the given name in the editor.

name is just a file name of a script in the library, not an absolute path.

The .py extension can be omitted. The file that is currently open in the editor will automatically be saved.

omz

Thanks, that documentation seems to be totally outdated (I think I wrote that before Pythonista even supported creating folders).

Phuket2

@omz , is the editor module written in Python? I have been trying to find in the Standard library folder, but can't see it

omz

No, it's written entirely in (Objective-)C, though it would be possible to replace it with something based on objc_util.

Phuket2

@omz , it's ok. As you mentioned the docs were out of date, was going to look at it and see what new stuff was in there.

omz

There is actually a new thing. editor.open_file() can take two additional (optional) boolean parameters: editor.open_file(file_path[, new_tab, force_reload]). The new_tab parameter should be self-explanatory. force_reload only has an effect when new_tab is False, and the given file is already open in the current tab.

Phuket2

@omz , thanks. They are not named args though. They are positional args. But it works.

omz

Yeah, I tend to be a bit lazy with keyword args in C code, I always forget the correct way to parse them… Positional args are a bit easier for me, though I'm trying to improve support for keyword args in new code, especially for functions that take lots of parameters.

Phuket2

@omz , LOL. Now I understand the ui interface a little bit better. You need a holiday. I know you don't need the virtues of a consistent prototype interface preached to you, however it does make life a hell of a lot easier for the rest of us 😎
Regardless, they are still small things. Like Apple, for the 1 thing that is that not 100% correct, you have done 1,000 correct and better than correct.