Community
    • Login

    show the current zoom

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    28 Posts 9 Posters 8.3k 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.
    • wonkawillyW
      wonkawilly
      last edited by

      I’d like to have this feature too.
      In my experience usually the zoom level is indicated in the status bar in most of the software I use.
      Probably modern GUIs usually implement zoom commands in the status bar and so I suppose that users would look there at a glance and to have coherence in GUIs probably would like to have it there since it is always visible and of easy of access.
      Since I have 24" screen I would not mind having it at the left or right side in the status bar, as shown in the Management Studio screenshot of the OP, or even as it was in Windows Word Pad fashon:
      ef261565-06d4-417f-9e0f-70b305c2ea80-image.png
      or MS Word’s or, to dedicate to it the less possible space, instead of having an horizontal zoom selector perhaps would work even better a vertical one as in the Windows volume slider:
      d9d66b50-ce4e-4b67-840e-0938fa4b1249-image.png
      Of course completed with the indication also expressed in numbers and maybe a button to reset to default/standard zoom level or to a user-settable-standard-default (I don’t know how to call it) zoom level, for the current file or for all opened files altogether .

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @wonkawilly
        last edited by Alan Kilborn

        @wonkawilly

        Regarding 228% screenshot: Way too much statusbar space wasted on a feature that is not very useful (IMO).


        OK, so just what are people zooming in/out for??
        Do people not know how to set an appropriate (for them) font size?? And thus set-and-leave zoom level at zero? And thus, just forget about zoom level forevermore?

        Snabel42S mkupperM 2 Replies Last reply Reply Quote 2
        • Snabel42S
          Snabel42 @Alan Kilborn
          last edited by

          @Alan-Kilborn a few different times I find myself adjusting zoom:

          • Different DPI and resolution on different monitors (application window currently being on different monitors
          • Content of the current text (Source code vs long form text etc)
          • My morning eyesight vs evening eye sight (mine changes due to tiredness)
          • Whether I prefer wearing glasses or not (changes with eye straing, lighting conditions etc

          I would personally much prefer zoom level being quickly visible in the status bar. rather than setting a font size and leaving it at that.

          1 Reply Last reply Reply Quote 1
          • mkupperM
            mkupper @Alan Kilborn
            last edited by

            @Alan-Kilborn said in show the current zoom:

            OK, so just what are people zooming in/out for??
            Do people not know how to set an appropriate (for them) font size?? And thus set-and-leave zoom level at zero? And thus, just forget about zoom level forevermore?

            I zoom in, out, and reset several times a day. Sometimes I need to see the big picture and will zoom out. Other times I want to see a detail and so I zoom in. When dealing with code I like to be able to see the entire block or section I’m dealing with and will adjust the zoom as needed. I use both the mouse wheel and keyboard’s Ctrl+Num +-/ to zoom in/out/reset.

            However, for Notepad++ I have never need to know the zoom level as a number or percentage as I adjust the zoom until it looks good.

            Lately I have been troubleshooting a web site issue and have discovered that knowing the exact zoom level, or being able to set it to an exact number in Firefox is useful as I have been taking screen shots and then using them to show what has changed. 80% zoom happens to be the sweet spot.

            However, I really don’t need to know that a number such as 80% is the sweet spot. For example, let’s say in Notepad++ I am taking advantage of page up/down to show different views or aspects of something. I flip up or down through the pages like a slide show. In that case there will be a zoom level that is the sweet spot for this particular file. All I’d do would be to add a note, Zoom +3 that reminds me that the desired sweet spot is achieved by resetting the zoom and then doing three up-ticks using Ctrl /+++.

            Alan KilbornA 1 Reply Last reply Reply Quote 1
            • Alan KilbornA
              Alan Kilborn @mkupper
              last edited by

              @mkupper said in show the current zoom:

              However, for Notepad++ I have never need to know the zoom level as a number or percentage as I adjust the zoom until it looks good.

              I was going to reply to @Snabel42 's comments with something like this.
              The key takeaway: Knowing the zoom level number doesn’t do much for you, just adjust until the text looks “good” to you (whatever that means).

              Here’s another point, when people are saying program X, Y and Z all have zoom in their status bar: I’d say that other programs use % values for this, and Notepad++ doesn’t provide a nice % value for the setting. So, if all the clamorers for this in the status bar get it, they’ll then start complaining that it isn’t showing a percentage.

              Snabel42S 1 Reply Last reply Reply Quote 1
              • Snabel42S
                Snabel42 @Alan Kilborn
                last edited by Snabel42

                @Alan-Kilborn said in show the current zoom:

                @mkupper said in show the current zoom:

                However, for Notepad++ I have never need to know the zoom level as a number or percentage as I adjust the zoom until it looks good.

                I was going to reply to @Snabel42 's comments with something like this.
                The key takeaway: Knowing the zoom level number doesn’t do much for you, just adjust until the text looks “good” to you (whatever that means).

                I was thinking the same thing. And I do agree that a lot of the time knowing the exact value probably is not necessary. Yet I somehow find myself wanting to see it. Maybe habit from it being such a common mechanism in many other applications I use?

                I was also considering the previously mentioned feature of allowing zoom to be synced between multiple tabs shown side-by-side. Side-by-side comparison views of multiple tabs is one scenario where I’d normally find myself wanting to “see” the zoom. I can usually sync up the zoom manually, but usually by overshooting the zoom in one of the tabs, then adjusting back to match the second tab.

                If syncing was a feature, I suppose seeing the actual zoom value/level would be needed even less. But then again seeing the zoom would perhaps let the user know if zoom-syncing was currently enabled or not for the two visible tabs.

                Alan KilbornA 1 Reply Last reply Reply Quote 0
                • deleeleeD
                  deleelee @Alan Kilborn
                  last edited by

                  @Alan-Kilborn said in show the current zoom:

                  there are currently two toolbar buttons dedicated to zoom

                  There are actually three buttons. Zoom in, zoom out, restore default zoom.

                  Another possibility would be to have a toolbar button that shows the current zoom then users can decide if they want to use it or not.

                  PeterJonesP 1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @deleelee
                    last edited by PeterJones

                    @deleelee ,

                    There are three zoom actions. There are only two zoom buttons on the default toolbar.

                    3221d929-1b04-4c4b-a9b7-487c1095f252-image.png

                    You can examine the Online User Manual’s list of all the toolbar buttons to confirm this

                    If you have a button on the toolbar for the restore-zoom, you probably added it with the Customize Toolbar plugin or another plugin.

                    deleeleeD 1 Reply Last reply Reply Quote 3
                    • deleeleeD
                      deleelee @PeterJones
                      last edited by deleelee

                      @PeterJones said in show the current zoom:

                      you probably added it with the Customize Toolbar plugin

                      Oh lordy, you are correct. Sorry about that. I forgot that plugin came with toolbar buttons.

                      1 Reply Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @Snabel42
                        last edited by

                        @Snabel42 said in show the current zoom:

                        I was also considering the previously mentioned feature of allowing zoom to be synced between multiple tabs shown side-by-side. Side-by-side comparison views of multiple tabs is one scenario where I’d normally find myself wanting to “see” the zoom. I can usually sync up the zoom manually, but usually by overshooting the zoom in one of the tabs, then adjusting back to match the second tab.

                        Here’s a script that will keep the zoom levels for both views the same. I call the script ZoomLevelKeepBothViewsSynched.py.

                        # -*- coding: utf-8 -*-
                        from __future__ import print_function
                        
                        #########################################
                        #
                        #  ZoomLevelKeepBothViewsSynched (ZLKBVS)
                        #
                        #########################################
                        
                        # references:
                        #  https://community.notepad-plus-plus.org/topic/25844
                        #  for newbie info on PythonScripts, see https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript
                        
                        #-------------------------------------------------------------------------------
                        
                        from Npp import *
                        
                        #-------------------------------------------------------------------------------
                        
                        try:
                            editor1.hwnd
                        except AttributeError:
                            # running PS2
                            import ctypes
                            user32 = ctypes.WinDLL('user32')
                            notepad.hwnd = user32.FindWindowW(u'Notepad++', None)
                            editor1.hwnd = user32.FindWindowExW(notepad.hwnd, None, u'Scintilla', None)
                        
                        assert editor1.hwnd
                        
                        #-------------------------------------------------------------------------------
                        
                        class ZLKBVS(object):
                        
                            def __init__(self):
                                editor.callback(self.zoom_callback, [SCINTILLANOTIFICATION.ZOOM])
                                self.zoom_callback( { 'hwndFrom' : editor } )
                        
                            def zoom_callback(self, args):
                                if not notepad.isSingleView():
                                    other_editor = editor2 if args['hwndFrom'] == editor1.hwnd else editor1
                                    this_editor = editor2 if other_editor == editor1 else editor1
                                    other_editor.setZoom(this_editor.getZoom())
                        
                        #-------------------------------------------------------------------------------
                        
                        # to run via another file, e.g., (user) startup.py, put these lines (uncommented and unindented) in that file:
                        #  import ZoomLevelKeepBothViewsSynched
                        #  zlkbvs = ZoomLevelKeepBothViewsSynched.ZLKBVS()
                        # also note: need to make sure that "Initialisation" for "Python Script Configuration" is set to "ATSTARTUP" and not "LAZY".
                        
                        if __name__ == '__main__':
                            try:
                                zlkbvs
                            except NameError:
                                zlkbvs = ZLKBVS()
                        
                        Andi KiisselA 1 Reply Last reply Reply Quote 4
                        • Alan KilbornA Alan Kilborn referenced this topic on
                        • Andi KiisselA
                          Andi Kiissel @Alan Kilborn
                          last edited by

                          @Alan-Kilborn said in show the current zoom:

                          Here’s a script that will keep the zoom levels for both views the same.

                          These five rows in startup.py do the same thing for me:

                          def syncZoomLevel(args):
                              level = editor.getZoom()
                              editor1.setZoom(level)
                              editor2.setZoom(level)
                          editor.callback(syncZoomLevel, [SCINTILLANOTIFICATION.ZOOM])
                          
                          
                          PeterJonesP 1 Reply Last reply Reply Quote 0
                          • PeterJonesP
                            PeterJones @Andi Kiissel
                            last edited by PeterJones

                            @Andi-Kiissel ,

                            Your super-simple script assumes that the last tab you clicked in (editor) is the same editor you are zooming. But it is possible to click in View1 and zoom in View2, because it will zoom whichever tab the mouse pointer is hovering over when you use Ctrl+Scrollwheel, even if you haven’t clicked in that view

                            And because of that, Alan had to add some checks to see which view was actually being zoomed (not which has the last click), and that process is hampered by PythonScript 2 not including the .hwnd, whereas PythonScript 3 has the .hwnd already. (Update 3: … hence needing the ctypes and hwnd-grabber at the beginning)

                            And as we regulars often do, he wrapped it in a class, so that function and variable names in his script won’t clobber the function and variable names from other scripts.

                            Thus, as often happens: when you just try to “get it done”, it’s pretty simple and can be a few lines of code; but when you then try making it good enough for publishing, to cover edge cases, the code becomes more complicated. This Is The Way.

                            ----

                            Update 1: Yep, I just confirmed: when I ran your script, clicked in View1, and tried to scrollwheel-zoom while the mouse cursor was still over View1, it correctly zoomed both Views. But if I move the mouse cursor over view2 – without clicking, so view1 is still active – then when I try to scroll-zoom, view2 briefly shows up as zoomed, but then jumps back to no-zoom.

                            Update 2: Yep, when I instead run Alan’s, whether my scrollwheel-zoom is over view1 or view2, both views correctly scroll as expected

                            mpheathM 1 Reply Last reply Reply Quote 4
                            • mpheathM
                              mpheath @PeterJones
                              last edited by

                              @PeterJones Any name can be clobbered. Minimal names in the global namespace is a good idea. So I guess no names is the least to be clobbered. Once the name has been used to register the object with the callback then the name is not needed anymore unless it is wanted to unregister the callback which is probably not often done.

                              Classes can have multiple methods which is why I consider that many users choose to use them. Functions also can be suitable for this task as it is not that complex. Functions can be as useful as classes and each has their role. So I am posting a function so please do not clobber me for choosing a function.

                              This function can sync the zoom levels and can be done without .hwnd so can be compatible with PythonScript 2 and PythonScript 3. Keeping track of the zoom levels and adjusting the levels is how it operates.

                              from Npp import editor, editor2, SCINTILLANOTIFICATION
                              
                              def _():
                                  zoomLevels = [editor1.getZoom(), editor2.getZoom()]
                              
                                  def zoomLevel(args):
                                      if editor1.getZoom() != zoomLevels[0]:
                                          level = editor1.getZoom()
                                          editor2.setZoom(level)
                                          zoomLevels[0] = level
                                      elif editor2.getZoom() != zoomLevels[1]:
                                          level = editor2.getZoom()
                                          editor1.setZoom(level)
                                          zoomLevels[1] = level
                              
                                  return zoomLevel
                              
                              editor.callback(_(), [SCINTILLANOTIFICATION.ZOOM])
                              del _
                              

                              This is basically a nameless enclosure function as _ is usually treated as a temporary name. Enclosed to keep zoomLevels available to only the inner nested function zoomLevel. The _ name is deleted after registering the callback so the global namespace has no additional names. This code can be added to the startup script and that is what I would insert it as that is where I have tested it.

                              Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 4
                              • Alan KilbornA
                                Alan Kilborn @mpheath
                                last edited by Alan Kilborn

                                @mpheath said:

                                I guess no names is the least to be clobbered.

                                But it is probably considered “extreme” to go to that length.
                                It isn’t a terrible thing to introduce one or two new names per script, if the names are reasonably unique (as mine tend to be).
                                Confession: My script directly above also introduces a user32 name. This is to support PythonScript v2, which, since I don’t use that, was a last minute add-on concession.

                                …and can be done without .hwnd so can be compatible with PythonScript 2 and PythonScript 3

                                I write exclusively in PS3 these days. Often I make the concession to publish a script so that it is compatible with both, but I don’t think in terms of “how do I make this the most efficient” in order to provide this support.

                                Probably, at some point, I will not bother to provide PS2 compatible code in scripts I publish.

                                Functions also can be suitable for this task as it is not that complex.

                                When I’m scripting, I don’t start out by judging: “Is this task complex enough to deserve a class wrapper?” or equivalently “Is this task simple enough to just be a function?”. As I have a script that generates a new script’s skeleton, I just go with it and everything gets a class.

                                I am posting a function so please do not clobber me for choosing a function.

                                Not clobbering, just commenting. :-)

                                1 Reply Last reply Reply Quote 1
                                • PeterJonesP
                                  PeterJones @mpheath
                                  last edited by

                                  @mpheath ,

                                  I am posting a function so please do not clobber me for choosing a function.

                                  Apparently, I did not communicate very clearly, since you think that was what I was saying. Sorry.

                                  My point about “clobbering” was the least important point in my message (and the point least supported by data). It was meant more as an observational example of why one might wrap things in a class: but your reason (multiple functions) and Alan’s reason (templated code) are both better justifications for it than my <theThing>it’s not clobbering time</theThing> semi-reason. :-)

                                  I come from Perl’s TIMTOWTDI philosophy, so I very much encourage and appreciate different approaches. And I like your solution for avoiding the need for .hwnd – tracking the state, so you can tell which was changed and thus which to replicate to the other, is a great idea.

                                  and @Alan-Kilborn said,

                                  I write exclusively in PS3 these days.

                                  I just wish PS3 would stop calling itself “alpha” and release to Plugins Admin, to make it easier for everyone to make that transition.

                                  mpheathM 1 Reply Last reply Reply Quote 3
                                  • mpheathM
                                    mpheath @PeterJones
                                    last edited by

                                    @PeterJones said in show the current zoom:

                                    Apparently, I did not communicate very clearly, since you think that was what I was saying. Sorry.

                                    My point about “clobbering” was the least important point in my message (and the point least supported by data)…

                                    @Andi-Kiissel had only one name and yet was warned about clobbering. I tried for less as changing the name to _ was quite easy. Thanks for apologizing and clarifying your intentions.

                                    I come from Perl’s TIMTOWTDI philosophy, so I very much encourage and appreciate different approaches. And I like your solution for avoiding the need for .hwnd – tracking the state, so you can tell which was changed and thus which to replicate to the other, is a great idea.

                                    I see here https://perl.fandom.com/wiki/TIMTOWTDI about “only one option for not equals operator”. Well, Python 2 vs Python 3 compatiibility is usually more of a concern than the single != operator IMO.

                                    I just wish PS3 would stop calling itself “alpha” and release to Plugins Admin, to make it easier for everyone to make that transition.

                                    Absolutely. I cater for PS2 as it is the Plugin Admin default. The Plugin Admin could offer both versions to keep everyone happy. Python 2 is backwards for me as I started with early Python 3 and so I do minor hacks to make PS3 code work for the PS2 users.

                                    @Alan-Kilborn said in show the current zoom:

                                    But it is probably considered “extreme” to go to that length.

                                    To be open minded about everything is to include the “extreme”. So thanks for the complement.


                                    As for “show the current zoom”, I like the KISS concept. Too much stuff to view which can make you can miss what is important. I am sure there are others who would prefer Notepad++ to look like a cockpit of a 747 jumbo jet. I am usually busy doing something so viewing the zoom level is not a concern for me. Synchronizing zoom with 2 panes is a tedious task so I saw value with another script to choose from that might help.

                                    Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 2
                                    • Alan KilbornA
                                      Alan Kilborn @mpheath
                                      last edited by

                                      @mpheath said in show the current zoom:

                                      I am sure there are others who would prefer Notepad++ to look like a cockpit of a 747 jumbo jet.

                                      Such a statement always reminds me of this ISSUE, maybe because of this COMMENT from that issue. :-)

                                      1 Reply Last reply Reply Quote 1
                                      • PeterJonesP
                                        PeterJones @mpheath
                                        last edited by

                                        Unimportant aside:

                                        @mpheath said in show the current zoom:

                                        I see here https://perl.fandom.com/wiki/TIMTOWTDI about “only one option for not equals operator”.

                                        Ugh, that page does an awful job of describing the TIMTOWTDI philosophy – it makes it seem like it’s a petty reactionism to Python, but that philosophy was actually baked into Perl from the beginning, without any thought to Python (which was introduced a couple years after Perl was initially released). Given that it had two sentences about TIMTOWTDI, two sentences about how “unreadable” Perl is, and a whole paragraph describing Python as the antithesis, I get the feeling that the author of that article may have been a critic, not a fan, of Perl.

                                        And I didn’t make either my original TIMTOWTDI comment, nor this response paragraph, to try to start a language-war with the proponents of Python. I personally use Perl more than I do Python (because PythonScript is my only use of Python, whereas I’ve been doing hobbiest projects in Perl since the 90s) – but it’s not because I think Perl is “better” than Python – they are different, and each have their pros and cons – it’s just that I’m more familiar and comfortable with Perl. I actually brought up TIMTOWTDI to say that I actually appreciate different perspectives and design choices in coding, and I usually learn something by seeing how someone else would approach a problem differently than I would.

                                        Alan KilbornA 1 Reply Last reply Reply Quote 3
                                        • Alan KilbornA
                                          Alan Kilborn @PeterJones
                                          last edited by Alan Kilborn

                                          @PeterJones said in show the current zoom:

                                          try to start a language-war with the proponents of Python

                                          No saber-rattling detected…or intended with the following:

                                          My history is Perl first, then Python – standalone, not PythonScript.
                                          And both were for text processing type things; for other things I’ve always been a C/C++ person (mainly C).
                                          The old command-line guy in me really liked Perl’s quirkiness, perhaps readers know what I mean … command.com’s interpreter really had/has a bunch of quirks.

                                          However, as much as I liked Perl at the time, I found that if I “put it down” for a while, it was really hard to come back to it (due to ever-advancing age perhaps). With Python, I found it just sort of flows from the fingertips, so to say, and was easy to come back to after some time off. Aside from maintenance of some large scripts I wrote and still use, I haven’t done any new Perl in many years (perhaps a decade?).

                                          I was rather pleased when I discovered Notepad++ and saw that its most popular scripting plugin was Python-based. (This might be the only sentence in the post that is on-topic).

                                          But overall, I see no need for “language wars”.
                                          I’m reminded of the quote from the Lord of the Rings (movies): “Go off and die in whatever manner most suits you” (or something like that).
                                          In this case, “Go off and use whatever language most suits you, as long as it gets your job done”.

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