Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
How to disable temporary the Pythonista word completion feature and syntax checking of a .py file
-
Hi, my question is a little strange. I have a big .py file in a folder of Pythonista and I need to update this file often by adding (by hand) memo, events, etc..I noticed that if I rename the file with .txt extension the editing is faster, because of lack of word completion and other editor features for python files. But with txt file I cant perform the same python wrench actions user finds when editing python files (for example share in home screen).
In order to be faster in editing python files that are not scripts to execute but plain text on which to perform wrench actions, can user temporary disable word completion feature and other features that make py files editing simpler with Pythonista editor but also slower? Maybe with a objc command that I could add to a programmable user key?
Thank you
-
Hi, sorry if I insist, but do you know a better way to solve the problem than creating a py script that opens a txt file?
The txt file can't be shortcut in home screen using Pythonista wrench actions, so a solution could be to create a py script that opens for editing the txt file I use for my memo/events/notes and to create a shortcut for the py script in idevice home screen for fast access. When user opens the py script from home screen, the python interpreter of Pythonista can start and so pythonista_startup can be executed too.
Thanks
-
have you tried just to wrap everything in a triple
quotes, and edit inside the quotes? that way there wont be any autocomplete, and syntax highlighting won't need to work as hard. -
@JonB Hi JonB, yes it's another solution I had not thought about. But I'd prefer to have black and not italics fonts, the text is more readable if black and not italic, in my opinion.
I ask again if you know some strange command in objc that disables or enables the features of the pythonist text editor when the file opened in editor is a py file (as word completion, syntax checking, built-in run key enabled, etc..). If no, no problem, I think will use the solution with python script with home shortcut that opens the txt file.
Thanks again
Regards -
There is a way to disable updates to highlights:
import editor t=editor._get_editor_tab() t.editorView().syntaxHighlighter().highlightingDisabled=True
which prevents new highlighting from happening, though any existing stays until you update a particular range. It will not be permanent though, iirc, because whenever the tab gets reloaded, it loses that setting.
Again, i din't wuite see why txt doesnt do what you want. As far as i see, txt files still get all of the custom wrench items, and you still get the built in "share". the other built in wrench items dont make sense anyway for non-valid python, like analyze, 2to3, etc.
Add to Home, iirc, tried to add a shortcut run, not edit, a given file. is that really the functionality you are missing?
-
by the way, if what you really want is a way to add txt files as hime screen shortcuts, the following would work:
:https://gist.github.com/Uberi/5031803/
you would probably want to change "run" to "edit" in the URL in the template.
-
@JonB Hi, thanks, actually, with Pythonista 3.1, user has not the wrench action "Home Screen" for txt files opened in editor as for py files, so no built-in way to add txt files to idevice home screen (as editable files, not runnable files). My goal is to create shortcut of a txt file in my iphone home screen and when I touch on the icon, iOS opens Pythonista text editor to allow user to edit the txt file.
Thanks also for the link (Uberi ...) but it seems to me not so easy to modify for my purposes.
I thought there were some commands like (for example):
ObjC.DisableWordCompletion ObjC.DisableSyntaxHighlighting ... ObjC.EnableWordCompletion ObjC.EnableSyntaxHighlighting
that, when executed, can disable globally, for all files opened in Pythonista editor and for speed increase, these two features (word completion and syntax high) that are enabled when editing py files and are disabled when editing different types of files.
No problem, thanks anyway for your help.
Regards -
@Matteo Home screen shortcut for editing a script.txt:
I've copied the @omz script from hereThen, I've removed the import workflow and editorial lines
Then I've replaced 3 lines by
shortcut_url = 'pythonista3://your_script.txt' # no ?action=run ===> edit title = 'your_title' icon_url = 'http://omz-software.com/editorial/homescreen_bookmark.png' # only an example
Then run it, that's all folks (you fall in Safari where you have to add a shortcut as usual)
If you want a wrench , you have to parametrize the script and put it in the wrench menu, as usual
You can even put any icon, not only icons proposed by PythonistaHoping I've been clear enough, good luck
-
sorry, my last bit got garbled -- i mean to write that the Add To Home button creates a runnable link, not an "edit" link.
But the gist I linked to lets you create Home Screen links for ANY file, you just have to modify the script to say edit instead of run in the URL. It looks like cvp provided directions.
You probably want to use .md files, since they allow creating headers/chapters that show up in the drop down next to the title, for easy navigation.
-
@cvp Hi cvp, your solution works very well, it is curious that the solution comes from a script for Editorial app, very nice example of compatibility!
Thank you @JonB also for .md suggestion: I played a little with it and it simplifies the navigation in a big file.Pythonista surprises me every day!
Regards