设置 Visual & Installer 中使用的颜色语法以匹配 Inno Setup 6

Setting the colour syntax used in Visual & Installer to match Inno Setup 6

我正在设置 Visual & Installer 颜色语法,使其看起来和感觉更像 Inno Setup 6,因为它让我的眼睛更舒服(尤其是我的色盲)。

如前所述here

All colors can be customized - there are many elements supported: Keywords, Comments, Parameters, Variables, Constants, labels, Preprocessor and many more... Configure them easily in Tools -> Options -> Environment -> Fonts and Colors dialog

所以我一直在研究可用的属性:

到目前为止我已经想出了(通过从 Inno 抓取屏幕并询问颜色):

我不知道我和官方的 Inno Setup 颜色有多接近。有人可以在任何地方确认这一点吗?

具体来说,我不确定脚本的哪些部分由以下内容表示:

我想确定 Inno Setup 为它们使用的颜色。

更新

我试图通过将背景颜色设置为明亮的颜色来识别脚本(IdentifierParameter)中的这些标记,但我没有看到此类元素。我重新启动 Visual Studio 以确保。所以我不确定发生了什么?

默认 Inno 设置 IDE (Compil32.exe)

不支持更改语法颜色。它们在源代码中是硬编码的。因此,如何更改它们的唯一方法是从源代码重新编译 Inno Setup。它们的颜色定义为 here.

重要提示: IDE 使用的每个主题的颜色都不同。

查看此 file 以了解如何将颜色应用于特定项目。

Visual Studio IDE

的可视化和安装程序

颜色可以在选项对话框的字体和颜色部分完全调整。它们与官方的 Inno Setup 颜色不匹配,V&I 不是 Inno 的精确副本 IDE,请随意调整颜色以满足您的需要。

重要提示:很难比较颜色,因为 IDE 有不同的语法高亮机制!并非 Inno IDE 中的 关键字 都是 V&I 等 关键字

参数和标识符

ParametersIdentifiers 的颜色当前未使用,保留供将来使用。

  • Parameters 实际上是 [Files] 部分中的关键字,它们目前用 Keyword 颜色着色:
  • 标识符变量函数过程的内部表示 等,并相应地着色。

为了完整起见,这里是 Visual & Installer 中使用的默认颜色 - Visual Studio:

if (mDarkTheme)
{
  // Parameters /*1*/ to /*X*/ are used in InnoSetupScanner.cs
  mColorableItems = new ColorableItem[]
  {                    
    /*1*/ new LanguageColorableItem(Name + " - Keyword",        Name + " - Keyword",        COLORINDEX.CI_BLUE,             COLORINDEX.CI_USERTEXT_BK, System.Drawing.Color.FromArgb((int)LanguageColorableItem.clrYelGold), System.Drawing.Color.Empty, FONTFLAGS.FF_DEFAULT),
    /*2*/ new LanguageColorableItem(Name + " - Comment",        Name + " - Comment",        COLORINDEX.CI_DARKGREEN,        COLORINDEX.CI_USERTEXT_BK, System.Drawing.Color.FromArgb((int)LanguageColorableItem.clrLtGreen), System.Drawing.Color.Empty, FONTFLAGS.FF_DEFAULT),
    /*3*/ new LanguageColorableItem(Name + " - Identifier",     Name + " - Identifier",     COLORINDEX.CI_SYSPLAINTEXT_FG,  COLORINDEX.CI_USERTEXT_BK, System.Drawing.Color.FromArgb((int)LanguageColorableItem.clrDkWhite), System.Drawing.Color.Empty, FONTFLAGS.FF_DEFAULT),
    /*4*/ new LanguageColorableItem(Name + " - String",         Name + " - String",         COLORINDEX.CI_MAROON,           COLORINDEX.CI_USERTEXT_BK, System.Drawing.Color.FromArgb((int)LanguageColorableItem.clrTeal), System.Drawing.Color.Empty, FONTFLAGS.FF_DEFAULT),
    /*5*/ new LanguageColorableItem(Name + " - Number",         Name + " - Number",         COLORINDEX.CI_LIGHTGRAY,        COLORINDEX.CI_USERTEXT_BK),
    /*6*/ new LanguageColorableItem(Name + " - Parameter",      Name + " - Parameter",      COLORINDEX.CI_BLUE ,            COLORINDEX.CI_USERTEXT_BK, System.Drawing.Color.FromArgb((int)LanguageColorableItem.clrYelGold), System.Drawing.Color.Empty, FONTFLAGS.FF_DEFAULT),
    /*7*/ new LanguageColorableItem(Name + " - Constant",       Name + " - Constant",       COLORINDEX.CI_MAROON,           COLORINDEX.CI_USERTEXT_BK, System.Drawing.Color.FromArgb((int)LanguageColorableItem.clrLtMaroon), System.Drawing.Color.Empty, FONTFLAGS.FF_DEFAULT),
    /*8*/ new LanguageColorableItem(Name + " - Preprocessor",   Name + " - Preprocessor",   COLORINDEX.CI_RED,              COLORINDEX.CI_USERTEXT_BK),
    /*9*/ new LanguageColorableItem(Name + " - Pascal",         Name + " - Pascal",         COLORINDEX.CI_BLUE,             COLORINDEX.CI_USERTEXT_BK, System.Drawing.Color.FromArgb((int)LanguageColorableItem.clrLtPurple), System.Drawing.Color.Empty, FONTFLAGS.FF_DEFAULT),
    /*10*/new LanguageColorableItem(Name + " - Section",        Name + " - Section",        COLORINDEX.CI_DARKGRAY,         COLORINDEX.CI_USERTEXT_BK, FONTFLAGS.FF_BOLD),
    /*11*/new LanguageColorableItem(Name + " - Flag",           Name + " - Flag",           COLORINDEX.CI_BLACK,            COLORINDEX.CI_USERTEXT_BK, System.Drawing.Color.FromArgb((int)LanguageColorableItem.clrOrange), System.Drawing.Color.Empty, FONTFLAGS.FF_DEFAULT)
  };
}
else
{
  // Parameters /*1*/ to /*X*/ are used in InnoSetupScanner.cs
  mColorableItems = new ColorableItem[]
  {                    
    /*1*/ new LanguageColorableItem(Name + " - Keyword",        Name + " - Keyword",        COLORINDEX.CI_BLUE,             COLORINDEX.CI_USERTEXT_BK),
    /*2*/ new LanguageColorableItem(Name + " - Comment",        Name + " - Comment",        COLORINDEX.CI_DARKGREEN,        COLORINDEX.CI_USERTEXT_BK),
    /*3*/ new LanguageColorableItem(Name + " - Identifier",     Name + " - Identifier",     COLORINDEX.CI_SYSPLAINTEXT_FG,  COLORINDEX.CI_USERTEXT_BK),
    /*4*/ new LanguageColorableItem(Name + " - String",         Name + " - String",         COLORINDEX.CI_MAROON,           COLORINDEX.CI_USERTEXT_BK, System.Drawing.Color.FromArgb((int)LanguageColorableItem.clrTeal), System.Drawing.Color.Empty, FONTFLAGS.FF_DEFAULT),
    /*5*/ new LanguageColorableItem(Name + " - Number",         Name + " - Number",         COLORINDEX.CI_DARKBLUE,         COLORINDEX.CI_USERTEXT_BK),
    /*6*/ new LanguageColorableItem(Name + " - Parameter",      Name + " - Parameter",      COLORINDEX.CI_BLUE ,            COLORINDEX.CI_USERTEXT_BK),
    /*7*/ new LanguageColorableItem(Name + " - Constant",       Name + " - Constant",       COLORINDEX.CI_MAROON,           COLORINDEX.CI_USERTEXT_BK),
    /*8*/ new LanguageColorableItem(Name + " - Preprocessor",   Name + " - Preprocessor",   COLORINDEX.CI_RED,              COLORINDEX.CI_USERTEXT_BK),
    /*9*/ new LanguageColorableItem(Name + " - Pascal",         Name + " - Pascal",         COLORINDEX.CI_BLUE,             COLORINDEX.CI_USERTEXT_BK),
    /*10*/new LanguageColorableItem(Name + " - Section",        Name + " - Section",        COLORINDEX.CI_BLACK,            COLORINDEX.CI_USERTEXT_BK, FONTFLAGS.FF_BOLD),
    /*11*/new LanguageColorableItem(Name + " - Flag",           Name + " - Flag",           COLORINDEX.CI_BLACK,            COLORINDEX.CI_USERTEXT_BK, System.Drawing.Color.FromArgb((int)LanguageColorableItem.clrOrange), System.Drawing.Color.Empty, FONTFLAGS.FF_DEFAULT)
  };
}


