alda-lang / alda

A music programming language for musicians. :notes:
https://alda.io
Eclipse Public License 2.0
5.58k stars 282 forks source link

CLI output is wonky #405

Open elydpg opened 2 years ago

elydpg commented 2 years ago

🐞 Bug report 🐞

Description

I'll let the below image speak for itself:

Screenshot (22)

Running the REPL causes PowerShell to recolour the screen in a weird way. Running this on cmd doesn't cause any recolouring, but you still get these ←[0m and ←[36m strings appearing.

daveyarwood commented 2 years ago

That's interesting! I thought that Powershell supported ANSI escape sequences. I found this article, for example. It looks like that's new in Powershell 7, though, and I'm not sure if the library for colored text that we're using in Alda is smart enough to recognize that environment and emit the right escape codes.

Alda does support the standard NO_COLOR environment variable, so you can remove those ANSI escape sequences by setting NO_COLOR to anything (e.g. NO_COLOR=true) in your environment variables. Can you give that a try?

elydpg commented 2 years ago

Screenshot (24)

Seems like it gets rid of the ←[0m like markings, but it doesn't get rid of the black recolouring of the screen...

daveyarwood commented 2 years ago

I don't know of anything that we're doing in Alda that would behave differently there than other programs. Are there color theme settings that you can change, such that you can set them to the same color, e.g. black?

elydpg commented 2 years ago

I mean, blue is the default colour of PowerShell... Seems odd that it should overwrite the colour in this way

daveyarwood commented 2 years ago

Do other programs behave this way in PowerShell, too?

elydpg commented 2 years ago

Not that I know of. Alda 1 doesn't have this problem.

daveyarwood commented 2 years ago

That's interesting! I wonder if this might be a peculiarity of Go.

alda-player isn't written in Go. Can you try running alda-player info and tell me if it has the same problem?

elydpg commented 2 years ago

I wonder if this might be a peculiarity of Go.

Not sure. Running alda-player info and even alda --help don't seem to cause the same problem. Only with the repl it seems...

Screenshot (25) Screenshot (26)

daveyarwood commented 2 years ago

OK, interesting.

My suspicion is that one of the Go libraries that we're using in the client is doing something strange. I don't have much bandwidth to devote to looking into this, but if a contributor felt like tackling this (or at least investigating further), it would be very much appreciated!

grasinski commented 2 years ago

Hi, I'd be willing to look into this!

KenP97 commented 2 years ago

I'm guessing the issue to be with the readline part, I changed the color library to "github.com/grookit/color" and managed to fix those ANSI escape characters printing out... but when the readline part starts the problems persists, and the background changes.

And I tried running readline separately and still the issue persisted even on a new project. so I'm guessing the issue is with the readline (we might need to configure it because they did mention it works on PowerShell)... ill look more into it till then image

KenP97 commented 2 years ago

Am I allowed to use a different library instead of readline?

KenP97 commented 2 years ago

image

daveyarwood commented 2 years ago

I answered you on Slack already, but for visibility here: