如何更改 MySQL Workbench 编辑器的背景颜色?

如何更改 MySQL Workbench 编辑器的背景颜色?

如何更改 MySQL Workbench 编辑器背景颜色?它似乎总是白色。我使用的是 Workbench 版本 6.3.7。

注意:其他 Stack 帖子中也提供了如何执行此操作的描述,但我尝试过的那些都没有用。事实上,有些说明已经过时,不再包含以前版本所具有的 XML 样式元素。

我正在查看 code_editor.xml(在我的 PC 上,它位于:C:\Program Files\MySQL\MySQL Workbench 6.3 CE\data),我看到了一些有趣的部分,例如:

<style id="1" fore-color="#008C3A" /> <!-- SCE_MYSQL_COMMENT -->
<style id="2" fore-color="#008C3A" /> <!-- SCE_MYSQL_COMMENTLINE -->
<style id="21" fore-color="#F77B09" back-color="#F0F0F0" /> <!-- SCE_MYSQL_HIDDENCOMMAND -->

<style id="3" fore-color="#A58E37" /> <!-- SCE_MYSQL_VARIABLE -->
<style id="4" fore-color="#A58E37" /> <!-- SCE_MYSQL_SYSTEMVARIABLE -->
<style id="5" fore-color="#A58E37" /> <!-- SCE_MYSQL_KNOWNSYSTEMVARIABLE -->

<style id="6" fore-color="#000000" /> <!-- SCE_MYSQL_NUMBER -->
<style id="12" fore-color="#FF0000" /> <!-- SCE_MYSQL_SQSTRING -->
<style id="13" fore-color="#FF0000" /> <!-- SCE_MYSQL_DQSTRING -->

<style id="7" fore-color="#0101BD" bold="Yes" /> <!-- SCE_MYSQL_MAJORKEYWORD -->
<style id="8" fore-color="#0101BD" bold="Yes"/> <!-- SCE_MYSQL_KEYWORD -->
<style id="15" fore-color="#0101BD" /> <!-- SCE_MYSQL_FUNCTION -->
<style id="10" fore-color="#C04000" bold="Yes" /> <!-- SCE_MYSQL_PROCEDUREKEYWORD -->
<style id="14" bold="Yes" /> <!-- SCE_MYSQL_OPERATOR -->

<style id="16" fore-color="#000000" /> <!-- SCE_MYSQL_IDENTIFIER -->
<style id="17" fore-color="#7D5A27" /> <!-- SCE_MYSQL_QUOTEDIDENTIFIER -->

<style id="22" fore-color="#FFFFFF" back-color="#A0A0A0" bold="Yes" /> <!-- SCE_MYSQL_PLACEHOLDER -->

<style id="18" fore-color="#007F00" /> <!-- SCE_MYSQL_USER1 -->

<!-- All styles again in their variant in a hidden command (with a 0x40 offset). -->
<style id="65" fore-color="#A0A0A0" back-color="#F0F0F0" /> <!-- SCE_MYSQL_COMMENT -->
<style id="66" fore-color="#A0A0A0" back-color="#F0F0F0" /> <!-- SCE_MYSQL_COMMENTLINE -->

<style id="67" fore-color="#A58E37" back-color="#F0F0F0" /> <!-- SCE_MYSQL_VARIABLE -->
<style id="68" fore-color="#A58E37" back-color="#F0F0F0" /> <!-- SCE_MYSQL_SYSTEMVARIABLE -->
<style id="69" fore-color="#A58E37" back-color="#F0F0F0" /> <!-- SCE_MYSQL_KNOWNSYSTEMVARIABLE -->

<style id="70" fore-color="#F0A030" back-color="#F0F0F0" /> <!-- SCE_MYSQL_NUMBER -->
<style id="76" fore-color="#209F20" back-color="#F0F0F0" /> <!-- SCE_MYSQL_SQSTRING -->
<style id="77" fore-color="#6D4A27" back-color="#F0F0F0" /> <!-- SCE_MYSQL_DQSTRING -->

<style id="71" fore-color="#007FBF" back-color="#F0F0F0" bold="Yes" /> <!-- SCE_MYSQL_MAJORKEYWORD -->
<style id="72" fore-color="#007FBF" back-color="#F0F0F0" bold="Yes"/> <!-- SCE_MYSQL_KEYWORD -->
<style id="79" fore-color="#C040C0" back-color="#F0F0F0" /> <!-- SCE_MYSQL_FUNCTION -->
<style id="74" fore-color="#C04000" back-color="#F0F0F0" bold="Yes" /> <!-- SCE_MYSQL_PROCEDUREKEYWORD -->
<style id="78" back-color="#F0F0F0" bold="Yes" /> <!-- SCE_MYSQL_OPERATOR -->

<style id="80" fore-color="#000000" back-color="#F0F0F0" /> <!-- SCE_MYSQL_IDENTIFIER -->
<style id="81" fore-color="#7D5A27" back-color="#F0F0F0" /> <!-- SCE_MYSQL_QUOTEDIDENTIFIER -->

<style id="86" fore-color="#FFFFFF" back-color="#A0A0A0" bold="Yes" /> <!-- SCE_MYSQL_PLACEHOLDER -->

<style id="82" fore-color="#007F00" /> <!-- SCE_MYSQL_USER1 -->

但我不知道其中哪一个(如果有的话)会简单地改变查询编辑器的背景颜色。提前致谢。

答案1

编辑器使用 Scintilla,并正如您所猜测的那样通过文件 data/code_editor.xml 进行配置。

该文件由语言组成,每种语言都必须定义样式。

要更改文本背景,请使用 ID 32 (STYLE_DEFAULT)

例子: <style id="32" back-color="#000000" /> <!-- STYLE_DEFAULT -->

