[Eric] Is there documentation for how to create a "nonstandard" plugin?

Mike C. Fletcher mcfletch at vrplumber.com
Thu Sep 18 19:21:40 BST 2014


Hi all,

I've been building a little voice-dictation-for-coding service (for 
linux) and I'm getting to the point where I need to actually hook it up 
to an editor. Since Eric (5), from Mercurial is my editor of choice it 
seems I'll need to figure out how to write a plugin that *isn't* one of 
the built-in types (i.e. not a VCS or similar plugin). I want to build a 
plug-in that:

  * hooks into each opened code-editing window (possibly/likely with a
    filter on the lexer languages)
      o captures "focus" events for the window(s) to tell the service
        when to interpret the dictation in the language-appropriate manner
      o preferably can provide some context hints to the dictation
        engine "docstring", "python code", "html code"
  * generates dictation events to be integrated into the code-editor
    (over DBUS)
      o with undo-ability (particularly as there's likely to be lots of
        "correct-that" operations)

The rest of this is just me thinking aloud and inviting 
corrections/suggestions/clarifications...

  * The editor class seems to be in eric5/QScintilla/Editor.py
      o Undo: QScintilla beginUndoAction/endUndoAction are there, so
        that looks pretty easy to implement
      o It looks like command-and-control should be easy to implement
        when I get that far too
  * Hooking the creation of an editor
      o Seems like I should be watching for
        ViewManager::editorOpenedEd(editor) and then doing all of my
        hooking in the handler
      o e5App().getObject('ViewManager').editorOpenedEd.connect(
        setup_editor_hooks )
      o The TabNanny plugin seems to do it this way
      o I'm assuming I can just hook regular Qt focus events too for the
        "change to this interpretation context" behaviour
      o It seems I can use the lexer language as a context cue
        (python/html/javascript/etc)
  * DBUS
      o I don't see any other use of DBUS, I'm guessing that PyQt qdbus
        should be available/workable
          + Obviously not on Windows/OS-X, but the whole project is
            linux-only for now
  * Plugin Structure
      o Seems to be magic comments in the plugin for metadata?
      o def activate(self): --> perform the hooking and DBUS setup
      o def deactivate(self): --> perform the un-hooking and DBUS
        teardown/deregistration
      o def __init__( self, ui ): --> internal setup only
      o Do we need a particular setup/packaging format? I gather each
        release needs to be hosted on Detlev's server/repository?

Anyway, if there's something obvious I'm missing, feel free to shout, 
I'm going to do a bit of hacking on the project this afternoon, so it 
may be I'll be back with further notes as I fall flat on my face. Eric 
is a rather huge code-base, so the chance that I've missed something is 
pretty large :D .

Have fun,
Mike

-- 
________________________________________________
   Mike C. Fletcher
   Designer, VR Plumber, Coder
   http://www.vrplumber.com
   http://blog.vrplumber.com



More information about the Eric mailing list