Community
    • Login

    Saved terminal text from MobaXTerm not keeping color once opened in Notepad++

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    rtfudl
    6 Posts 3 Posters 3.6k 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.
    • Pro AudioP
      Pro Audio
      last edited by

      Is there a plug-in or way for Notepad++ to have my terminal text output from MobaXTerm display the same (color and format etc) once opened in Notepad++?

      To clarify, when I save my terminal text from MobaXTerm, MobaXTerm by default color codes the text in the terminal which I like.

      If I save the terminal text in rtf and then open the file in Notepad++, I see things in passages like "\par \cf0\highlight0”, “cf1”, “\cf3\f0 v\cf0”. I’m assuming that’s where color/formatting is suppose to be.

      If I save the terminal text in plain text format, I get all the text properly formatted exactly the way it looks in MobaxTerm but with no color.

      If also tried this below (saving the raw data, pasting in Notepad, saving as XML file format, and then importing as UDL in Notepad++ but I only see some text as a blue color not multiple colors like in MobaXTerm.

      https://github.com/nakohdo/NPP.RTF/blob/master/userDefineLang_RTF.xml

      Is there a way to accomplish this? Thanks in advance!

      Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Pro Audio
        last edited by

        @Pro-Audio

        Probably posting a screenshot of MobaXTerm display output here is a good discussion starter.

        Pro AudioP 1 Reply Last reply Reply Quote 0
        • PeterJonesP
          PeterJones @Pro Audio
          last edited by PeterJones

          @Pro-Audio ,

          As Alan said, we can have a more meaningful conversation about meeting your goals once you show us a screenshot of the MobaXTerm text with its colors. However, I have some background/meta information that will help you better understand some things that your phrasing indicates you don’t fully understand.

          The \par and \cf0 and the others are way that RTF-based word-processors save their color and font information, because like HTML, RTF is a text-based format. But when Notepad++ edits RTF (or HTML), it shows you the underlying codes, not the pretty formatted text. (This is by design: it is a text editor, and the codes are part of the text saved in a .rtf file)

          The RTF User Defined Language (UDL) that you imported (*) defines syntax highlighting for the \par and \cf0 and other such codes. But it will not make Notepad++ turn into a Word Processor and show you the rendered RTF (which is the colored text you were hoping to see, if I’ve understood correctly). So that UDL is meant for highlighting the fancy codes in the raw RTF source code, just like the HTML parser highlights the HTML codes, or the default Markdown UDL highlights markdown codes. So to accomplish your goal, saving the RTF and editing in Notepad++ is probably not what you want. (OTOH, if you save the RTF, and open the RTF with a word processor like the free WordPad that comes with Microsoft Windows, it will “look” more like what you saw. That’s part of the philosophical difference between a Word Processor and a Text Editor.)

          *: as an aside, you imported that UDL the hard way. Since the site you linked already has the XML file, you could have just downloaded that file, saved it into %AppData%\Notepad++\userDefineLangs\ folder as userDefineLang_RTF.xml and restarted Notepad++, which would automatically bring in that RTF UDL into Notepad++, without all the extra copy/paste/save/import steps.

          But back to your original problem: in general, if you have something with a list of keywords that will always be made a certain color, or things inside quotes want to be a “quote color”, then it’s really easy to do by defining your own User Defined Language for MobaXTerm. But if MobaXTerm is just outputting things in arbitrary colors, or based on rules other than simple keyword-matches or “in between quotes”, then UDL might not be powerful enough to accomplish your goal (though UDL + EnhanceAnyLexer plugin might be sufficient). Again, until we know more what MobaXTerm output looks like, we cannot give specific advice.

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

            Example from internet search:

            0384f899-5f87-4c1b-818b-ca636102fd29-image.png

            Maybe it provides some idea…but really OP needs to come back and explain what exactly they are looking for.

            1 Reply Last reply Reply Quote 0
            • Pro AudioP
              Pro Audio @Alan Kilborn
              last edited by

              @Alan-KilbornF89D381A-AE3A-407A-AF5E-F186ECB77B85.jpeg 80B7AA64-4677-4152-9FF5-817BE2627F13.jpeg

              These are just some examples of how MobaXTerm looks.

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

                @Pro-Audio ,

                So, looking at the two screenshots, I’m not convinced that Notepad++ & UDL & EnhanceAnyLexer Plugin is really going to give you what you want.

                The “rules” that it uses for highlighting seem pretty arbitrary – for example, in the command apt-get install nano, the nano is not highlighted in the command line, nor one line down after package, but a few lines down, the nano after Package is highlighted. And sometimes the word file is cyan and sometimes purple. That indicates to me that MobaXTerm might just be accepting the colors that the linux tools themselves are setting, rather than performing its own highlighting. And there is virtually no way that we would be able to define a UDL+EnhanceAnyLexer combination that would be able to decide, just from the text, what colors each word should be and have it 100% match what you are seeing in MobaXTerm.

                You could do some things, where you give it a list of keywords like cygwin and libgcc1, etc for cyan coloring, and words like nano and file for purple, then use EnhanceAnyLexer to look for sets of text with no spaces that have multiple / or . between “word” characters… but even that won’t get everything right (like the ellipses not being highlighted). So if you’re looking for exact color match, it’s not going to happen.

                As much as I hate recommending a different tool than Notepad++ for the job in this forum, if you a really looking to keep the exact colors for all words for your linux output copied from MobaXTerm, I think you might best be served saving the RTF output, then opening the RTF file with a word processor like WordPad. (There are times when a Word Processor is the right tool for the job. And Notepad++ is not a Word Processor.)

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