From af079d101de33c491fd481d02fcd4fd6d94b6243 Mon Sep 17 00:00:00 2001 From: John Patterson Date: Sun, 22 Jul 2018 09:33:49 -0700 Subject: [PATCH 1/3] adds settings for inactive region font & bg color This adds the inactiveRegionFontColor and inactiveRegionBackgroundColor settings. If a preprocessor block is found to be inactive, it will be colored by these fields if they are set. They accept hexadecimal font strings or valid theme colors as their values.These fields also interactive with the dimInactiveRegions setting. This was requested in issue https://github.com/Microsoft/vscode-cpptools/issues/2212. --- Extension/CHANGELOG.md | 3 ++- Extension/package.json | 12 ++++++++++++ Extension/src/LanguageServer/client.ts | 2 ++ Extension/src/LanguageServer/settings.ts | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index 478055e6c..1c77f95ae 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,6 +1,6 @@ # C/C++ for Visual Studio Code Change Log -## Version 0.17.7: July 19, 2018 +## Version 0.17.7: July 22, 2018 * Fix `Go to Definition` for code scoped with an aliased namespace. [#387](https://github.com/Microsoft/vscode-cpptools/issues/387) * Fix incorrect IntelliSense errors with template template-arguments. [#1014](https://github.com/Microsoft/vscode-cpptools/issues/1014) * Fix crash when using designated initializer lists. [#1440](https://github.com/Microsoft/vscode-cpptools/issues/1440) @@ -24,6 +24,7 @@ * Add a setting to silence configuration provider warnings. [#2292](https://github.com/Microsoft/vscode-cpptools/issues/2292) * Fix for debugging async Visual C++ causing debugger to hang. * Fix `main` snippet. +* Add `inactiveRegionFontColor` and `inactiveRegionBackgroundColor` to settings. [#2212](https://github.com/Microsoft/vscode-cpptools/issues/2212) ## Version 0.17.6: July 2, 2018 * Fix the database icon getting stuck with recursive includes. [#2104](https://github.com/Microsoft/vscode-cpptools/issues/2104) diff --git a/Extension/package.json b/Extension/package.json index 924330524..1b2c3a551 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -154,6 +154,18 @@ "minimum": 0.1, "maximum": 1 }, + "C_Cpp.inactiveRegionFontColor": { + "type": "string", + "default": null, + "description": "Controls the font coloring of inactive preprocessor blocks. Input is in the form a hexidecimal color code or a valid Theme Color. If not set, this defaults to the syntax coloring scheme of the editor. This setting only applies when inactive region dimming is enabled.", + "scope": "resource" + }, + "C_Cpp.inactiveRegionBackgroundColor": { + "type": "string", + "default": null, + "description": "Controls the background coloring of inactive preprocessor blocks. Input is in the form a hexidecimal color code or a valid Theme Color. If not set, this defaults to transparent. This setting only applies when inactive region dimming is enabled.", + "scope": "resource" + }, "C_Cpp.formatting": { "type": "string", "enum": [ diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index c3af87f00..d6ce32b91 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -840,6 +840,8 @@ class DefaultClient implements Client { let decoration: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType({ opacity: settings.inactiveRegionOpacity.toString(), + backgroundColor: settings.inactiveRegionBackgroundColor, + color: settings.inactiveRegionFontColor, rangeBehavior: vscode.DecorationRangeBehavior.ClosedOpen }); diff --git a/Extension/src/LanguageServer/settings.ts b/Extension/src/LanguageServer/settings.ts index 738f8f402..c1ad24221 100644 --- a/Extension/src/LanguageServer/settings.ts +++ b/Extension/src/LanguageServer/settings.ts @@ -41,6 +41,8 @@ export class CppSettings extends Settings { public get errorSquiggles(): string { return super.Section.get("errorSquiggles"); } public get dimInactiveRegions(): boolean { return super.Section.get("dimInactiveRegions"); } public get inactiveRegionOpacity(): number { return super.Section.get("inactiveRegionOpacity"); } + public get inactiveRegionFontColor(): string { return super.Section.get("inactiveRegionFontColor"); } + public get inactiveRegionBackgroundColor(): string { return super.Section.get("inactiveRegionBackgroundColor"); } public get autoComplete(): string { return super.Section.get("autocomplete"); } public get loggingLevel(): string { return super.Section.get("loggingLevel"); } public get navigationLength(): number { return super.Section.get("navigation.length", 60); } From 55f6695bc3f802f8f622caa23121a2db18464ec8 Mon Sep 17 00:00:00 2001 From: John Patterson Date: Mon, 23 Jul 2018 10:18:04 -0700 Subject: [PATCH 2/3] fixes MR feedback * Cleanup CHANGELOG to new release * FontColor -> ForegroundColor * hexidecimal -> hexadecimal * fixing inactiveRegionForegroundColor typing --- Extension/CHANGELOG.md | 4 +++- Extension/package.json | 11 +++++++---- Extension/src/LanguageServer/client.ts | 2 +- Extension/src/LanguageServer/settings.ts | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index 1c77f95ae..9a853477b 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,5 +1,8 @@ # C/C++ for Visual Studio Code Change Log +## Version 0.17.8: August 16, 2018 +* Add `inactiveRegionForegroundColor` and `inactiveRegionBackgroundColor` to settings. [#2212](https://github.com/Microsoft/vscode-cpptools/issues/2212) + ## Version 0.17.7: July 22, 2018 * Fix `Go to Definition` for code scoped with an aliased namespace. [#387](https://github.com/Microsoft/vscode-cpptools/issues/387) * Fix incorrect IntelliSense errors with template template-arguments. [#1014](https://github.com/Microsoft/vscode-cpptools/issues/1014) @@ -24,7 +27,6 @@ * Add a setting to silence configuration provider warnings. [#2292](https://github.com/Microsoft/vscode-cpptools/issues/2292) * Fix for debugging async Visual C++ causing debugger to hang. * Fix `main` snippet. -* Add `inactiveRegionFontColor` and `inactiveRegionBackgroundColor` to settings. [#2212](https://github.com/Microsoft/vscode-cpptools/issues/2212) ## Version 0.17.6: July 2, 2018 * Fix the database icon getting stuck with recursive includes. [#2104](https://github.com/Microsoft/vscode-cpptools/issues/2104) diff --git a/Extension/package.json b/Extension/package.json index 1b2c3a551..4b1a938d5 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -154,16 +154,19 @@ "minimum": 0.1, "maximum": 1 }, - "C_Cpp.inactiveRegionFontColor": { - "type": "string", + "C_Cpp.inactiveRegionForegroundColor": { + "type": [ + "string", + "null" + ], "default": null, - "description": "Controls the font coloring of inactive preprocessor blocks. Input is in the form a hexidecimal color code or a valid Theme Color. If not set, this defaults to the syntax coloring scheme of the editor. This setting only applies when inactive region dimming is enabled.", + "description": "Controls the font coloring of inactive preprocessor blocks. Input is in the form a hexadecimal color code or a valid Theme Color. If not set, this defaults to the syntax coloring scheme of the editor. This setting only applies when inactive region dimming is enabled.", "scope": "resource" }, "C_Cpp.inactiveRegionBackgroundColor": { "type": "string", "default": null, - "description": "Controls the background coloring of inactive preprocessor blocks. Input is in the form a hexidecimal color code or a valid Theme Color. If not set, this defaults to transparent. This setting only applies when inactive region dimming is enabled.", + "description": "Controls the background coloring of inactive preprocessor blocks. Input is in the form a hexadecimal color code or a valid Theme Color. If not set, this defaults to transparent. This setting only applies when inactive region dimming is enabled.", "scope": "resource" }, "C_Cpp.formatting": { diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index d6ce32b91..01779d7ae 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -841,7 +841,7 @@ class DefaultClient implements Client { let decoration: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType({ opacity: settings.inactiveRegionOpacity.toString(), backgroundColor: settings.inactiveRegionBackgroundColor, - color: settings.inactiveRegionFontColor, + color: settings.inactiveRegionForegroundColor, rangeBehavior: vscode.DecorationRangeBehavior.ClosedOpen }); diff --git a/Extension/src/LanguageServer/settings.ts b/Extension/src/LanguageServer/settings.ts index c1ad24221..452eddb7f 100644 --- a/Extension/src/LanguageServer/settings.ts +++ b/Extension/src/LanguageServer/settings.ts @@ -41,7 +41,7 @@ export class CppSettings extends Settings { public get errorSquiggles(): string { return super.Section.get("errorSquiggles"); } public get dimInactiveRegions(): boolean { return super.Section.get("dimInactiveRegions"); } public get inactiveRegionOpacity(): number { return super.Section.get("inactiveRegionOpacity"); } - public get inactiveRegionFontColor(): string { return super.Section.get("inactiveRegionFontColor"); } + public get inactiveRegionForegroundColor(): string { return super.Section.get("inactiveRegionForegroundColor"); } public get inactiveRegionBackgroundColor(): string { return super.Section.get("inactiveRegionBackgroundColor"); } public get autoComplete(): string { return super.Section.get("autocomplete"); } public get loggingLevel(): string { return super.Section.get("loggingLevel"); } From 917fb82c9697fba1b6697b0e3b2c7375ce27622b Mon Sep 17 00:00:00 2001 From: John Patterson Date: Mon, 23 Jul 2018 12:47:22 -0700 Subject: [PATCH 3/3] fix MR feedback * inactiveRegionBackgroundColor still had string typing instead of string | null --- Extension/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Extension/package.json b/Extension/package.json index 4b1a938d5..9d8e6f7e7 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -164,7 +164,10 @@ "scope": "resource" }, "C_Cpp.inactiveRegionBackgroundColor": { - "type": "string", + "type": [ + "string", + "null" + ], "default": null, "description": "Controls the background coloring of inactive preprocessor blocks. Input is in the form a hexadecimal color code or a valid Theme Color. If not set, this defaults to transparent. This setting only applies when inactive region dimming is enabled.", "scope": "resource"