rdbende / tkcode

Use Chlorophyll instead
https://github.com/rdbende/chlorophyll
MIT License
18 stars 3 forks source link

Pointers are broken in json reading #14

Open Moosems opened 2 years ago

Moosems commented 2 years ago

I set up a json file as a theme and used pointers to make future editing simpler. The issue is that I got an error.

Error:

  File "/Users/Moosems/Desktop/DIP-dev/LangEditors.py", line 22, in __init__
    CodeEditor.__init__(self, master, language="Python", autofocus=True, highlighter=self.highlighter, font=self.editor_font, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tkcode/codeeditor.py", line 23, in __init__
    codebox.BaseCodeBox.__init__(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tkcode/codebox.py", line 94, in __init__
    self.update_highlighter(highlighter)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tkcode/codebox.py", line 280, in update_highlighter
    self.config(**general_props)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tkcode/codebox.py", line 429, in configure
    tk.Text.configure(self, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 1675, in configure
    return self._configure('configure', cnf, kw)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 1665, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown color name "{'$ref': '#/ColoringLight/bg'}"

Json file:

{
    "ColoringLight":
    {
        "bg": "#ffffff",
        "fg": "#4f4c4d",
        "TokenText": "#544619",
        "TokenKeyword": "#2f33ff",
        "TokenPunctuation": "#dd8ced",
        "TokenName": "#b6c23f",
        "TokenOperator": "#f6a656",
        "TokenComment": "#2cbe48",
        "TokenLiteralNumber": "#ab4bbe",
        "TokenLiteralString": "#f45159"
    },

    "general":
    {
        "background":{"$ref": "#/ColoringLight/bg"},
        "foreground": {"$ref": "#/ColoringLight/fg"},
        "insertbackground": "#c8894a",
        "insertwidth": 1,
        "highlightthickness": 0,
        "borderwidth": 0
    },

    "selection":
    {
    },

    "syntax":
    {
        "Token.Text": {"$ref": "#/ColoringLight/TokenText"},
        "Token.Other": {"$ref": "#/ColoringLight/TokenText"},
        "Token.Error": {"$ref": "#/ColoringLight/TokenText"},
        "Token.Whitespace": {"$ref": "#/ColoringLight/TokenText"},
        "Token.Escape": {"$ref": "#/ColoringLight/TokenText"},

        "Token.Keyword": {"$ref": "#/ColoringLight/TokenKeyword"},
        "Token.Keyword.Constant": {"$ref": "#/ColoringLight/TokenKeyword"},
        "Token.Keyword.Declaration": {"$ref": "#/ColoringLight/TokenKeyword"},
        "Token.Keyword.Namespace": {"$ref": "#/ColoringLight/TokenKeyword"},
        "Token.Keyword.Pseudo": {"$ref": "#/ColoringLight/TokenKeyword"},
        "Token.Keyword.Reserved": {"$ref": "#/ColoringLight/TokenKeyword"},
        "Token.Keyword.Type": {"$ref": "#/ColoringLight/TokenKeyword"},
        "Token.Keyword.Other": {"$ref": "#/ColoringLight/TokenKeyword"},

        "Token.Punctuation": {"$ref": "#/ColoringLight/TokenPunctuation"},

        "Token.Name.Attribute": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Builtin": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Builtin.Pseudo": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Class": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Constant": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Decorator": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Entity": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Exception": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Function": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Function.Magic": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Label": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Namespace": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Other": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Tag": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Variable": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Variable.Class": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Variable.Global": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Variable.Instance": {"$ref": "#/ColoringLight/TokenName"},
        "Token.Name.Variable.Magic": {"$ref": "#/ColoringLight/TokenName"},

        "Token.Operator": {"$ref": "#/ColoringLight/TokenOperator"},
        "Token.Operator.Word": {"$ref": "#/ColoringLight/TokenOperator"},

        "Token.Comment": {"$ref": "#/ColoringLight/TokenComment"},
        "Token.Comment.Hashbang": {"$ref": "#/ColoringLight/TokenComment"},
        "Token.Comment.Multiline": {"$ref": "#/ColoringLight/TokenComment"},
        "Token.Comment.Preproc": {"$ref": "#/ColoringLight/TokenComment"},
        "Token.Comment.Preprocfile": {"$ref": "#/ColoringLight/TokenComment"},
        "Token.Comment.Single": {"$ref": "#/ColoringLight/TokenComment"},
        "Token.Comment.Special": {"$ref": "#/ColoringLight/TokenComment"},

        "Token.Literal.Number.Bin": {"$ref": "#/ColoringLight/TokenLiteralNumber"},
        "Token.Literal.Number.Float": {"$ref": "#/ColoringLight/TokenLiteralNumber"},
        "Token.Literal.Number.Hex": {"$ref": "#/ColoringLight/TokenLiteralNumber"},
        "Token.Literal.Number.Integer": {"$ref": "#/ColoringLight/TokenLiteralNumber"},
        "Token.Literal.Number.Integer.Long": {"$ref": "#/ColoringLight/TokenLiteralNumber"},
        "Token.Literal.Number.Oct": {"$ref": "#/ColoringLight/TokenLiteralNumber"},

        "Token.Literal.String.Affix": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Char": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Delimeter": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Doc": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Double": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Escape": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Heredoc": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Interpol": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Other": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Regex": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Single": {"$ref": "#/ColoringLight/TokenLiteralString"},
        "Token.Literal.String.Symbol": {"$ref": "#/ColoringLight/TokenLiteralString"}
    }
}
rdbende commented 2 years ago

TBH, I've never heard of JSON pointers before. But if it isn't working, it's an issue with Python's json module, since tkcode uses that to get the colors and it's not something, I could solve in tkcode.

Moosems commented 2 years ago

@rdbende I opened this stackoverflow question and I'll let you know if anything becomes of it

Moosems commented 2 years ago

@rdbende An answer was given that I think will work for tkcode

Moosems commented 2 years ago

you can use the jsonref module instead of the json module and it should fix the issue