Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Using UDL as default file type?

    Help wanted · · · – – – · · ·
    2
    6
    345
    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.
    • John English
      John English last edited by John English

      I am trying to set up an IDE for students based on portable NPP, which is being used for a language which is not one in the “standard” list. I have defined syntax colouring and so on as a UDL, and everything is working nicely apart from one problem. I would like to use my UDL as the default file type for new files (and thus also give the appropriate file extension), but I can’t find a way to do this. Is there a way to set the default file type to something which is not hard-wired into NPP?

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        PeterJones @John English last edited by

        @john-english ,

        Not at this time. But it’s easy enough to write up a PythonScript that you could call instead of hitting the normal File > New or New File button which would create a new file and associate it with the chosen UDL language.

        And if your Language menu is staying constant (not changing frequently), you could even make it a macro instead – you would need one action in the macro for the File > New (which you could get by recording a macro and saving that macro), then adding another call to set the language (the language-menu entries are not macro-recordable, for historical reasons)

        For example, UI Spy plugin tells me that in my normal Notepad++ installation, Markdown (preinstalled) UDL is 46182.
        87cb1989-8da3-4cd8-ab00-2da1735c3340-image.png

        I then can create a macro in my shortcuts.xml:

                <Macro name="NewMarkdown" Ctrl="no" Alt="no" Shift="no" Key="0">
                    <Action type="2" message="0" wParam="41001" lParam="0" sParam="" />
                    <Action type="2" message="0" wParam="46182" lParam="0" sParam="" />
                </Macro>
        

        When I reload Notepad++ and run Macro > NewMarkdown, it creates a new file, and tells it to use Markdown (preinstalled). And then when I save that file, it will default to markdown’s default .md from the UDL settings.

        You can use Macro > Modify Shortcut to assign a shortcut to that (even the standard Ctrl+N, as long as you change File > New to not use Ctrl+N)

        Since your students’ installs are all going to be setup by you originally, I would bet that the menuCmdID will be the same for your UDL on all their machines, so I think it would work for you.

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

          @peterjones
          OK. I wanted this to just happen automatically when they start up NPP. At the moment it starts up with a tab labelled “new1” using C++ as the default language, and it does C++ syntax colouring when they start typing into it. The students will then have to click on my UDL in the language menu to get the right syntax colouring before they do anything else. Thanks for the suggestion, but it doesn’t really help in this situation AFAICS.

          PeterJones 1 Reply Last reply Reply Quote 0
          • PeterJones
            PeterJones @John English last edited by

            @john-english said in Using UDL as default file type?:

            t doesn’t really help in this situation AFAICS.

            Possibly not. At which point, my other suggestion (PythonScript) would help. (make sure ATSTARTUP is selected; add code or a call in the user startup.py that sets the language to your UDL if the file is new 1 and empty)

            John English 1 Reply Last reply Reply Quote 1
            • John English
              John English @PeterJones last edited by John English

              @peterjones
              OK, thanks, I’ll give it a whirl.

              PeterJones 1 Reply Last reply Reply Quote 0
              • Referenced by  PeterJones PeterJones 
              • PeterJones
                PeterJones @John English last edited by PeterJones

                @john-english and others reading this discussion:

                I have submitted #11097 Allow UDLs in Default Language, due to this discussion and another recent one. (As well as the related #11096 Allow UDLs in SaveAs, which should also make dealing with UDLs easier)

                I cannot guarantee that anything will happen as a result of those issues, but they’ve at least been submitted. And anyone reading this discussion who agrees that one or more of those is a good idea is free to go upvote or comment on those issues.

                1 Reply Last reply Reply Quote 2
                • First post
                  Last post
                Copyright © 2014 NodeBB Forums | Contributors