• Login
Community
  • Login

why SCI_APPENDTEXT changed NPP default background?

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
5 Posts 3 Posters 537 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.
  • G
    glandon
    last edited by Apr 21, 2024, 12:00 PM

    Maybe something wrong, i didn’t get the root cause.

    986d3770-3539-42c6-884c-27249c60ff6a-image.png

    G P R 3 Replies Last reply Apr 21, 2024, 12:01 PM Reply Quote 0
    • G
      glandon @glandon
      last edited by Apr 21, 2024, 12:01 PM

      bool appendLogToNpp(std::string &log) {
      if (log.empty()){
      return true;
      }

      int bufID = ::SendMessage(g_nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0);
      if (g_curBufferID != bufID) {
          return false;
      }
      
      // Get the current scintilla
      int which = -1;
      ::SendMessage(g_nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&which);
      if (which == -1) {
          return false;
      }
      HWND curScintilla = (which == 0)?g_nppData._scintillaMainHandle:g_nppData._scintillaSecondHandle;
      
      ::SendMessage(curScintilla, SCI_APPENDTEXT, log.length(), (LPARAM)log.c_str());
      //::PostMessage(curScintilla, SCI_SCROLLTOEND, 0, 0);
      ::SendMessage(curScintilla, SCI_GOTOPOS, ::SendMessage(curScintilla, SCI_GETLENGTH, 0, 0), 0);
      return true;
      

      }

      1 Reply Last reply Reply Quote 0
      • P
        PeterJones @glandon
        last edited by PeterJones Apr 21, 2024, 5:46 PM Apr 21, 2024, 3:35 PM

        @glandon ,

        Given the bright orange, I am wondering if you have triggered the change-history feature, but don’t have all the change-history colors in your active theme.

        See the Settings > Preferences > Margins/Borders/Edge > Change History options, as well as Settings > Style Configurator > Global Styles for Change History Margin and, lower down in the same section, Change History modified, Change History revert modified, Change History revert origin, and Change History saved

        Whether the latter of those are available depends on which version of Notepad++ you have, and whether your stylers.xml or theme has been updated to include those settings; if you have a recent Notepad++ and it doesn’t have those, you may have to update your stylers.xml or your theme from stylers.model.xml. (The User Manual has a section called “upgrading a portable edition ”… but as the note at the bottom of that section says, the same procedure is useful for bringing over new settings from stylers.model.xml into stylers.xml or your theme, as well.)

        But maybe I’m wrong, and it really is something weird going on with SCI_APPENDTEXT and your plugin’s code specifically, in which case someone else would have to step in to help you, because I’m not a plugin developer.

        1 Reply Last reply Reply Quote 2
        • R
          rdipardo @glandon
          last edited by Apr 22, 2024, 9:30 AM

          @glandon said in why SCI_APPENDTEXT changed NPP default background?:

          Maybe something wrong, i didn’t get the root cause.

          This looks like the same issue as the one discussed here.

          The plugin needs to set the change history margin to a non-zero width, as demonstrated here.

          G 1 Reply Last reply Apr 22, 2024, 3:43 PM Reply Quote 2
          • G
            glandon @rdipardo
            last edited by Apr 22, 2024, 3:43 PM

            @rdipardo Perfect, with your guide, my code works well again, thanks!

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