Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when adding theme to ~/.config/babi/theme.json #41

Closed
jkittner opened this issue Mar 17, 2020 · 8 comments
Closed

Error when adding theme to ~/.config/babi/theme.json #41

jkittner opened this issue Mar 17, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@jkittner
Copy link
Contributor

Hi Anthony,
I was testing babi on my Ubuntu 18.04 server via SSH and it worked perfectly fine until I tried to add themes to ~/.config/babi/theme.json
I tried to add this theme. I simply copy/pasted it into a file named theme.json.
I am using Python 3.6.9 and when executingbabi theme.json the following error comes up:

Traceback (most recent call last):
  File "/home/kittnjdr/.local/bin/babi", line 11, in <module>
    load_entry_point('babi==0.0.1', 'console_scripts', 'babi')()
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/main.py", line 63, in main
    return c_main(stdscr, args)
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/main.py", line 37, in c_main
    screen = Screen(stdscr, args.filenames or [None], perf)
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/screen.py", line 78, in __init__
    Syntax.from_screen(stdscr, color_manager),
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/hl/syntax.py", line 143, in from_screen
    theme = Theme.from_filename(xdg_config('theme.json'))
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/theme.py", line 152, in from_filename
    return cls.from_dct(json.loads(contents))
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/theme.py", line 139, in from_dct
    return cls(Style(**default), TrieNode.from_dct(root))
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/theme.py", line 74, in from_dct
    k: TrieNode.from_dct(v) for k, v in dct['children'].items()
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/theme.py", line 74, in <dictcomp>
    k: TrieNode.from_dct(v) for k, v in dct['children'].items()
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/theme.py", line 74, in from_dct
    k: TrieNode.from_dct(v) for k, v in dct['children'].items()
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/theme.py", line 74, in <dictcomp>
    k: TrieNode.from_dct(v) for k, v in dct['children'].items()
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/theme.py", line 76, in from_dct
    return cls(PartialStyle.from_dct(dct), children)
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/theme.py", line 48, in from_dct
    kv['fg'] = Color.parse(dct['foreground'])
  File "/home/kittnjdr/.local/lib/python3.6/site-packages/babi/color.py", line 11, in parse
    return cls(r=int(s[1:3], 16), g=int(s[3:5], 16), b=int(s[5:7], 16))
ValueError: invalid literal for int() with base 16: 'hi'

Maybe this theme is not suitable?

@gagbo
Copy link

gagbo commented Mar 17, 2020

One line json file :(

The thing that didn't work is "settings":{"foreground":"white","background":"#E05252"}}, to help conversation ; assuming that the color parser just removed the first char w (thinking it should just be a #) and tried to parse the hi characters as a hex number

@jkittner
Copy link
Contributor Author

jkittner commented Mar 17, 2020

That was indeed the issue. I formatted the json to a multilne file and replaced "white" with "#FFFFFF". Now there is no error but still no syntax highlighting.

@asottile
Copy link
Owner

hmmm yeah the color parser assumes they're hex codes so that's the first issue -- as for no syntax highlighting after that it probably means the grammar didn't match? can you ls ~/.local/share/babi/textmate_syntax/ there should be a bunch of files in there from running ./bin/download-syntax

@asottile asottile added the bug Something isn't working label Mar 17, 2020
@asottile
Copy link
Owner

Capture28

here's what it looks like for me once I fixed white -- I also did black at the same time, I don't suspect other named colors will come up but I'll try a bunch of themes later to verify 👍

thanks again for the report!

@jkittner
Copy link
Contributor Author

~/.local/share/babi/textmate_syntax/ looks fine to me all files are there.
I think the problem might be caused by my SSH-client and not the server.

  • When using windows' cmd to SSH into my remote server the syntax highlighting works perfectly fine with all file types and different themes.
  • When using PuTTY or MobaXterm the syntax highlighting does not work at all. In PuTTY 256-color mode is activated, MobaXterm should have this enabled as a default.

@asottile
Copy link
Owner

ah, if you echo $TERM it probably was xterm or something without sufficient colors -- it needs to be a >=256 color compatible terminal to display colors. I wonder why putty's 256color mode didn't work though, perhaps the TERM it enables isn't recognized by curses?

@jkittner
Copy link
Contributor Author

jkittner commented Mar 17, 2020

echo $TERM returns xterm-256color in MobaXterm even though it looks like this.

grafik
I think this issue is not related to babi it's some kind of problem with MobaXterms color modes...
Thanks for your help and your great work I am looking forward to using babi as my nr 1 text editor!

@asottile
Copy link
Owner

whoa, weird! it looks like ~some coloring is taking but it's greyscaled everything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants