• Login
Community
  • Login

Question for PythonScript users

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
6 Posts 3 Posters 696 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E
    Ekopalypse
    last edited by Sep 19, 2019, 2:54 PM

    the first time I have to thank google for caching :-)

    I’m still working to get a python3 scripting interface for npp.
    Most of the part already works but now the fancy stuff needs to be addressed.
    One open point on my list addresses callbacks.

    The question I have is how do you use and clear callbacks currently.

    The issue I’m facing is that if I run a script to register a callback function it is hard
    to identify the registered callback function if I want to clear it from another script.

    Currently I’m saving the hash of a func.code.code object and compare it once
    a clearCallback request comes in.
    But this, obviously has the drawback if one wants to register the same function
    multiple times with the same notification.
    But I’m questioning that this makes sense at all - so are there other constructs
    you might think of which could break your code when I’m doing such comparison?
    Or does it make sense to register the same function multiple times for the same notification?

    1 Reply Last reply Reply Quote 2
    • A
      Alan Kilborn
      last edited by Sep 19, 2019, 3:02 PM

      @Ekopalypse said in Question for PythonScript users:

      Or does it make sense to register the same function multiple times for the same notification?

      I’m a fairly extensive Pythonscripter and I’ve never needed to do this, so I’d say NO.

      But maybe there is a use for it…for someone…

      1 Reply Last reply Reply Quote 2
      • C
        cmeriaux
        last edited by Sep 19, 2019, 10:28 PM

        @Ekopalypse I don’t use callback even it’s very powerfull, I always trigger my scripts through shortcut.
        I’m very interrested in your python script implementation. Have you forked the original one our did you rewrite a new one ? Are you on github ?
        Thanks

        E 1 Reply Last reply Sep 19, 2019, 10:46 PM Reply Quote 2
        • E
          Ekopalypse @cmeriaux
          last edited by Sep 19, 2019, 10:46 PM

          @cmeriaux

          Thx for the input.
          I’m writing a completely new version as my c/c++ skills are terrible aka non-existant
          I’m using cffi for creating the necessary code for the plugin and cpython interpreter.
          Everything else is written in python3.7 (actually should work with all versions >3.4 if compiled with it).
          Surprisingly, it is often faster than the current pythonscript version and
          can use pip (not officially supported but seems to work) on embedded python package.

          I do have an account on github and it is planned to release it to github
          once I have all important functionality, currently available in pythonscript, covered.

          Currently I do have two issues I want to have fixed before releasing the
          first version, namely the two in the important section below.

          Current open points

          {IMPORTANT (no release until those are done)
              - editor object used in scripts is fixed !! AARRRGGGG
              - boost::regex = python re (not sure if boost::regex can be implemented at all)
                  cython seems to be able to use boost templates - investigating.
          ;;}
          
          {MEDIUM (should have points but not worth to stop releasing version)
              - create tests for notepad, scintilla and console objects
              - create sphinx docs
              - console object needs run combo/textbox - consider using pyshell(?)
              - editor callback factory needs to be coded otherwise each instance holds
                it own list of subscribers - maybe move to plugin.py (!?)
              - console hotspot functionality missing
          ;;}
          
          {LOW (nice to have but does not affect functionality)
              - startup.py (really needed? __init__.py might do the job as well)
              - create readme
              - different console output colors
              - console configuration gui
              - reconsider using cython for notepad and scintilla objects
          
              - PS functions which do return int but docu and iface suggest it shouldn't
                  setSelection  int  None         <-- PS error?
                  addText  int  None              <-- PS error?
                  addSelection  int  None         <-- PS error?
                  changeInsertion  int  None      <-- PS error?
                  setStylingEx  int  None         <-- PS error?
                  appendText  int  None           <-- PS error?
                  addStyledText  int  None        <-- PS error?
                  copyText  int  None             <-- PS error?
                  write  int  None                <-- PS error?
          
              - list of messages not implemented yet as wasn't implented by pythonscript either
                  NPPM_GETCURRENTSCINTILLA
                  NPPM_MODELESSDIALOG
                  NPPM_DMMSHOW
                  NPPM_DMMHIDE
                  NPPM_DMMUPDATEDISPINFO
                  NPPM_DMMREGASDCKDLG
                  NPPM_DMMVIEWOTHERTAB
                  NPPM_SETMENUITEMCHECK
                  NPPM_ADDTOOLBARICON
                  NPPM_DMMGETPLUGINHWNDBYNAME
                  NPPM_MSGTOPLUGIN
                  NPPM_SETBUFFERLANGTYPE
                  NPPM_GETBUFFERENCODING
                  NPPM_GETSHORTCUTBYCMDID
                  NPPM_REMOVESHORTCUTBYCMDID
                  NPPM_GETPLUGINHOMEPATH
                  NPPM_GETFULLCURRENTPATH
                  NPPM_GETCURRENTDIRECTORY
                  NPPM_GETFILENAME
                  NPPM_GETNAMEPART
                  NPPM_GETEXTPART
                  NPPM_GETCURRENTWORD
                  NPPM_GETFILENAMEATCURSOR
                  NPPM_GETCURRENTLINE
                  NPPM_GETCURRENTCOLUMN
                  NPPM_GETNPPFULLFILEPATH
          ;;}
          
          {DONE
              - scintilla wrapped
              - assert scintilla functions
              - notepad wrapped
              - assert notepad functions
              - console wrapped
              - assert console functions
              - dynamic menu creation, like adding an menu item when creating a new script
          ;;}
          
          {INFO
              pymlreplace (deprecated function)
              pyreplace (deprecated function)
              no editor.flash (notepad has flashWindow which from my point of view is better)
              no editor.createLoader function, seems that it doesn't make sense from scripting point of view
              editor.search returns a tuple (start_position, end_position)
              editor.research and rereplace are currently implemented using python re engine.
              editor.callbacks are, like notepad.callbacks synchronous
              console.encoding is a property, not a function anymore (python3 related)
              no console.softspace as softspace is not used in python3 print function anymore
              console.run = console.execute (threading uses run)
              notepad.outputDebugString has not been migrated
          ;;
          
          C 1 Reply Last reply Sep 20, 2019, 12:02 PM Reply Quote 2
          • E
            Ekopalypse
            last edited by Ekopalypse Sep 19, 2019, 11:33 PM Sep 19, 2019, 11:30 PM

            Just to illustrate (and to test the new picture upload functionality :-) what
            the first important open point is.
            The callback mechanism itself works, the problem is, that the editor object,
            once it gets created WIHTIN an import statement, is fixed and not dynamic anymore.
            Meaning that if editor pointed to editor1 at the time it was imported
            it will always point to editor1, regardless if one does editor=editor2.
            But if a script gets executed (BUT NOT IMPORTED) then editor points to either editor1 or editor2. Hmmmm ???

            98defa20-9567-4ff0-9621-8f7b8b29e0f0-image.png

            1 Reply Last reply Reply Quote 2
            • C
              cmeriaux @Ekopalypse
              last edited by Sep 20, 2019, 12:02 PM

              @Ekopalypse Thanks very much for your involvement.
              Once you’are ready for beta testing, you can contact me.

              1 Reply Last reply Reply Quote 3
              1 out of 6
              • First post
                1/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors