Forum Archive

Search text in your scripts via help of popup menu

cvp

Little (not quick but still dirty) script to be executed once by Pythonista restart (fi in your pythonista_startup.py).

When you tap help in the popup menu of a selected text

After some seconds (function of your iDevice, the number and size of your scripts), you get a list of scripts containing the selected text (case insensitive)

If you select a script, you'll get, like for Pythonista help, a small (webview) window displaying the script as an html with Python syntax highlighting, where occurrences of selected text are also highlighted (in yellow)

If you search has also results in Pythonista help, you'll see both results in the list

The script imports @jonB's swizzle module

You can find this script here

mikael

@cvp, wow! Now we know what you have been doing.

Sort of acts like a help as well, right?

stephen

@cvp

OUTSTANDING!

i have been missing the abilitynto lookup my own code like this from my pc IDE's i used to use for .net Thanks!

cvp

@mikael said:

Sort of acts like a help as well, right?

Yes and no.

It is used like an help but it does not give any help, it is only a way to scan your sources to find a text. Not sure this code would be used so. Perhaps it could be easier to have the search as a Pythonista tool. But, I've had some fun at least 😀

stephen

garenteed EVERYDAY use from this guy lol

stephen

@cvp got a NameError when searching a local method variable by accedent
screen shot

EDIT:

Well after another app restart itbstarted working again. not sure what happened .

cvp

@stephen yes, bug....

def setSearchResults_(_self,_sel,_search_results):
    from objc_util import ObjCInstance, ns 

Import * not allowed... ns forgotten
Import in def needed because script executed once but defs can be called later and import of module no more in memory

GitHub corrected

stephen

@cvp awesome ty! this module has already helped alot

cvp

@stephen Thanks but I'd not be astonished if you meet other bug(sss) 😢

stephen

@cvp heads up sems like GitHub update did not take

Eh bugs happen. tells you it is doing somthing 😉

cvp

A best idea would be to add a new menu option in the popup menu for searching in sources, without doing that in the help menu.
But I don't know how to do that.
Perhaps @jonB who already did that in the past but also said that it was only for one edited tab.

cvp

@stephen said:

GitHub update did not take

Strange, line 63 contains ,ns now

stephen

@cvp appollagize 😅 looked at wrong line. been a day..

mieq

@cvp Interesting! Thanks for sharing!

crazyfox

@cvp. Helpful! Thank you.