Community
    • Login

    Seeing the zoom level with PythonScript.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    zoom
    14 Posts 3 Posters 5.2k 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.
    • Scott SumnerS
      Scott Sumner @SalviaSage
      last edited by

      @SalviaSage

      I ran the code from the linked thread (not sure if you changed it at all–if you did you should say that; if not you shouldn’t have copied it above). When running it, I find its results acceptable. There is a bit of “flicker” and here’s why: this code is competing with Notepad++ itself to draw that section of the status bar. Whenever it needs to change, first (probably) Notepad++ draws it and then the Pythonscript code draws it.

      I’m not sure why it is so bad for you; your animated GIF isn’t the greatest (very small), but it does appear to be worse than what I see in my trials.

      1 Reply Last reply Reply Quote 0
      • SalviaSageS
        SalviaSage
        last edited by

        You are right, both pythonscript and n++ itself is drawing it. There is no flicker at all without this external code. The code pretty much breaks the proper appearance of that area of n++ by flickering each time you click with mouse or type. This is not acceptable for me.

        But I really would like to see my zoom levels and this code does let me see zoom levels. Maybe we can put this zoom thing into another part of n++. Maybe we can give it a place of its own in the status bar, so folks can see what zoom level they are at.

        Ideas?

        thanks for looking into this matter!

        Scott SumnerS 1 Reply Last reply Reply Quote 0
        • Scott SumnerS
          Scott Sumner @SalviaSage
          last edited by Scott Sumner

          @SalviaSage

          I have had code writing over these 2 areas of the statusbar in the same manner for a long time, and for me the flickering is minimal and very acceptable:
          Imgur

          Sorry but I can’t really say why it is so poor for you.

          So the 6 sections of the status bar are:
          Imgur
          and you control which one you write to by using the following in the code:

          1. STATUSBARSECTION.DOCTYPE
          2. STATUSBARSECTION.DOCSIZE
          3. STATUSBARSECTION.CURPOS
          4. STATUSBARSECTION.EOFFORMAT
          5. STATUSBARSECTION.UNICODETYPE
          6. STATUSBARSECTION.TYPINGMODE

          Why don’t you try the DOCTYPE section; I think you’ll be happier with the result, unless your system is again different from mine.

          1 Reply Last reply Reply Quote 3
          • SalviaSageS
            SalviaSage
            last edited by

            Okay, I managed to move the zoom thing to the file type area, but it replaced the whole filetype name. I kind of copied the previous code so it won’t do this, but I can’t keep the file type text unless if I know its variable name (or whatever its called) for the filetype name.

            Is there like a link to Notepad++ API? I know it’s open source, but I don’t even know where to look.

            Claudia FrankC Scott SumnerS 2 Replies Last reply Reply Quote 0
            • Claudia FrankC
              Claudia Frank @SalviaSage
              last edited by

              @SalviaSage

              messages which can be send to npp are defined in Notepad_plus_msgs.h
              You are looking for NPPM_GETLANGUAGEDESC.

              The current python script versions (1.0.8.0 and 1.0.9.0(beta)) do not contain this
              message yet but one of the next versions should contain it with something like

              >>> notepad.getLanguageDesc(notepad.getLangType())
              'eXtensible Markup Language file'
              

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 1
              • Scott SumnerS
                Scott Sumner @SalviaSage
                last edited by

                @SalviaSage

                Okay, well, I for one find the “DOCTYPE” area kind of useless, or at least unimportant: If I’m editing a .py file, I know that it is a Python file; I don’t need Notepad++ to tell me. Also, The “DOCTYPE” area is only updated by Notepad++ when the user changes tabs (or when the user changes a tab’s type (rare)). So the flickering you noticed earlier should not happen or at least be minimal (i.e., acceptable).

                Don’t take this the wrong way, but from reading several other of your posts, you seem to be a bit hard to please. Notepad++ is a great text editor, but it isn’t going to please everyone all the time. Learn to take joy in what it can do for you, and don’t criticize it too harshly if it can’t do something exactly the way you want.

                1 Reply Last reply Reply Quote 2
                • SalviaSageS
                  SalviaSage
                  last edited by SalviaSage

                  @Claudia-Frank

                  I made some progress on this. I can now return the language type number with this code, and then have the zoom put after it.

                  For example, returns a 22 for python files and 80 for windows registry files.

                  However, I have not managed to return the names instead.

                  import locale
                  locale.setlocale(locale.LC_ALL, '')
                  
                  def StatusbarTypeOverride(args):
                      _type = "{0:n}".format(notepad.getLangType())
                      _zoom = editor.getZoom()
                      notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, 'type:{}  zoom:{}'.format(_type, _zoom))
                  
                  editor.callback(StatusbarTypeOverride, [SCINTILLANOTIFICATION.UPDATEUI, SCINTILLANOTIFICATION.ZOOM])  # register callback
                  

                  Claudia, you said the version 1.0.9.0 release (non-beta) doesn’t contain that syntax you typed.
                  Why? I don’t think I can return the names if that syntax is not in pythonscript.

                  Maybe I can make an issue post in their page telling them to implement it.

                  Claudia FrankC 1 Reply Last reply Reply Quote 0
                  • SalviaSageS
                    SalviaSage
                    last edited by

                    lol win… I added the Zoom line in to the EOL displayer instead. there is very very little flickering and this is what is acceptable.

                    This is what it looks like:
                    https://i.imgur.com/WRho9f3.jpg

                    And this is the code:

                    ## Adds the zoom indicator to the statusbar.
                    import locale
                    locale.setlocale(locale.LC_ALL, '')
                    
                    def StatusbarEOLOverride(args):
                    	_eolMode = editor.getEOLMode()
                    	_zoom = editor.getZoom()
                    	_eolString = ""
                    	if _eolMode == 0:
                    		_eolString = "CR+LF"
                    	elif _eolMode == 1:
                    		_eolString = "LF"
                    	elif _eolMode == 2:
                    		_eolString = "CR"
                    	notepad.setStatusBar(STATUSBARSECTION.EOFFORMAT, '{} | Zoom: {}'.format(_eolString, _zoom))
                    
                    editor.callback(StatusbarEOLOverride, [SCINTILLANOTIFICATION.UPDATEUI, SCINTILLANOTIFICATION.ZOOM]) # register callback
                    

                    case closed for now… until the npp devs give us a brand new statusbar category that shows the zoom…

                    1 Reply Last reply Reply Quote 1
                    • SalviaSageS
                      SalviaSage
                      last edited by

                      sorry, the forum won’t let me edit my post. Here is the correct code:

                      ## Adds the zoom indicator to the statusbar.
                      import locale
                      locale.setlocale(locale.LC_ALL, '')
                      
                      def StatusbarEOLOverride(args):
                      	_eolMode = editor.getEOLMode()
                      	_zoom = editor.getZoom()
                      	_eolString = ""
                      	if _eolMode == 0:
                      		_eolString = "CR+LF"
                      	elif _eolMode == 1:
                      		_eolString = "CR"
                      	elif _eolMode == 2:
                      		_eolString = "LF"
                      	notepad.setStatusBar(STATUSBARSECTION.EOFFORMAT, '{} | Zoom: {}'.format(_eolString, _zoom))
                      
                      editor.callback(StatusbarEOLOverride, [SCINTILLANOTIFICATION.UPDATEUI, SCINTILLANOTIFICATION.ZOOM]) # register callback
                      
                      1 Reply Last reply Reply Quote 0
                      • SalviaSageS
                        SalviaSage
                        last edited by

                        … admin plz fix my post…

                        ## Adds the zoom indicator to the statusbar.
                        import locale
                        locale.setlocale(locale.LC_ALL, '')
                        
                        def StatusbarEOLOverride(args):
                            _eolMode = editor.getEOLMode()
                            _zoom = editor.getZoom()
                            _eolString = ""
                            _zoomString = ""
                            if _eolMode == 0:
                                _eolString = "CR+LF"
                            elif _eolMode == 1:
                                _eolString = "CR"
                            elif _eolMode == 2:
                                _eolString = "LF"
                            if _zoom == 0:
                                _zoomString = "0"
                            else:
                                _zoomString = '{:+}'.format(_zoom)
                            notepad.setStatusBar(STATUSBARSECTION.EOFFORMAT, '{} | Zoom: {}'.format(_eolString, _zoomString))
                        
                        editor.callback(StatusbarEOLOverride, [SCINTILLANOTIFICATION.UPDATEUI, SCINTILLANOTIFICATION.ZOOM]) # register callback
                        

                        this code is even better

                        1 Reply Last reply Reply Quote 1
                        • Claudia FrankC
                          Claudia Frank @SalviaSage
                          last edited by

                          @SalviaSage

                          the reason why it isn’t in the current python script version is that
                          the pull request hasn’t be merged yet
                          because there is

                          a) an outstanding issue (has to do with PR #53) and
                          b) I haven’t provided any unit tests yet.

                          You are using 1.0.9.0 with npp x64bit aren’t you,
                          because x86 (32bit) is still offering 1.0.8.0 only.

                          I’m using 1.0.9.0 for quite some time now and it looks reasonable stable but I still
                          consider it to be in beta state as it is the first 64bit version and I’m sure there are
                          still some hidden “features” waiting to be detected :-)

                          Some console lock/freezings have been already discovered and merged.

                          Cheers
                          Claudia

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