omz:forum

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

    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

    nfmusician

    @nfmusician

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

    nfmusician Unfollow Follow

    Latest posts made by nfmusician

    • RE: Crash when disabling scroll before calling ObjC Syntax Highlighter

      @JonB I was not aware of the built-in syntax highlighter and so built my own from scratch, basically following a train of thought from these two threads and using objc_util : https://forum.omz-software.com/topic/2727/ui-textview-individual-words and https://forum.omz-software.com/topic/2014/beta-tinkering-with-pythonista-s-internals-using-objc_util/15. I checked the Pythonista site and a Google search for "OMTextView" and "OMSyntaxHighlighter" but can find nothing except passing references. Is this documented, or is this just something under the hood I'll have to investigate?

      My custom syntax is indeed expressible as nested RegEx, which is essentially how I've implemented it myself (https://github.com/nbeversl/pythonista-crash-min-example/blob/master/syntax.py).

      As a result of creating the "minimal example" for this thread, I discovered -- entirely by accident --that this crash is eliminated if the ObjCInstance of the ui.TextView is instantiated before any subviews are added to the main view (the parent of the ui.TextView, which is a ui.View). After that, calling add_subview() through the (non-Objective-C) ui module API on the main view works -- and the disabling/re-enabling of the scrolling described above also works.

      I'm happy for the moment with any solution that gets my main project working, but at the same time I'm curious what I may not be understanding here -- is there something about an ObjCInstance of a view that interacts poorly with non-ObjCinstance sibling views, or is interfered with by changes to the parent view?

      posted in Pythonista
      nfmusician
      nfmusician
    • Crash when disabling scroll before calling ObjC Syntax Highlighter

      I've got a project that involves highlighting a custom syntax I've created. The highlighting happens on textview_did_change() in the delegate of a ui.TextView() that is a subview of the main view, which is a ui.View().

      When editing more than one screenful of text, the rewrite of the NSMutableAttributedString to the TextView moves the cursor to the end of the file briefly and, depending on view position, can cause the view to scroll away from the editing point. To mitigate this, I've attempted to disable scrolling before the call to the syntax highlighter, and re-enable it afterwards. I also save the cursor position and restore it. I'm not sure I've gone about all of this in the cleanest possible way, but it works.

      The problem is that it crashes if a second subview is added to the main view using add_subview(). I discovered this is the trigger only by commenting out code until I isolated it. I get no ObjectiveC exception log in the folder to give me a clue to what is going wrong.

      I've posted a minimal example at https://github.com/nbeversl/pythonista-crash-min-example. syntax.py is the code for the highlighting that I'm using in the project. main.py is a minimal example that reproduces the problem.

      The example works as is. To see the crash, uncomment line 84 and then try typing text into the textview.

      Adding subviews works fine (no crashes) if the scrolling behavior is not changed before and after the update.

      Is there another way to prevent the scrolling/cursor positioning issues when calling the highlighting, or if not, what is the interaction between that and the secondary subview that causes the crash and how to fix?

      The main project has about 8 subviews ; adding any one of them causes this crash.

      posted in Pythonista
      nfmusician
      nfmusician
    • Triggering code on Pythonista focus lost

      I've got an app using a TextView for editing plaintext files that has a save button. In the case that focus is lost from the Pythonista app as a whole (not just the TextView itself) while the file is unsaved, is there a way to catch this and trigger an automatic save before the app sleeps?

      posted in Pythonista
      nfmusician
      nfmusician
    • RE: TextField loses focus

      You can call textfield.end_editing(). See http://omz-software.com/pythonista/docs/ios/ui.html#textview

      posted in Pythonista
      nfmusician
      nfmusician
    • RE: UI TextView Individual Words

      @JonB I have written a custom markup language for plaintext/prose writing, similar in function to Markdown, but much different syntax. So I am looking for a way to use both autocorrect and customized syntax highlighting.

      posted in Pythonista
      nfmusician
      nfmusician
    • RE: UI TextView Individual Words

      @JonB, I have followed your suggestion and tried WebView() for on-the-fly syntax highlighting using a <textarea> and a JavaScript editor like Ace or CodeMirror. The problem is that if you want to edit in place (as @AtomBombed describes), these libraries intercept the keyboard input on iOS, disabling autocorrect, which is a dealbreaker if you are writing prose/plaintext/Markdown/etc. I have not found a way around this. Are you aware of one, and/or has another solution emerged in the four years since this thread was opened?

      posted in Pythonista
      nfmusician
      nfmusician
    • RE: [Beta] Tinkering with Pythonista's internals using objc_util

      Understanding this is for experimentation only, how would one go about modifying OMPythonSyntaxHighlighter or making a custom syntax highlighter class?

      posted in Pythonista
      nfmusician
      nfmusician
    • RE: Prevent duplicate launch from shortcut

      @TPO Do you have this on a Github anywhere? It's useful.

      posted in Pythonista
      nfmusician
      nfmusician
    • RE: Python: Can't delete file from Dropbox?

      The Dropbox SDK will only manage files when connected, correct? So just to clarify, there is no workflow or other offline equivalent to either swiping left on a file to delete, or using the in-editor feature to rename a file.?

      posted in Editorial
      nfmusician
      nfmusician