omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. emkay_online

    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.


    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 9
    • Best 0
    • Controversial 0
    • Groups 0

    emkay_online

    @emkay_online

    0
    Reputation
    595
    Profile views
    9
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    emkay_online Unfollow Follow

    Latest posts made by emkay_online

    • RE: How to access VisionKit?

      @cvp Thank you so much for this code. It works a treat and really gives me a solid foundation to build on.

      Also thank you for giving me a good grounding in the objc_util module - it's certainly a complex one, especially for someone with no iOS coding experience.

      Thank you.

      posted in Pythonista
      emkay_online
      emkay_online
    • RE: How to access VisionKit?

      Thank you for your code. I'm as puzzled as you as to why it doesn't work. I added the other methods in case an error or a cancel was being returned, but nothing.

      I'll keep playing and hope I stumble on the answer.

      Thanks again.

      Martin

      posted in Pythonista
      emkay_online
      emkay_online
    • RE: How to access VisionKit?

      You are amazing - thank you. You have saved me so much frustration and guessing.

      Thank you so much,

      Martin

      posted in Pythonista
      emkay_online
      emkay_online
    • How to access VisionKit?

      Hi,

      I'm just dipping my toes into objc_util and have fallen at the first hurdle.

      I want to write a small script that calls VisionKit to scan a document and return the result to Pythonista. API is here: https://developer.apple.com/documentation/visionkit

      I've started with:

      from objc_util import *
      VNDocumentCameraViewController = ObjCClass('VNDocumentCameraViewController')
      
      

      But Pythonista says that the class VNDocumentCameraViewController doesn't exist.

      I'd love some help getting past this (and if anyone could take the example further, that would be amazing).

      Thank you,

      Martin

      posted in Pythonista
      emkay_online
      emkay_online
    • RE: API to highlight search results in editor?

      @JonB That is fantastic. It took a second to realise I needed to open the search bar first, but now it works perfectly.

      Thank you

      ps. Sorry to only just reply, I wasn't getting alerts on your posts

      posted in Pythonista
      emkay_online
      emkay_online
    • RE: API to highlight search results in editor?

      Thanks for the on_main_thread idea - I gave it a go, but the search term didn't change and it just cycled through the old search results.
      I'll keep playing with it.

      posted in Pythonista
      emkay_online
      emkay_online
    • RE: API to highlight search results in editor?

      I've been fiddling around with this, but still have had no luck.

      If I start a search (using the UI) I can navigate around the results using:

      import editor
      t = editor._get_editor_tab()
      v = t.editorView()
      v.selectFirstSearchResult() # moves forward
      v.highlightPrevSearchResult() # moves back
      

      But if I try to set the search term with:

      v.setSearchTerm_("text")
      v.applySearchTerm()
      v.highlightNextSearchResult()
      

      It just moves through the original search term results.

      Any thoughts or ideas would be appreciated.

      Thanks

      posted in Pythonista
      emkay_online
      emkay_online
    • RE: API to highlight search results in editor?

      @enceladus thanks for that. I actually use that API already (for results of a style check, where line granularity is good enough).

      For the word frequency I need to see the individual words in context (just like the native highlighted search results), to assess whether they need replacing.

      Thank you.

      posted in Pythonista
      emkay_online
      emkay_online
    • API to highlight search results in editor?

      I have a python script that finds the most used words in a text file.

      I have a working algorithm for finding the most used words. From this I create a listview of the words and phrases which I can click on.

      I currently have a text view (which shows the markdown file) and use attributed text to highlight the clicked on word.

      However, this reimplements the wheel, that is Pythonista's editor.

      So, I would love to be able to click on the items and highlight the occurrences (case-insensitive) in a Pythonista editor tab (so that I can quickly edit some of the frequently used words with alternatives)

      Does anyone have an example of how to highlight search results in the editor? I've experimented with editorView, but end up in a mess either setting up NSRegularExpression or getting the results to highlight.

      Thanks

      Martin

      posted in Pythonista
      emkay_online
      emkay_online