Stani 的 python 编辑器 - 更改语法着色

发布于 2024-08-25 09:53:07 字数 4053 浏览 3 评论 0原文

查看 Stani 的 Python IDE,它肯定捆绑了大量有用的功能。但它不允许我进行自定义语法着色。

来自作者网站上的问答:

“- 不支持更改颜色,除非您手动编辑 sm/wxp/stc.py”

因此,我尝试自己检查该代码,以寻求完美的全功能 IDE 。

stc.py 文件似乎是作者对 Robin Dunn 的 wxPython 原始代码进行的修改。隐藏在所有事件处理中的代码似乎决定了各种语法的颜色。

我想做的就是将背景颜色更改为黑色,将黑色文本更改为白色,如果其他所有内容仍然显示在这两种新颜色下,我就是一个快乐的编码员。

有人试过这个吗?谢谢

编辑:~441 周围的行

def SetStyles(self)

是那些行吗?

编辑^2:有人也能找到光标闪烁颜色设置吗?或者这是一些“更”硬编码的东西?

edit^3:到目前为止,我在函数 SetStyles 中修改了 -441 行的十六进制颜色值。

    def SetStyles(self):
    # anti-aliasing
    if hasattr(self,'SetUseAntiAliasing'):
        self.SetUseAntiAliasing(True)

    #INDICATOR STYLES FOR ERRORS (self.errorMark)
    self.IndicatorSetStyle(2, wx_stc.STC_INDIC_SQUIGGLE)
    self.IndicatorSetForeground(2, wx.RED)

    #import dialogs.stcStyleEditor
    if 1:#dialogs.stcStyleEditor.SetStyles(self, self.config):
        self.StyleSetSpec(wx_stc.STC_P_DEFAULT, "face:%(mono)s,fore:#B0B0B0,size:%(size)d" % self.faces)
        self.StyleClearAll()

        # Global default styles for all languages  B0B0B0= gray
        self.StyleSetSpec(wx_stc.STC_STYLE_DEFAULT,     "face:%(mono)s,fore:#B0B0B0,back:#00000,size:%(size)d" % self.faces)
        self.StyleSetSpec(wx_stc.STC_STYLE_LINENUMBER,  "back:#C0C0C0,face:%(mono)s,size:%(size)d" % self.faces)
        self.StyleSetSpec(wx_stc.STC_STYLE_CONTROLCHAR, "face:%(mono)s,fore:#B0B0B0" % self.faces)
        self.StyleSetSpec(wx_stc.STC_STYLE_BRACELIGHT,  "fore:#B0B0B0,back:#0000FF,bold")
        self.StyleSetSpec(wx_stc.STC_STYLE_BRACEBAD,    "fore:#B0B0B0,back:#FF0000,bold")

        # Python styles
        # White space
        self.StyleSetSpec(wx_stc.STC_P_DEFAULT, "face:%(mono)s,fore:#000000,back:#000000,size:%(size)d" % self.faces)
        # Comment
        self.StyleSetSpec(wx_stc.STC_P_COMMENTLINE, "face:%(mono)s,fore:#F70909,back:#000000,italic,size:%(size)d" % self.faces)
        # Number
        self.StyleSetSpec(wx_stc.STC_P_NUMBER, "face:%(mono)s,fore:#FFFFFF,size:%(size)d" % self.faces)
        # String
        self.StyleSetSpec(wx_stc.STC_P_STRING, "face:%(mono)s,fore:#34C640,size:%(size)d" % self.faces)
        # Single quoted string
        self.StyleSetSpec(wx_stc.STC_P_CHARACTER, "face:%(mono)s,fore:#43AB4E,size:%(size)d" % self.faces)
        # Keyword (Class, def, etc.)
        self.StyleSetSpec(wx_stc.STC_P_WORD, "face:%(mono)s,fore:#FF9100,bold,size:%(size)d" % self.faces)
        # Triple quotes
        self.StyleSetSpec(wx_stc.STC_P_TRIPLE, "face:%(mono)s,fore:#7F0000,size:%(size)d" % self.faces)
        # Triple double quotes
        self.StyleSetSpec(wx_stc.STC_P_TRIPLEDOUBLE, "face:%(mono)s,fore:#7F0000,size:%(size)d" % self.faces)
        # Class name definition (Name of the class)
        self.StyleSetSpec(wx_stc.STC_P_CLASSNAME, "face:%(mono)s,fore:#00AEFF,bold,size:%(size)d" % self.faces)
        # Function or method name definition (bright blue = #0011FF)
        self.StyleSetSpec(wx_stc.STC_P_DEFNAME, "face:%(mono)s,fore:#FFFF00,bold,size:%(size)d" % self.faces)
        # Operators (+ - /)
        self.StyleSetSpec(wx_stc.STC_P_OPERATOR, "face:%(mono)s,fore:#FFFFFF,bold,size:%(size)d" % self.faces)
        # Identifiers (this was all the same color - > self.SetTopWindow(self.frame))
        self.StyleSetSpec(wx_stc.STC_P_IDENTIFIER, "fore:#FFFFFF")
        # Comment-blocks
        self.StyleSetSpec(wx_stc.STC_P_COMMENTBLOCK, "face:%(mono)s,fore:#990000,back:#C0C0C0,italic,size:%(size)d" % self.faces)
        # End of line where string is not closed
        self.StyleSetSpec(wx_stc.STC_P_STRINGEOL, "face:%(mono)s,fore:#B1CCB0,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" % self.faces)

