kuroko-lang / kuroko

Dialect of Python with explicit variable declaration and block scoping, with a lightweight and easy-to-embed bytecode compiler and interpreter.
https://kuroko-lang.github.io/
MIT License
423 stars 24 forks source link

“Missing” output #44

Closed kseistrup closed 5 months ago

kseistrup commented 1 year ago

On every new release of kuroko I tell myself that now is the time to learn kuroko, and every time I give up after a line or two in the REPL because it doesn't seem to show any output. This time is different, though, because I'm gonna file an issue where I ask if this is the intended behaviour:

kuroko-silent

Can I disable syntax highlighting, if that is what is interfering with the dark shell theme that I'm using?


klange commented 1 year ago

The palette in your terminal has "dark gray" set as the same color as background, which is incorrect.

https://github.com/kuroko-lang/kuroko/blob/master/src/kuroko.c#L1172

Can I disable syntax highlighting, if that is what is interfering with the dark shell theme that I'm using?

Syntax highlighting is not the cause of this, though if you are setting a custom palette as part of your shell configuration that may be responsible.

klange commented 1 year ago

Screenshot from 2023-08-30 05-48-54

The default theme I get in Terminator does not do this, and I checked several other palettes.

Screenshot_2023-08-30_05-51-52

When adjusting the color palette in Terminator, the lower left color here should be a gray that is distinct from the background. This is the color that is used to display expression results in the Kuroko repl.

kseistrup commented 1 year ago

Thanks.

I'm using the Dracula theme everywhere. The gray and the background may be too similar, but they are not identical. I suspected it was something like that, but then I expected help and license to produce more than a single line of text, so I wan't sure.

It would still be nice to be able to disable the colouring and just see plain, unadorned characters in the REPL, though.

klange commented 1 year ago

You should be able to determine if text was actually output by selecting it (and possibly copying with Ctrl+Shift+V). Assuming your terminal is wide enough, help and license can produce a single line of output.

klange commented 1 year ago

I would appreciate if you can verify whether text was output at all, but I have also prepared a branch which does not include the color codes in expression evaluation output: https://github.com/kuroko-lang/kuroko/tree/uncolored

You can further disable the syntax highlighting repl input with the -r option, but note that this will also disable tab completion and automatic indentation.

klange commented 1 year ago

I’d also like to see what happens with other strings printed using the 90 color code; seeing something like the results of print("\[[90mhello world\[[0m") would be useful.

klange commented 1 year ago

I think I will make the output format configurable, similar to how prompts can usually be changed (I'll support that as well).

kseistrup commented 12 months ago

strings printed using the 90 color code

They are “invisible” in terminal emulators that are using the Dracula colour theme.

kseistrup commented 12 months ago

This is what the “uncolored” branch looks like:

kuroko-uncoloured

This make me realise that I do not object to syntax highlighting at all, in fact I find it very useful.

I objected to some output being “invisible”, and one way of making the invisible text visible is to disable syntax highlighting.

Disabling syntax highlighting still has its merits: https://no-color.org/

Another way to improve visibility is to not make plain text output darker than text input (as on the screenshot above).

klange commented 12 months ago

I'll consider supporting $NO_COLOR for the repl output, alongside the improvements I mentioned previously. I had thought I had a none theme for the line editor, but I appear to be mistaken - I will add that as well. Lots of good ideas here that I should be able to get into Kuroko 1.4.1.

Meanwhile, I have tried very hard to reproduce your original issue myself, including setting up Fish and Terminator and using the Dracula theme (which I got from here: https://github.com/dracula/terminator), but I have been unable to - the gray I get is quite distinct from the background color. This is going to nerd snipe me...

Screenshot from 2023-08-30 18-22-59

Screenshot_2023-08-30_18-25-04

To help satisfy my curiosity, can you provide your Terminator config file and details on the version? I really want to get to the bottom of this - maybe there's a recent bug in Terminator or VTE to be squashed here.

kseistrup commented 12 months ago

This is going to nerd snipe me...

No, please do not waste time on the Dracula theme. I am using the “Dracula Pro” theme, which is a tad different from the free version.

(Side note: I have, for a long time considered moving away from Dracula [Pro] to e.g. Solarized Dark. However, the palette is being used in many terminal utilities, so it's not a change that can be accomplished swiftly, and I have had enough incentive to do so just yet.)

kseistrup commented 12 months ago

can you provide your Terminator config file

I believe that would violate the Dracula Pro TOS agreement, but perhaps I can disclose that I have in my ~/.bashrc:

printf '%b' '\e[40m' '\e[8]' # set default background to color 0 'dracula-bg'
printf '%b' '\e[37m' '\e[8]' # set default foreground to color 7 'dracula-fg'
printf '%b' '\e]P0282a36'    # redefine 'black'               as 'dracula-bg'

Color 0 is probably the offending colour.

klange commented 5 months ago

Kuroko now accepts the NO_COLOR environment variable to disable coloring the output of repr'd return values in the repl.

Additionally, rline (the rich line editing library) will accept NO_COLOR and disable themes - it still outputs ANSI escape sequences, as this is fundamental to how it works, but all of the color sequences will use "color 9", which should always set the default color. If this still isn't suitable, disabling rline with the -r flag is still an option.