Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new filetypes for developer file preview #17183

Merged
merged 15 commits into from
Apr 14, 2022

Conversation

Aaron-Junker
Copy link
Collaborator

@Aaron-Junker Aaron-Junker commented Mar 21, 2022

Summary of the Pull Request

What is this about:

What is included in the PR:

  • Preview for reg files (self written!)
  • New extensions for XML preview: ".xslt", ".xsd", ".wsdl"
  • New extensions for c++ preview: ".ino", ".pde"
  • New extension for cshtml preview: ".razor"

A system to add costum file types. Only downside is that you have to copy paste the language definitions into monacoSpecialLanguages.js

How does someone test / validate:

Install and test with new file types

Quality Checklist

Contributor License Agreement (CLA)

A CLA must be signed. If not, go over here and sign the CLA.

@Aaron-Junker
Copy link
Collaborator Author

@stefansjfw Could you please make the installer stuff:

  • Including "costumLanguages" folder
  • Including "monacoSpecialLanguages.js"

This would be very nice.

@stefansjfw
Copy link
Collaborator

@stefansjfw Could you please make the installer stuff:

  • Including "costumLanguages" folder
  • Including "monacoSpecialLanguages.js"

This would be very nice.

Sure. Could you please rebase this work on top of latest main?

@htcfreek
Copy link
Collaborator

@Aaron-Junker
Are the words marked by spell checker predefined or can we change casing here to lowerCamelCase?

@Aaron-Junker
Copy link
Collaborator Author

Aaron-Junker commented Mar 23, 2022

@stefansjfw I main master in

@htcfreek
Copy link
Collaborator

htcfreek commented Mar 29, 2022

Regarding reg format:
Can you define special colored elements? Then we could color keys/values to delete in red. (I suggest to color the whole line in red like np++ does for deleted keys.

Delete key

[-hklm\key-to-delete]

Delete value

"value-to-delete"=-

And let's have the constants in purple to look different in all color modes.

Btw. there is a test wep page you can use to validate your colors.

@Aaron-Junker
Copy link
Collaborator Author

Regarding reg format:
Can you define special colored elements? Then we could color keys/values to delete in red. (I suggest to color the whole line in red like np++ does for deleted keys.

Delete key

[-hklm\key-to-delete]

Delete value

"value-to-delete"=-

Tjis should be possible. Thanks for the suggestion.

And let's have the constants in purple to look different in all color modes.

Btw. there is a test wep page you can use to validate your colors.

I can't define the color just the type of a element.

@GitMensch
Copy link

A note in doc/devdocs/modules/powerpreview/monaco/readme.md about how to add languages which don't have a reasonable mapping for in monaco would be good (likely "add to monaco first", but I haven't found information on that either).

@Aaron-Junker
Copy link
Collaborator Author

A note in doc/devdocs/modules/powerpreview/monaco/readme.md about how to add languages which don't have a reasonable mapping for in monaco would be good (likely "add to monaco first", but I haven't found information on that either).

I agree. Will look what I can provide. What did you want to integrate?

@GitMensch
Copy link

What did you want to integrate?

Whatever I stumble over :-)
Form my current source tree:

COBOL (.cob/.cbl) would likely be "totally new";
autoconf (.ac, .at; which may be aliased to .m4 if that exists, but that isn't highlighted so far)

Side note: if ".in" isn't aliased to .txt altrit should be added, too, similar for .rc (I may have a manual provider as text setup, would need to check); automake (.am) should be aliased to Makefile; .sln + .vcxproj may be aliased to xml if there's no better match;

@Aaron-Junker
Copy link
Collaborator Author

Will this also handle .xslt? We use .xsl for html pages using xsl and .xslt for other transformation. Thanks for adding these!

I will add these too,

@GitMensch
Copy link

Looks like I've asked in the wrong post, please add ".log", ".err", ".out" as text to fix #17506.

@Aaron-Junker Aaron-Junker marked this pull request as ready for review April 10, 2022 15:47
@Aaron-Junker
Copy link
Collaborator Author

@htcfreek I added your suggestions.
image

@stefansjfw This is now ready for review

@Aaron-Junker
Copy link
Collaborator Author

I will add the docs later

@microsoft microsoft deleted a comment from github-actions bot Apr 10, 2022
@microsoft microsoft deleted a comment from github-actions bot Apr 10, 2022
@microsoft microsoft deleted a comment from github-actions bot Apr 10, 2022
@microsoft microsoft deleted a comment from github-actions bot Apr 10, 2022
@htcfreek
Copy link
Collaborator

htcfreek commented Apr 10, 2022

@Aaron-Junker
What do you think about this:

image
image
image

return {
        tokenPostfix: '.reg',
        tokenizer: {
            root: [
                // Header (case sensitive)
                [/Windows Registry Editor Version 5.00/, 'comment'],
                [/REGEDIT4/, 'comment'],
                // Comments
                [/;.*/, "comment"],
                // Keys
                [/\[\-.*\]/, 'invalid'],
                [/\\.*[^\]]/, 'keyword'],
                // Values
                [/@/, "keyword"],
                [/\".*\"=\-/, "invalid"],
                [/\".*\"(?=\=)/, "keyword"],
                [/\".*\"(?!\=)/, 'string'],
                [/((hex\({0,1}[0-9,a,b]*\){0,1})|dword):.*/, "string"],
                // Hive names (case in-sensitive)
                [/HKEY_CLASSES_ROOT/, 'type'],
                [/HKEY_LOCAL_MACHINE/, 'type'],
                [/HKEY_USERS/, 'type'],
                [/HKEY_CURRENT_USER/, 'type'],
                [/HKEY_PERFORMANCE_DATA/, 'type'],
                [/HKEY_DYN_DATA/, 'type'],
                [/hkey_classes_root/, 'type'],
                [/hkey_local_machine/, 'type'],
                [/hkey_users/, 'type'],
                [/hkey_current_user/, 'type'],
                [/hkey_performance_data/, 'type'],
                [/hkey_dyn_data/, 'type'],
                // Symbols (For better contrast on hc-black)
                [/=/, 'delimiter'],
                [/\[/, 'delimiter'],
                [/]/, 'delimiter'],
            ]
        }
    }

@htcfreek
Copy link
Collaborator

Or with special color for value type:
image

return {
        tokenPostfix: '.reg',
        tokenizer: {
            root: [
                // Header (case sensitive)
                [/Windows Registry Editor Version 5.00/, 'comment'],
                [/REGEDIT4/, 'comment'],
                // Comments
                [/;.*/, "comment"],
                // Keys
                [/\[\-.*\]/, 'invalid'],
                [/\\.*[^\]]/, 'keyword'],
                // Values
                [/@/, "keyword"],
                [/\".*\"=\-/, "invalid"],
                [/\".*\"(?=\=)/, "keyword"],
                [/\".*\"(?!\=)/, 'string'],
                [/hex\({0,1}[0-9,a,b]\)|hex|dword(?=\:)/, "type"],
                [/[0-9,a-f,A-F][0-9,a-f,A-F],*/, 'string'],
                // Hive names (case in-sensitive)
                [/HKEY_CLASSES_ROOT/, 'type'],
                [/HKEY_LOCAL_MACHINE/, 'type'],
                [/HKEY_USERS/, 'type'],
                [/HKEY_CURRENT_USER/, 'type'],
                [/HKEY_PERFORMANCE_DATA/, 'type'],
                [/HKEY_DYN_DATA/, 'type'],
                [/hkey_classes_root/, 'type'],
                [/hkey_local_machine/, 'type'],
                [/hkey_users/, 'type'],
                [/hkey_current_user/, 'type'],
                [/hkey_performance_data/, 'type'],
                [/hkey_dyn_data/, 'type'],
                // Symbols (For better contrast on hc-black)
                [/=/, 'delimiter'],
                [/\[/, 'delimiter'],
                [/]/, 'delimiter'],
                [/:/, 'delimiter'],
            ]
        }
    }

@Aaron-Junker
Copy link
Collaborator Author

Or with special color for value type:
image

return {
        tokenPostfix: '.reg',
        tokenizer: {
            root: [
                // Header (case sensitive)
                [/Windows Registry Editor Version 5.00/, 'comment'],
                [/REGEDIT4/, 'comment'],
                // Comments
                [/;.*/, "comment"],
                // Keys
                [/\[\-.*\]/, 'invalid'],
                [/\\.*[^\]]/, 'keyword'],
                // Values
                [/@/, "keyword"],
                [/\".*\"=\-/, "invalid"],
                [/\".*\"(?=\=)/, "keyword"],
                [/\".*\"(?!\=)/, 'string'],
                [/hex\({0,1}[0-9,a,b]\)|hex|dword(?=\:)/, "type"],
                [/[0-9,a-f,A-F][0-9,a-f,A-F],*/, 'string'],
                // Hive names (case in-sensitive)
                [/HKEY_CLASSES_ROOT/, 'type'],
                [/HKEY_LOCAL_MACHINE/, 'type'],
                [/HKEY_USERS/, 'type'],
                [/HKEY_CURRENT_USER/, 'type'],
                [/HKEY_PERFORMANCE_DATA/, 'type'],
                [/HKEY_DYN_DATA/, 'type'],
                [/hkey_classes_root/, 'type'],
                [/hkey_local_machine/, 'type'],
                [/hkey_users/, 'type'],
                [/hkey_current_user/, 'type'],
                [/hkey_performance_data/, 'type'],
                [/hkey_dyn_data/, 'type'],
                // Symbols (For better contrast on hc-black)
                [/=/, 'delimiter'],
                [/\[/, 'delimiter'],
                [/]/, 'delimiter'],
                [/:/, 'delimiter'],
            ]
        }
    }

I love it. Thank you so much.

Copy link
Collaborator

@stefansjfw stefansjfw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you test this?

I tried building installer and installing PT and monaco doesn't work even for old file types..

@Aaron-Junker
Copy link
Collaborator Author

How did you test this?

I tried building installer and installing PT and monaco doesn't work even for old file types..

I added the files and registry keys manually. I will look why this happens.

@stefansjfw
Copy link
Collaborator

How did you test this?
I tried building installer and installing PT and monaco doesn't work even for old file types..

I added the files and registry keys manually. I will look why this happens.

Sorry, my bad. You already asked for installer stuff and I somehow though I already did that. Here it is..

@stefansjfw
Copy link
Collaborator

@Aaron-Junker Can you try the installer now and all new extensions? For me e.g. xslt doesn't seem to work, but wsdl works for some reason..

@Aaron-Junker
Copy link
Collaborator Author

@Aaron-Junker Can you try the installer now and all new extensions? For me e.g. xslt doesn't seem to work, but wsdl works for some reason..

I forgot to generate a new monaco_languages.json file after adding xslt.

@Aaron-Junker
Copy link
Collaborator Author

How did you test this?
I tried building installer and installing PT and monaco doesn't work even for old file types..

I added the files and registry keys manually. I will look why this happens.

Sorry, my bad. You already asked for installer stuff and I somehow though I already did that. Here it is..

Thanks.

@htcfreek
Copy link
Collaborator

@Aaron-Junker
let's add this page to our docs: https://microsoft.github.io/monaco-editor/monarch.html

@Aaron-Junker
Copy link
Collaborator Author

@htcfreek As I stated above

I will add the docs later

@Aaron-Junker Aaron-Junker changed the title [WIP] Adding new filetypes for developer file preview Adding new filetypes for developer file preview Apr 11, 2022
@stefansjfw
Copy link
Collaborator

@Aaron-Junker Can you try the installer now and all new extensions? For me e.g. xslt doesn't seem to work, but wsdl works for some reason..

I forgot to generate a new monaco_languages.json file after adding xslt.

this is still TBD, right ?

@Aaron-Junker
Copy link
Collaborator Author

@Aaron-Junker Can you try the installer now and all new extensions? For me e.g. xslt doesn't seem to work, but wsdl works for some reason..

I forgot to generate a new monaco_languages.json file after adding xslt.

this is still TBD, right ?

Forgot about it. Should be ready now.

Copy link
Collaborator

@stefansjfw stefansjfw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. nice work

@jaimecbernardo jaimecbernardo merged commit d9c8d8d into main Apr 14, 2022
@Aaron-Junker Aaron-Junker deleted the user/aaron-junker/monaco-new-languages branch April 14, 2022 14:32
@htcfreek
Copy link
Collaborator

htcfreek commented May 4, 2022

isn't this shipped with 0.58.0?

@Aaron-Junker
Copy link
Collaborator Author

isn't this shipped with 0.58.0?

Yes why?

@htcfreek
Copy link
Collaborator

htcfreek commented May 4, 2022

isn't this shipped with 0.58.0?

Yes why?

Didn't work for me. .reg is not shown with dev preview. It's shown as plain text with I think default provider.

@Aaron-Junker
Copy link
Collaborator Author

isn't this shipped with 0.58.0?

Yes why?

Didn't work for me. .reg is not shown with dev preview. It's shown as plain text with I think default provider.

Open a new issue. I will look this this weekend what is going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants