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

Add profiles.json schema to doc folder #2704

Merged
merged 10 commits into from
Sep 27, 2019

Conversation

cinnamon-msft
Copy link
Contributor

@cinnamon-msft cinnamon-msft commented Sep 9, 2019

Summary of the Pull Request

Updated the JSON schema referenced in #1003
Adding it to our repo so we can reference it in the profiles.json file

References

#1003

PR Checklist

  • Closes profile.json should have a schema #1003
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

@cinnamon-msft cinnamon-msft requested a review from a team September 9, 2019 20:21
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

I don't think any of these comments rise above the level of "nit"

"definitions": {
"Color": {
"default": "#",
"pattern": "^#[A-Fa-f0-9]{6}$",
Copy link
Member

Choose a reason for hiding this comment

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

This can actually be a #rgb color now as well

"pattern": "^#[A-Fa-f0-9]{6}$",
"type": "string"
},
"ProfileKey": {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"ProfileKey": {
"ProfileGuid": {

maybe?

"type": "string"
},
"ProfileKey": {
"default": "{}",
Copy link
Member

Choose a reason for hiding this comment

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

I'm not totally sure this is true, but I'm not sure what a better way to put this would be

"keys": {
"description": "Defines the key combinations used to call the command.",
"items": {
"pattern": "^(ctrl\\+|alt\\+|shift\\+){0,3}([0-9a-zA-Z]|backspace|tab|enter|esc|space|pgup|pgdn|end|home|left|up|right|down|insert|delete|numpad_([0-9]|multiply|plus|minus|period|divide)|f[1-9]|f1[0-9]|f2[0-4]|plus|,|-|\\.)$",
Copy link
Member

Choose a reason for hiding this comment

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

holy regular expression batman

Copy link
Contributor

Choose a reason for hiding this comment

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

i am extremely alarmed about this pattern.

Copy link
Contributor

Choose a reason for hiding this comment

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

also, this pattern is hyper-specific (backspace, tab, enter, etc.), but it misses out on all the extended keys like {}[]_+-=|\\

also, this pattern allows ctrl+ctrl+ctrl+c

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe I can help with this one @cinnamon_msft - Question - should we force the use of at least one modifier through regex? Else we're letting people redefine things like Enter, for example.

Copy link
Contributor

Choose a reason for hiding this comment

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

people actually want enter, now that a failed keybinding dispatch can pass through. As a binding for copy, it'll copy if there's a selection or send a CR if there isn't.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you want me to alter the logic, let me know. Regex101 is an excellent tool and will explain how the expression works, but it does take a certain twisted effort to comprehend, and for many people regex is a write-only exercise so if it's hurting everyone's brains, that's okay with me lol

Copy link
Collaborator

Choose a reason for hiding this comment

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

I put out a Twitter challenge to improve it: https://twitter.com/oising/status/1172226517331525632 -- maybe we can make it even less readable / compact

Copy link
Member

Choose a reason for hiding this comment

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

@oising I'm glad to see another regex lover is around 😁. I've just been caught up with how to make CTRL+, ALT+, and SHIFT+ not repeat (as Dustin aluded to the CTRL+CTRL+CTRL+C issue above).

At least we only need to solve this problem once, so as ugly as it gets, we'll never have to touch it again 🤞

Copy link
Collaborator

@oising oising Sep 12, 2019

Choose a reason for hiding this comment

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

Yeah, it's only really possible with lookbehind assertions (to prevent dupes), and it's also lucky we're using javascript since PCRE only supports fixed width assertions, though .NET added lookbehind assertions specifically. I don't know if it support backreferences though. Another thing to think about was possibly using subroutines (to possibly add some feel-good DRY), but man, I only had 20 minutes :D

Copy link
Collaborator

@oising oising Sep 12, 2019

Choose a reason for hiding this comment

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

So yeah, just for information, a subroutine call lets you "call" a previous capture group from later in the expression, but in the later context. It's not supported in javascript it seems, but if it was, we could remove the second and third modifier capture group, and just refer to the first one by its index with (?2):

^(?<modifier>(ctrl|alt|shift)\+?((?2)(?<!\2)\+?)?((?2)(?<!\2|\4))?\+?)?(?<key>\w+?)?(?<=\w)$

"description": "Sets the background color of the profile. Overrides background set in color scheme if colorscheme is set. Uses hex color format: \"#rrggbb\". Default \"#000000\" (black)."
},
"backgroundImage": {
"description": "(Not in SettingsSchema.md)",
Copy link
Member

Choose a reason for hiding this comment

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

todo?

},
"colorScheme": {
"default": "Campbell",
"description": "Name of the terminal color scheme to use. Color schemes are defined under schemes.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Name of the terminal color scheme to use. Color schemes are defined under schemes.",
"description": "Name of the terminal color scheme to use. Color schemes are defined under \"schemes\".",

"type": "string"
},
"connectionType": {
"$ref": "#/definitions/ProfileKey",
Copy link
Member

Choose a reason for hiding this comment

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

Oh maybe this should just be Guid

Copy link
Contributor

Choose a reason for hiding this comment

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

yes we need a separate guid type

},
"connectionType": {
"$ref": "#/definitions/ProfileKey",
"default": "{d9fcfdfa-a479-412c-83b7-c5640e61cd62}",
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this not have a default, as I'm pretty sure the default is the null guid?

Copy link
Contributor

Choose a reason for hiding this comment

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

ABSOLUTELY NOT

@zadjii-msft zadjii-msft added the Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs label Sep 9, 2019
{
"$id": "https://github.com/microsoft/terminal/terminal.profile.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Microsoft Terminal Profile Settings",
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be "Microsoft's Windows Terminal Settings Profile Schema" or similar?

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Sep 10, 2019
@@ -0,0 +1,449 @@
{
"$id": "https://github.com/microsoft/terminal/terminal.profile.schema.json",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know what the $id is supposed to represent, but this is not a valid URL

"title": "Microsoft Terminal Profile Settings",
"definitions": {
"Color": {
"default": "#",
Copy link
Contributor

Choose a reason for hiding this comment

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

What does # mean as a default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When editing the profiles.json, it'll auto-fill the "#" for the color code

"properties": {
"globals": {
"additionalProperties": false,
"description": "Properties affect the entire window, regardless of the profile settings.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"description": "Properties affect the entire window, regardless of the profile settings.",
"description": "Properties that affect the entire window, regardless of the profile settings.",

"properties": {
"alwaysShowTabs": {
"default": true,
"description": "When set to true, tabs are always displayed. When set to false and showTabsInTitlebar is set to false, tabs only appear after typing Ctrl + T.",
Copy link
Contributor

Choose a reason for hiding this comment

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

after "opening a new tab" (since it can be rebound)

},
"defaultProfile": {
"$ref": "#/definitions/ProfileKey",
"description": "Sets the default profile. Opens by typing Ctrl + T or by clicking the '+' icon. The guid of the desired default profile is used as the value."
Copy link
Contributor

Choose a reason for hiding this comment

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

note about the new tab binding again

doc/cascadia/profiles.schema.json Show resolved Hide resolved
"type": "string"
},
"scrollbarState": {
"description": "Defines the visibility of the scrollbar. Possible values: \"visible\", \"hidden\"",
Copy link
Contributor

Choose a reason for hiding this comment

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

default

"type": "boolean"
},
"startingDirectory": {
"default": "%USERPROFILE%",
Copy link
Contributor

Choose a reason for hiding this comment

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

this is actually not the default, we just .. faked it into being default. if they remove it, the default is "the current directory"

}
},
"required": [
"acrylicOpacity",
Copy link
Contributor

Choose a reason for hiding this comment

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

only guid, colorScheme, commandline and name are required.

"$ref": "#/definitions/Color",
"description": "Sets the color used as ANSI green."
},
"name": {
Copy link
Contributor

Choose a reason for hiding this comment

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

move name up

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Sep 11, 2019
@DHowett-MSFT
Copy link
Contributor

notes from use: source is allowed in profile, globals is not required (all globals objects can be merged with the root optionally), and name or guid are the only truly required fields for Profile as of #754.

@DHowett-MSFT
Copy link
Contributor

DHowett-MSFT commented Sep 20, 2019

and key bindings fail to validate for \ and | and all symbols; suggest widening \w to [^+\s] (all characters that are not plus or space)

@DHowett-MSFT
Copy link
Contributor

For the key bindings, ^(?<modifier>(ctrl|alt|shift)\+?((ctrl|alt|shift)(?<!\2)\+?)?((ctrl|alt|shift)(?<!\2|\4))?\+?)?(?<key>[^+\s]+?)?(?<=[^+\s])$ works (needs escaping again)

doc/cascadia/SettingsSchema.md Outdated Show resolved Hide resolved
doc/cascadia/profiles.schema.json Outdated Show resolved Hide resolved
"profiles",
"schemes"
],
"type": "object"
Copy link
Contributor

Choose a reason for hiding this comment

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

we still have the problem where defaultProfile can be inside globals or outside of it, keybindings can be inside globals or outside, etc.
Anything that can exist in globals can also exist outside of globals, so we need some sort of reusable object mapping that says so.

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Sep 24, 2019
Co-Authored-By: Dustin L. Howett (MSFT) <[email protected]>
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Sep 24, 2019
Co-Authored-By: Dustin L. Howett (MSFT) <[email protected]>
"default": false,
"description": "When set to true, the window will have an acrylic background. When set to false, the window will have a plain, untextured background.",
"type": "boolean"
}
Copy link

Choose a reason for hiding this comment

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

The "hidden" property is missing.

Suggested change
}
},
"hidden": {
"default": false,
"description": "If set to true, the profile will not appear in the list of profiles. This can be used to hide default profiles and dynamicially generated profiles, while leaving them in your settings file.",
"type": "boolean"
}

@DHowett-MSFT
Copy link
Contributor

@bitcrazed i'm dismissing your review because you left one comment and it's since been fixed.

@cinnamon-msft cinnamon-msft merged commit 258c8b4 into master Sep 27, 2019
@cinnamon-msft cinnamon-msft deleted the cinnamon/add-schema-to-docs branch January 30, 2020 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

profile.json should have a schema
7 participants