这使用黑色背景并将其他颜色更改为更亮。

尚待解决的问题:

1.类标识符(“self.”、“classname.”等)与“.”后面的文本颜色相同,但原来是这样的,别以为可以被改变(无论如何,很容易) 2. 鼠标光标位置标记(闪烁“|”)仍然是黑色,在新背景中变得不可见。 3. 这个应用程序是否支持鼠标悬停变量并弹出变量来源的描述?(就像在 pyscripter 中一样)?

Looking at Stani's Python IDE, it definitely comes bundled with tons of useful features. Except it doesn't let me do custom syntax coloring.

From the Q&A on the author's site:

"- changing colors is not supported unless you edit manually sm/wxp/stc.py"

So I've attempted to check out that code myself in my quest for the perfect full-featured IDE.

The stc.py file seems to be the author's modifications on Robin Dunn's original code for wxPython. Buried within all the event handling seems to be code that determines the colour of the various syntax.

All I want to do is change the background colour to be black, change the black texts to white, and if everything else stills show up under these two new colours, i'm a happy coder.

Has anyone tried this? Thanks

edit: The lines around ~441

def SetStyles(self)

are those lines it?

edit^2: would someone be able to find the cursor blink color setting as well? Or is that something a little 'more' hard coded?

edit^3: What I have so far , modifying the hex color values from line -441, in the function SetStyles.

    def SetStyles(self):
    # anti-aliasing
    if hasattr(self,'SetUseAntiAliasing'):
        self.SetUseAntiAliasing(True)

    #INDICATOR STYLES FOR ERRORS (self.errorMark)
    self.IndicatorSetStyle(2, wx_stc.STC_INDIC_SQUIGGLE)
    self.IndicatorSetForeground(2, wx.RED)

    #import dialogs.stcStyleEditor
    if 1:#dialogs.stcStyleEditor.SetStyles(self, self.config):
        self.StyleSetSpec(wx_stc.STC_P_DEFAULT, "face:%(mono)s,fore:#B0B0B0,size:%(size)d" % self.faces)
        self.StyleClearAll()

        # Global default styles for all languages  B0B0B0= gray
        self.StyleSetSpec(wx_stc.STC_STYLE_DEFAULT,     "face:%(mono)s,fore:#B0B0B0,back:#00000,size:%(size)d" % self.faces)
        self.StyleSetSpec(wx_stc.STC_STYLE_LINENUMBER,  "back:#C0C0C0,face:%(mono)s,size:%(size)d" % self.faces)
        self.StyleSetSpec(wx_stc.STC_STYLE_CONTROLCHAR, "face:%(mono)s,fore:#B0B0B0" % self.faces)
        self.StyleSetSpec(wx_stc.STC_STYLE_BRACELIGHT,  "fore:#B0B0B0,back:#0000FF,bold")
        self.StyleSetSpec(wx_stc.STC_STYLE_BRACEBAD,    "fore:#B0B0B0,back:#FF0000,bold")

        # Python styles
        # White space
        self.StyleSetSpec(wx_stc.STC_P_DEFAULT, "face:%(mono)s,fore:#000000,back:#000000,size:%(size)d" % self.faces)
        # Comment
        self.StyleSetSpec(wx_stc.STC_P_COMMENTLINE, "face:%(mono)s,fore:#F70909,back:#000000,italic,size:%(size)d" % self.faces)
        # Number
        self.StyleSetSpec(wx_stc.STC_P_NUMBER, "face:%(mono)s,fore:#FFFFFF,size:%(size)d" % self.faces)
        # String
        self.StyleSetSpec(wx_stc.STC_P_STRING, "face:%(mono)s,fore:#34C640,size:%(size)d" % self.faces)
        # Single quoted string
        self.StyleSetSpec(wx_stc.STC_P_CHARACTER, "face:%(mono)s,fore:#43AB4E,size:%(size)d" % self.faces)
        # Keyword (Class, def, etc.)
        self.StyleSetSpec(wx_stc.STC_P_WORD, "face:%(mono)s,fore:#FF9100,bold,size:%(size)d" % self.faces)
        # Triple quotes
        self.StyleSetSpec(wx_stc.STC_P_TRIPLE, "face:%(mono)s,fore:#7F0000,size:%(size)d" % self.faces)
        # Triple double quotes
        self.StyleSetSpec(wx_stc.STC_P_TRIPLEDOUBLE, "face:%(mono)s,fore:#7F0000,size:%(size)d" % self.faces)
        # Class name definition (Name of the class)
        self.StyleSetSpec(wx_stc.STC_P_CLASSNAME, "face:%(mono)s,fore:#00AEFF,bold,size:%(size)d" % self.faces)
        # Function or method name definition (bright blue = #0011FF)
        self.StyleSetSpec(wx_stc.STC_P_DEFNAME, "face:%(mono)s,fore:#FFFF00,bold,size:%(size)d" % self.faces)
        # Operators (+ - /)
        self.StyleSetSpec(wx_stc.STC_P_OPERATOR, "face:%(mono)s,fore:#FFFFFF,bold,size:%(size)d" % self.faces)
        # Identifiers (this was all the same color - > self.SetTopWindow(self.frame))
        self.StyleSetSpec(wx_stc.STC_P_IDENTIFIER, "fore:#FFFFFF")
        # Comment-blocks
        self.StyleSetSpec(wx_stc.STC_P_COMMENTBLOCK, "face:%(mono)s,fore:#990000,back:#C0C0C0,italic,size:%(size)d" % self.faces)
        # End of line where string is not closed
        self.StyleSetSpec(wx_stc.STC_P_STRINGEOL, "face:%(mono)s,fore:#B1CCB0,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" % self.faces)

this uses a black background and changes the other colors to be brighter.

Questions Still Remaining:

1.The class identifiers ("self.", "classname.", etc) have the same color as the text after the '.', but this is how the original one is, don't think that can be changed (easily, anyway)
2. The mouse cursor position marker (blinking "|" ) is still black, which becomes invisible in the new background.
3. Does this application support mouse-overing variables and having a description of the variable's origins pop up?(like in pyscripter)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情话难免假 2024-09-01 09:53:07

我上面提到的代码基本上解决了这个问题,所以我会关闭这个问题。

The code I referred to above basically solves the issue, so I'll close the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文