public enum COLORINDEX
{
  CI_USERTEXT_FG = 0,
  CI_SYSTEXT_FG = 0,
  CI_USERTEXT_BK = 1,
  CI_SYSTEXT_BK = 1,
  CI_FIRSTFIXEDCOLOR = 2,
  CI_BLACK = 2,
  CI_WHITE = 3,
  CI_MAROON = 4,
  CI_DARKGREEN = 5,
  CI_BROWN = 6,
  CI_DARKBLUE = 7,
  CI_PURPLE = 8,
  CI_AQUAMARINE = 9,
  CI_LIGHTGRAY = 10,
  CI_DARKGRAY = 11,
  CI_RED = 12,
  CI_GREEN = 13,
  CI_YELLOW = 14,
  CI_BLUE = 15,
  CI_MAGENTA = 16,
  CI_CYAN = 17,
  CI_LASTFIXEDCOLOR = 17,
  CI_SYSSEL_FG = 18,
  CI_SYSSEL_BK = 19,
  CI_SYSINACTSEL_FG = 20,
  CI_SYSINACTSEL_BK = 21,
  CI_SYSWIDGETMGN_BK = 22,
  CI_SYSPLAINTEXT_FG = 23,
  CI_SYSPLAINTEXT_BK = 24,
  CI_PALETTESIZE = 25,
  CI_FORBIDCUSTOMIZATION = 26
}

from namespace namespace Microsoft.VisualStudio.TextManager.Interop

public class LanguageColorableItem : ColorableItem
{
  // Default colors (for Dark Theme mostly)
  public const int clrLtGreen     = unchecked((int)0xFF93C763);
  public const int clrDkWhite     = unchecked((int)0xFFE0E2E4);
  public const int clrYelGold     = unchecked((int)0xFFFFCD22);
  public const int clrLtPurple    = unchecked((int)0xFFA082BD);
  public const int clrLtMaroon    = unchecked((int)0xFFA0522D);
  public const int clrOrange      = unchecked((int)0xFFFF8040);
  public const int clrTeal        = unchecked((int)0xFF4A9595);
}

public class ColorableItem : IVsColorableItem, IVsHiColorItem, IVsMergeableUIItem
{
}

from namespace Microsoft.VisualStudio.Package

更新

以下内容由@ajtruckle 提供。

Inno Setup 颜色常量(来自上面的源代码 link)是:

  MRed = D29CC;            { Azure DevOps }
  MGreen = 9933;          { Azure DevOps }
  MBlue = $D47800;           { Azure DevOps }   
  MOrange = E88E5;         { Azure DevOps }
  MPurple = 3B77;         { Azure DevOps }
  MYellow = DCBF2;         { Azure DevOps }
  MTeal = $B0C94E;           { Visual Studio 2017 }
  MGray = 7070;           { Inno Setup 5 }

上面的颜色代码似乎是 BGR。考虑到这一点,这些似乎是视觉和安装程序的等效颜色映射:

  • Comment — 绿色 — RGB(51, 153, 51)
  • Keyword — 蓝色 — RGB(0, 120, 212)
  • Number — 橙色 — RGB(229, 136, 94)
  • Pascal — 蓝色 — RGB(0, 120, 212)
  • Preprocessor — 红色 — RGB(204, 41, 61)
  • String — 橙色 — RGB(229, 136, 94)

特定于视觉和安装程序:

  • Constant
  • Flag
  • Section
  • Parameter — 尚未使用(用法如上所述)
  • Identifier — 尚未使用(用法如上所述)