Community
    • Login

    v7.9.2 NPPM_SETLINENUMBERWIDTHMODE

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 2 Posters 259 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.
    • PeterJonesP
      PeterJones
      last edited by

      I am trying to implement the PerlScript wrappers for the new NPPM_SETLINENUMBERWIDTHMODE in v7.9.2.
      I got the NPPM_GETLINENUMBERWIDTHMODE to correctly read the state of the Settings > Preferences > Margins/Border/Edge: Line Number toggle. But it seems to always ignore NPPM_SETLINENUMBERWIDTHMODE (or, rather, that message always reads as a failure (retcode = 0))

      While debugging, I tried with both raw SendMessage from Perl, and using NppExec’s npp_sendmsg, and both seemed to fail on the SET, with the GET

      Notepad_plus_msgs.h#L439-L450

      #define NPPM_SETLINENUMBERWIDTHMODE (NPPMSG + 99)

        #define LINENUMWIDTH_DYNAMIC     0
      
        #define LINENUMWIDTH_CONSTANT    1
      

      // BOOL NPPM_SETLINENUMBERWIDTHMODE(0, INT widthMode)

      // Set line number margin width in dynamic width mode (LINENUMWIDTH_DYNAMIC) or constant width mode (LINENUMWIDTH_CONSTANT)

      // It may help some plugins to disable non-dynamic line number margins width to have a smoothly visual effect while vertical scrolling the content in Notepad++

      // If calling is successful return TRUE, otherwise return FALSE.

      #define NPPM_GETLINENUMBERWIDTHMODE (NPPMSG + 100)

      // INT NPPM_GETLINENUMBERWIDTHMODE(0, 0)

      // Get line number margin width in dynamic width mode (LINENUMWIDTH_DYNAMIC) or constant width mode (LINENUMWIDTH_CONSTANT)

      With NppExec

      script:

      cls
      echo get original setting:
      npp_sendmsg 2124 0 0
      echo $(MSG_RESULT)
      echo ---------------------
      echo try to set to 0
      npp_sendmsg 2123 0 0
      echo $(MSG_RESULT)
      echo and readback what I set
      npp_sendmsg 2124 0 0
      echo $(MSG_RESULT)
      echo The 2123 (set) failed, and 2124 stayed with original value
      echo ---------------------
      echo try to set to 1
      npp_sendmsg 2123 0 1
      echo $(MSG_RESULT)
      echo  and readback what I set
      npp_sendmsg 2124 0 0
      echo $(MSG_RESULT)
      echo The 2123 (set) failed, and 2124 stayed with original value
      

      When I have Settings > Preferences > Margins/Border/Edge: Line Number = Constant Width

      get original setting:
      NPP_SENDMSG: 2124 0 0
      1
      ---------------------
      try to set to 0
      NPP_SENDMSG: 2123 0 0
      0
      and readback what I set
      NPP_SENDMSG: 2124 0 0
      1
      The 2123 (set) failed, and 2124 stayed with original value
      ---------------------
      try to set to 1
      NPP_SENDMSG: 2123 0 1
      0
      and readback what I set
      NPP_SENDMSG: 2124 0 0
      1
      The 2123 (set) failed, and 2124 stayed with original value
      

      When I have Settings > Preferences > Margins/Border/Edge: Line Number = Dynamic Width =====

      get original setting:
      NPP_SENDMSG: 2124 0 0
      0
      ---------------------
      try to set to 0
      NPP_SENDMSG: 2123 0 0
      0
      and readback what I set
      NPP_SENDMSG: 2124 0 0
      0
      The 2123 (set) failed, and 2124 stayed with original value
      ---------------------
      try to set to 1
      NPP_SENDMSG: 2123 0 1
      0
      and readback what I set
      NPP_SENDMSG: 2124 0 0
      0
      The 2123 (set) failed, and 2124 stayed with original value
      

      With PerlScript

      script:

      print "==========\n";
      print "0,1 => ", notepad->SendMessage( 2123, 0, 1), "\n";
      print "get => ", notepad->SendMessage( 2124, 0, 0), "\n";
      print "1,0 => ", notepad->SendMessage( 2123, 1, 0), "\n";
      print "get => ", notepad->SendMessage( 2124, 0, 0), "\n";
      print "1,1 => ", notepad->SendMessage( 2123, 1, 1), "\n";
      print "get => ", notepad->SendMessage( 2124, 0, 0), "\n";
      print "==========\n";
      

      With dynamic, I get:

      ==========
      0,1 => 0
      get => 0
      1,0 => 0
      get => 0
      1,1 => 0
      get => 0
      ==========
      

      With Constant, I get

      ==========
      0,1 => 0
      get => 1
      1,0 => 0
      get => 1
      1,1 => 0
      get => 1
      ==========
      

      So, the GET message is working okay, but the SET message is not.
      Can others confirm this behavior?
      Or have I just misread the NPPM_SETLINENUMBERWIDTHMODE instructions from the source code, and I’m using it wrong?

      If it’s real, I’ll open a bug report on the new feature, but I wanted to confirm before opening a bug report.

      1 Reply Last reply Reply Quote 1
      • EkopalypseE
        Ekopalypse
        last edited by Ekopalypse

        Is a bug I guess

        	case NPPM_SETLINENUMBERWIDTHMODE:
        		{
        			if (lParam != LINENUMWIDTH_DYNAMIC || lParam != LINENUMWIDTH_CONSTANT)
        				return FALSE;
        

        should be && instead of || , right?

        PeterJonesP 1 Reply Last reply Reply Quote 4
        • EkopalypseE
          Ekopalypse
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Ekopalypse
            last edited by

            @Ekopalypse said in v7.9.2 NPPM_SETLINENUMBERWIDTHMODE:

            Is a bug I guess
            should be && instead of || , right?

            Yes, that would make more sense. I’ll file a bug tomorrow (really hard to do from phone browser)

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

              @PeterJones said in v7.9.2 NPPM_SETLINENUMBERWIDTHMODE:

              I’ll file a bug tomorrow

              #9338

              Thanks for the research, @Ekopalypse

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