左侧的行号背景可通过 id 33(STYLE_LINENUMBER)进行自定义

其他样式 id 适用于不同的关键字(code_editor.xml 注释中描述)。例如:可以通过back-color在语言 SCLEX_MYSQL 上添加 id 1 和 2 来更改注释背景。

对于您想要定制的每种语言,都必须这样做。

据我所知,没有办法全局更改默认设置。

参考

答案2

取自这里但我对其进行了更改,以便它可以在 Windows 10 上的 MySQL Workbench 8.0 中运行。由于据我所知 MacOS 已经集成了暗黑模式,所以不需要它。

将以下内容复制到code_editor.xml末尾。您可以在安装 Workbench 的任何<language name="SCLEX_MYSQL">位置或位置找到此文件。C:\Program Files\MySQL\MySQL Workbench 8.0 CE\data

<style id= "0" fore-color-light="#DDDDDD" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_DEFAULT                  -->
<style id= "1" fore-color-light="#999999" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_COMMENT                  -->
<style id= "2" fore-color-light="#999999" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_COMMENTLINE              -->
<style id= "3" fore-color-light="#DDDDDD" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_VARIABLE                 -->
<style id= "4" fore-color-light="#9B859D" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_SYSTEMVARIABLE           -->
<style id= "5" fore-color-light="#9B859D" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_KNOWNSYSTEMVARIABLE      -->
<style id= "6" fore-color-light="#FF8080" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_NUMBER                   -->
<style id= "7" fore-color-light="#7AAAD7" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_MAJORKEYWORD             -->
<style id= "8" fore-color-light="#7AAAD7" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_KEYWORD                  -->
<style id= "9" fore-color-light="#9B859D" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_DATABASEOBJECT           -->
<style id="10" fore-color-light="#DDDDDD" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_PROCEDUREKEYWORD         -->
<style id="11" fore-color-light="#B9CB89" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_STRING                   -->
<style id="12" fore-color-light="#B9CB89" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_SQSTRING                 -->
<style id="13" fore-color-light="#B9CB89" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_DQSTRING                 -->
<style id="14" fore-color-light="#FFBB80" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_OPERATOR                 -->
<style id="15" fore-color-light="#9B859D" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_FUNCTION                 -->
<style id="16" fore-color-light="#DDDDDD" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_IDENTIFIER               -->
<style id="17" fore-color-light="#B9CB89" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_QUOTEDIDENTIFIER         -->
<style id="18" fore-color-light="#B9CB89" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_USER1                    -->
<style id="19" fore-color-light="#B9CB89" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_USER2                    -->
<style id="20" fore-color-light="#B9CB89" back-color-light="#2A2A2A" bold="No" />   <!-- SCE_MYSQL_USER3                    -->
<style id="21" fore-color-light="#FFBB80" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_HIDDENCOMMAND            -->
<style id="22" fore-color-light="#909090" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_PLACEHOLDER              -->

<!-- These two are for scintilla globally. -->
<style id="32" fore-color-light="#DDDDDD" back-color-light="#2A2A2A" bold="No" />   <!-- STYLE_DEFAULT                      THIS IS THE ONE FOR THE BACKGROUND!!!!! -->
<style id="33" fore-color-light="#2A2A2A" back-color-light="#DDDDDD" bold="No" />   <!-- STYLE_LINENUMBER                   -->

<!-- All styles again in their variant in a hidden command (with a 0x40 offset). -->
<style id="65" fore-color-light="#999999" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_COMMENT                  -->
<style id="66" fore-color-light="#999999" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_COMMENTLINE              -->
<style id="67" fore-color-light="#DDDDDD" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_VARIABLE                 -->
<style id="68" fore-color-light="#9B859D" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_SYSTEMVARIABLE           -->
<style id="69" fore-color-light="#9B859D" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_KNOWNSYSTEMVARIABLE      -->
<style id="70" fore-color-light="#FF8080" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_NUMBER                   -->
<style id="71" fore-color-light="#7AAAD7" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_MAJORKEYWORD             -->
<style id="72" fore-color-light="#7AAAD7" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_KEYWORD                  -->
<style id="73" fore-color-light="#9B859D" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_DATABASEOBJECT           -->
<style id="74" fore-color-light="#DDDDDD" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_PROCEDUREKEYWORD         -->
<style id="75" fore-color-light="#B9CB89" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_STRING                   -->
<style id="76" fore-color-light="#B9CB89" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_SQSTRING                 -->
<style id="77" fore-color-light="#B9CB89" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_DQSTRING                 -->
<style id="78" fore-color-light="#FFBB80" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_OPERATOR                 -->
<style id="79" fore-color-light="#9B859D" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_FUNCTION                 -->
<style id="80" fore-color-light="#DDDDDD" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_IDENTIFIER               -->
<style id="81" fore-color-light="#B9CB89" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_QUOTEDIDENTIFIER         -->
<style id="82" fore-color-light="#B9CB89" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_USER1                    -->
<style id="83" fore-color-light="#B9CB89" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_USER2                    -->
<style id="84" fore-color-light="#B9CB89" back-color-light="#707070" bold="No" />   <!-- SCE_MYSQL_USER3                    -->
<style id="85" fore-color-light="#FFBB80" back-color-light="#909090" bold="No" />   <!-- SCE_MYSQL_HIDDENCOMMAND            -->
<style id="86" fore-color-light="#AAAAAA" back-color-light="#909090" bold="No" />   <!-- SCE_MYSQL_PLACEHOLDER              -->

您还可以在 Workbench 中将方案更改为Windows 7下方Edit -> Preferences -> Fonts & Colors,以使一些额外元素比默认值稍暗(至少对我来说)。

相关内容