Community
    • Login

    MIB file (SNMP) syntax highlighting [User Defined Language]

    Scheduled Pinned Locked Moved General Discussion
    9 Posts 7 Posters 3.9k 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.
    • unknown14725U
      unknown14725
      last edited by unknown14725

      I work on a lot of SNMP projects where I need to read MIB files. I could not find a UDL for MIB files anywhere on the net, but I found a few forum posts here and there where people request it. In the end I decided to make one for personal use, and figured i might as well share it.

      Download here: pastebin.com (save as i.e. userDefineLang-MIB.xml, and place in directory .\Notepad++\userDefineLangs)

      2019-10-16 08_21_03-HOST-RESOURCES-MIB-rfc2790.txt - Notepad++.png

      It’s very rough around the edges, and does not do folding (I could not get it to work due to the complexity of delimiters in ASN.1). It’s purely for visual syntax highlighting to ease on-screen reading of MIB files.

      gstaviG 1 Reply Last reply Reply Quote 4
      • Vincent DuvernetV
        Vincent Duvernet
        last edited by

        wonderful :) I was looking for MIB/SNMP compatibility today :)

        But the BackColor is not working associated to DarkTheme :
        [https://github.com/Ludomancer/VS2015-Dark-Npp](link url)

        Michael VincentM 2 Replies Last reply Reply Quote 0
        • PeterJonesP
          PeterJones
          last edited by

          @Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

          But the BackColor is not working associated to DarkTheme

          User Defined Languages do not honor themes: if you change your theme, it does not change the coloring for the UDL syntax highlighter. You can use Language > User Defined Language > Define Your Language… to change the colors for your specific UDL.

          1 Reply Last reply Reply Quote 2
          • Michael VincentM
            Michael Vincent @Vincent Duvernet
            last edited by

            @Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

            wonderful :) I was looking for MIB/SNMP compatibility today :)

            Why use a UDL? The default theme already has ASN.1 and that can be copied into (and adjusted for color) into your preferred theme (as @PeterJones mentions). I did this for Obsidian Theme which I use exclusively.

            You may need to associate your MIB extension with ASN.1 for Notepad++ to recognize the file on opening:

            Settings => Style Configurator… =>

            3540c3c6-4fb9-4c15-a9c3-dccd5f2c4d6e-image.png

            Cheers.

            1 Reply Last reply Reply Quote 3
            • Michael VincentM
              Michael Vincent @Vincent Duvernet
              last edited by

              @Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

              wonderful :) I was looking for MIB/SNMP compatibility today :)

              You may also want it in the function list. I’ve added in my $(NPP_INSTALL_DIR)/functionList.xml file:

               <association id="asn1_syntax" langID="65"  />
              

              […] then down in the parsers section:

              <!-- ============== [ ASN.1 ] -->
              
              <parser
              	displayName="ASN.1"
              	id         ="asn1_syntax"
              	commentExpr="(?x)
              					(?m-s:\-\-.*$)    # Single Line Comment
              				"
              >
              
              	<classRange mainExpr="(?:^\s*\w+\s+::=\s+[\w-]+\s*)">
              		<className>
              			<nameExpr expr="(?:\s*)\K[\w]+"/>
              		</className>
              		<function
              			mainExpr="(?:^\s*\w+\s+)">
              			<functionName>
              				<funcNameExpr expr="(?:\s*)\K[\w]+"/>
              			</functionName>
              		</function>
              	</classRange>
              	<function
              		mainExpr="(?:^\s*\w+\s+OBJECT-\w+[\n\s]*)">
              		<functionName>
              			<nameExpr expr="(?:\s*)\K[\w]+"/>
              		</functionName>
              	</function>
              </parser>
              

              Cheers.

              1 Reply Last reply Reply Quote 2
              • Joshua From VietnamJ
                Joshua From Vietnam
                last edited by

                @vincent-duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

                wonderful :) I was looking for MIB/SNMP compatibility today :)

                But the BackColor is not working associated to DarkTheme :

                Just stumbled on this UDL but you’re right it doesn’t come up very well in Dark Mode.

                So I tweaked it for DM here: at pastebin, with the URL: zC7fCauP

                (Sorry for the lack of a hyperlink, spam filters were blocking me.)

                Hope it can be useful.
                Cheers

                1 Reply Last reply Reply Quote 0
                • gstaviG
                  gstavi @unknown14725
                  last edited by

                  @unknown14725
                  Long ago I worked with MIB files for ~1 year and wrote the lexamples plugin that provides MIB files and GNU Makefiles lexing.
                  This is an external DLL lexer, not user defined language.

                  I used it for writing GNU Makefiles for years. I haven’t touched MIB for 7 years.

                  Haven’t used it for a while, it is possible that it was broken in latest NPP version but it should be possible to test the lexing quality with old NPP version. If the lexing is superior we could consider porting it to newer NPP version.

                  Source code

                  rdipardoR 1 Reply Last reply Reply Quote 3
                  • rdipardoR
                    rdipardo @gstavi
                    last edited by

                    @gstavi,

                    Haven’t used it for a while, it is possible that it was broken in latest NPP version

                    This definitely won’t work:

                    ILexer *LexerMib::LexerFactoryMib()
                    {
                      return new LexerMib;
                    }
                    
                    ILexer *lexamples_create_mib_lexer()
                    {
                      return LexerMib::LexerFactoryMib();
                    }
                    

                    As other plugin developers are finding out, Scintilla 5 moved the lexer interface to the Lexilla library. The new API is ultimately better for external lexers — basically, every lexer is external now — once you get the hang of it.

                    gstaviG 1 Reply Last reply Reply Quote 3
                    • gstaviG
                      gstavi @rdipardo
                      last edited by

                      @rdipardo said in MIB file (SNMP) syntax highlighting [User Defined Language]:

                      This definitely won’t work:

                      That is why I said “test the lexing quality with old NPP version”.
                      if there is interest, I may invest the time. Or since the source code is available then maybe someone else will take over.

                      If everyone is happy with UDL, great.

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