[GH-ISSUE #223] Does not render on Windows Terminal (preview) #123

Closed
opened 2026-03-03 16:22:33 +03:00 by kerem · 14 comments
Owner

Originally created by @kvnxiao on GitHub (Feb 12, 2020).
Original GitHub issue: https://github.com/mum4k/termdash/issues/223

Originally assigned to: @kvnxiao on GitHub.

Currently using https://github.com/microsoft/terminal from the window's app store (which is still in preview since it has not officially released yet) on my Windows machine.

I'm trying to make a cross-platform terminal application but it doesn't seem to work at all through Windows Terminal, regardless of the underlying shell I use (e.g. neither cmd nor powershell work when launched through Windows Terminal).

I am aware that termbox-go does not work through mintty or cygwin, but I can confirm that termbox-go and termui do work through the new Windows Terminal application.

Here is an example of a termui application running in windows terminal:
image

However when I try to build the TextInputDemo as an executable and run this through Windows Terminal, it does not show up at all.

image

It simply shows a flashing cursor at the top left.

Originally created by @kvnxiao on GitHub (Feb 12, 2020). Original GitHub issue: https://github.com/mum4k/termdash/issues/223 Originally assigned to: @kvnxiao on GitHub. Currently using https://github.com/microsoft/terminal from the window's app store (which is still in preview since it has not officially released yet) on my Windows machine. I'm trying to make a cross-platform terminal application but it doesn't seem to work at all through Windows Terminal, regardless of the underlying shell I use (e.g. neither cmd nor powershell work when launched through Windows Terminal). I am aware that termbox-go does not work through mintty or cygwin, **but I can confirm that termbox-go and termui _do_ work through the new Windows Terminal application**. Here is an example of a termui application running in windows terminal: ![image](https://user-images.githubusercontent.com/14130413/74332539-f540ff00-4d63-11ea-9cfb-0044ab3739e8.png) However when I try to build the [TextInputDemo](https://github.com/mum4k/termdash/blob/master/widgets/textinput/textinputdemo/textinputdemo.go) as an executable and run this through Windows Terminal, it does not show up at all. ![image](https://user-images.githubusercontent.com/14130413/74332605-1c97cc00-4d64-11ea-83ba-7ad0552d4bba.png) It simply shows a flashing cursor at the top left.
kerem 2026-03-03 16:22:33 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@mum4k commented on GitHub (Feb 12, 2020):

Thank you for the bug report. I currently have no easy way to test this on windows so hoping to get some help if you have the time.

Good to hear that termbox works in the terminal. Termdash completely depends on termbox-go when it comes to rendering, so it might just be the case of some missing / different initialization of termbox. Would you be able to experiment, find the differences between how termdash and termui initialize termbox? That is where the answer might be. Once we have the differences, we can easily modify the code to fix this.

<!-- gh-comment-id:585428912 --> @mum4k commented on GitHub (Feb 12, 2020): Thank you for the bug report. I currently have no easy way to test this on windows so hoping to get some help if you have the time. Good to hear that termbox works in the terminal. Termdash completely depends on termbox-go when it comes to rendering, so it might just be the case of some missing / different initialization of termbox. Would you be able to experiment, find the differences between how termdash and termui initialize termbox? That is where the answer might be. Once we have the differences, we can easily modify the code to fix this.
Author
Owner

@kvnxiao commented on GitHub (Feb 12, 2020):

I can look into it sometime this week.

I have also noticed that the text demo here: https://github.com/mum4k/termdash/tree/master/widgets/text/textdemo
simply does not work on Windows, even when launched from conhost through cmd or powershell (and not Windows Terminal).

The text is mangled, and the rotating / scrolling lines of text does not show up properly.

I'll get a screenshot in a bit and post it here for tracking.

P.S. I really like the way termdash is written from an API standpoint, so I would definitely like to see it work on Windows

<!-- gh-comment-id:585439731 --> @kvnxiao commented on GitHub (Feb 12, 2020): I can look into it sometime this week. I have also noticed that the text demo here: https://github.com/mum4k/termdash/tree/master/widgets/text/textdemo simply does not work on Windows, even when launched from conhost through cmd or powershell (and not Windows Terminal). The text is mangled, and the rotating / scrolling lines of text does not show up properly. I'll get a screenshot in a bit and post it here for tracking. P.S. I really like the way termdash is written from an API standpoint, so I would definitely like to see it work on Windows
Author
Owner

@mum4k commented on GitHub (Feb 12, 2020):

That is interesting, do the other demos work or none of them work? I do seem to recall that there was some issue on windows around setting the right font (one that supports the unicode characters that are used to draw borders, etc). It might be unrelated though, there was some relevant discussion here: https://github.com/mum4k/termdash/issues/99

Looking forward to hear from you after you experiment with it and thanks.

<!-- gh-comment-id:585475410 --> @mum4k commented on GitHub (Feb 12, 2020): That is interesting, do the other demos work or none of them work? I do seem to recall that there was some issue on windows around setting the right font (one that supports the unicode characters that are used to draw borders, etc). It might be unrelated though, there was some relevant discussion here: https://github.com/mum4k/termdash/issues/99 Looking forward to hear from you after you experiment with it and thanks.
Author
Owner

@kvnxiao commented on GitHub (Feb 13, 2020):

Kind of unrelated to the main issue

FYI, here is what the textdemo one looks like running through regular conhost (directly opened through the built .exe)

image

Seems like using non-english languages like having the Chinese characters screw up the offsets a bit. I blame Windows for this.

Removing the Chinese characters seems to prevent the issue from popping up, and the scrolling text shows up properly now:

image

A bit of a shame but it might mean that the Windows conhost can't properly support monospaced CJK fonts to take up only 1 column space on screen for whatever reason.

In summary: all the widgets work on Windows when ran directly or through cmd/powershell, which uses the default conhost.exe, but NOT Windows Terminal, which is the main issue here

<!-- gh-comment-id:585632094 --> @kvnxiao commented on GitHub (Feb 13, 2020): **Kind of unrelated to the main issue** FYI, here is what the textdemo one looks like running through regular conhost (directly opened through the built .exe) ![image](https://user-images.githubusercontent.com/14130413/74420235-17e11f80-4e19-11ea-9bf6-cd9945072af7.png) Seems like using non-english languages like having the Chinese characters screw up the offsets a bit. I blame Windows for this. Removing the Chinese characters seems to prevent the issue from popping up, and the scrolling text shows up properly now: ![image](https://user-images.githubusercontent.com/14130413/74420479-82925b00-4e19-11ea-8835-36d14e6f9af4.png) A bit of a shame but it might mean that the Windows conhost can't properly support monospaced CJK fonts to take up only 1 column space on screen for whatever reason. In summary: **all the widgets work on Windows when ran directly or through cmd/powershell, which uses the default conhost.exe, but NOT Windows Terminal, which is the main issue here**
Author
Owner

@kvnxiao commented on GitHub (Feb 13, 2020):

For Windows Terminal:

So it seems like there is an issue with whenever an empty space exists between the text and the next element (whether the next element is another container, or the border of the current container).

image

If you could point me to the right directly as to how exactly the code is rendering the different widgets at different locations within the terminal view? (e.g. how is each line created)

I'm uploading a gif as well to show that some lines do end up showing up as long as text needs to be updated at the current row (in this case it is from the scrolling text widget).

SpCM67djHV

<!-- gh-comment-id:585658156 --> @kvnxiao commented on GitHub (Feb 13, 2020): For Windows Terminal: So it seems like there is an issue with whenever an empty space exists between the text and the next element (whether the next element is another container, or the border of the current container). ![image](https://user-images.githubusercontent.com/14130413/74425161-36e3af80-4e21-11ea-84e9-432fd5c2001a.png) If you could point me to the right directly as to how exactly the code is rendering the different widgets at different locations within the terminal view? (e.g. how is each line created) I'm uploading a gif as well to show that some lines do end up showing up as long as text needs to be updated at the current row (in this case it is from the scrolling text widget). ![SpCM67djHV](https://user-images.githubusercontent.com/14130413/74425535-da34c480-4e21-11ea-8347-4e82b96fcc81.gif)
Author
Owner

@kvnxiao commented on GitHub (Feb 13, 2020):

After further exploring,

I found that the culprit was termbox-go itself with how it renders. (maybe?)

I tested using tcell and it's termbox api compatibility here https://github.com/gdamore/tcell/blob/master/termbox/compat.go

and guess what? It works!
It even works with the Chinese text.

image

It also works with the textinputdemo which was the one I originally tried to run as shown in the first comment:

image

The only thing with the tcell termbox-compatibility is that the input events do not work properly, but this was obviously a quick replacement test to see if it would fix the rendering.

At this point I'm not sure whether I should be blaming termbox-go's way of rendering or Windows Terminal for still being a preview (maybe the 1.0.0 release of Windows Terminal will fix how termbox-go renders?).

My recommendation would be to directly pursue https://github.com/mum4k/termdash/issues/100 so that different terminal rendering backends can be used, seeing as this appears to render fine on Windows when using tcell.

This would obviously entail more than just using the termbox compat file from tcell, since there are certain issues with the compat api:

  1. Mouse events are not supported through the termbox compat api.
  2. If the only change was to use the termbox compat api by changing the imports, then the keyboard events also end up containing both a key and a character, which causes termdash to panic whenever a key is pressed.
<!-- gh-comment-id:585675228 --> @kvnxiao commented on GitHub (Feb 13, 2020): After further exploring, I found that the culprit was termbox-go itself with how it renders. (maybe?) I tested using **tcell** and it's termbox api compatibility here https://github.com/gdamore/tcell/blob/master/termbox/compat.go and guess what? **It works!** It even works with the Chinese text. ![image](https://user-images.githubusercontent.com/14130413/74428553-4108ac80-4e27-11ea-9c37-d0704a18f007.png) It also works with the textinputdemo which was the one I originally tried to run as shown in the first comment: ![image](https://user-images.githubusercontent.com/14130413/74430313-a3af7780-4e2a-11ea-883f-fa0ec6809488.png) The only thing with the tcell termbox-compatibility is that the input events do not work properly, but this was obviously a quick replacement test to see if it would fix the rendering. At this point I'm not sure whether I should be blaming termbox-go's way of rendering or Windows Terminal for still being a preview (maybe the 1.0.0 release of Windows Terminal will fix how termbox-go renders?). My recommendation would be to directly pursue https://github.com/mum4k/termdash/issues/100 so that different terminal rendering backends can be used, seeing as this appears to render fine on Windows when using tcell. This would obviously entail more than just using the termbox compat file from tcell, since there are certain issues with the compat api: 1. [Mouse events are not supported through the termbox compat api](https://github.com/gdamore/tcell/blob/master/termbox/compat.go#L296-L299). 2. If the only change was to use the termbox compat api by changing the imports, then the keyboard events also end up containing both a key and a character, [which causes termdash to panic whenever a key is pressed](https://github.com/mum4k/termdash/blob/master/terminal/termbox/event.go#L91).
Author
Owner

@mum4k commented on GitHub (Feb 13, 2020):

This was really helpful investigation, thank you @kvnxiao.

I agree that pursuing #100 sounds like the right option. When I started developing Termdash, I had a replacement of termbox in mind. All the terminal interactions happen through the terminalapi layer:

https://github.com/mum4k/termdash/tree/master/terminal/terminalapi

Where termbox-go is just one implementation of that api:
https://github.com/mum4k/termdash/tree/master/terminal/termbox

I think the right way forward would be to add a tcell implementation of the same API. That is where we can handle any necessary translations of keyboard events, mouse events, etc.

Is this something you would be interested in working on?

<!-- gh-comment-id:585774206 --> @mum4k commented on GitHub (Feb 13, 2020): This was really helpful investigation, thank you @kvnxiao. I agree that pursuing #100 sounds like the right option. When I started developing Termdash, I had a replacement of termbox in mind. All the terminal interactions happen through the terminalapi layer: https://github.com/mum4k/termdash/tree/master/terminal/terminalapi Where termbox-go is just one implementation of that api: https://github.com/mum4k/termdash/tree/master/terminal/termbox I think the right way forward would be to add a tcell implementation of the same API. That is where we can handle any necessary translations of keyboard events, mouse events, etc. Is this something you would be interested in working on?
Author
Owner

@kvnxiao commented on GitHub (Feb 13, 2020):

This is something I can definitely look into trying out on my own branch.

<!-- gh-comment-id:586021696 --> @kvnxiao commented on GitHub (Feb 13, 2020): This is something I can definitely look into trying out on my own branch.
Author
Owner

@mum4k commented on GitHub (Feb 14, 2020):

Great, please feel free to reach out with any questions or concerns and thank you for your help!

<!-- gh-comment-id:586032692 --> @mum4k commented on GitHub (Feb 14, 2020): Great, please feel free to reach out with any questions or concerns and thank you for your help!
Author
Owner

@kvnxiao commented on GitHub (Feb 15, 2020):

I've created a few commits to my forked repo with a new tcell backend that implements the terminalapi interface.

https://github.com/mum4k/termdash/compare/master...kvnxiao:master

This includes proper colour setting, keyboard, and mouse events.

There are a few caveats (differences from termbox-go) I'd like to discuss before moving forward:

  1. The tcell terminal autodetects colour support by default, but for termbox and for the terminalapi in termdash we have an explicit option to set the colour output mode. Do we still want to have an option to set the output mode when using the tcell implementation?
  2. Tcell's mouse support is superb as it supports multiple buttons being detected for a single mouse event (e.g. mouse1 + mouse2 pressed together) using an int16 bitmask. With the current implementation of the mouse keys used by terminalapi, we only support a "singular" mouse event, so for now I've made it so that multi-button events return ButtonUnknown without returning an error. What do you think about this?

I think moving forward, maybe it would be cool to support multi-mouse buttons from the terminalapi side as well, but I am not sure how termbox handles that.

And before I open the PR, is there anything I need to be weary of? For example, what do I do about license headers?

<!-- gh-comment-id:586533846 --> @kvnxiao commented on GitHub (Feb 15, 2020): I've created a few commits to my forked repo with a new tcell backend that implements the terminalapi interface. https://github.com/mum4k/termdash/compare/master...kvnxiao:master This includes proper colour setting, keyboard, and mouse events. There are a few caveats (differences from termbox-go) I'd like to discuss before moving forward: 1. The tcell terminal autodetects colour support by default, but for termbox and for the terminalapi in termdash we have an explicit option to set the colour output mode. Do we still want to have an option to set the output mode when using the tcell implementation? 2. Tcell's mouse support is superb as it supports multiple buttons being detected for a single mouse event (e.g. mouse1 + mouse2 pressed together) using an int16 bitmask. With the current implementation of the mouse keys used by terminalapi, we only support a "singular" mouse event, so for now I've made it so that multi-button events return ButtonUnknown without returning an error. What do you think about this? I think moving forward, maybe it would be cool to support multi-mouse buttons from the terminalapi side as well, but I am not sure how termbox handles that. And before I open the PR, is there anything I need to be weary of? For example, what do I do about license headers?
Author
Owner

@mum4k commented on GitHub (Feb 15, 2020):

That looks really good, glad to hear it worked out. Thank you for raising the two discussion points. In general - we don't have to limit ourselves to the functionality provided by termbox-go, i.e. it would be ok to even modify terminalapi as long as it remains backward compatible with termbox-go and with the existing functionality utilised by termdash. With that said, I don't think we should attempt to do that in a single PR as it might bloat the scope. We can add tcell now with the same functionality as termbox-go and expand on it later if desired.

  1. I am assuming this is referring to the termbox.ColorMode option:
    github.com/mum4k/termdash@68bf0566e6/terminal/termbox/termbox.go (L45-L51)

If yes, the way I see it - this is an optional argument specific to termbox-go, it isn't declared in terminalapi and doesn't have to be supported by the tcell implementation assuming everything works without it.

  1. Support of multiple mouse buttons sounds really cool, I didn't know tcell had that. As per the reasoning above I would advise towards deferring this to a later PR. I think your choice of returning ButtonUnknown is the correct one, returning an error would end up in termdash terminating on these events (assuming the default error handler 1). Let's make sure we document this somewhere in the new tcell package.

If we choose to work on multiple mouse buttons in the future, we can modify terminalapi and indicate that this is only supported with the tcell terminal and not termbox. We could come up with some form of a capability registration. So that individual terminal implementation register which parts of the events they are capable off. That way we could return an error if the user creates termbox-go but expects to get multiple mouse button events somewhere down the stack. Or we could decide to completely abandon termbox-go in the future.

Another interesting thing we should look at is performance. I wonder what is the performance impact of switching from termbox-go to termdash CPU and Memory wise. Have you thought about running termdashdemo with pprof using the two terminal implementations and compare (https://blog.golang.org/profiling-go-programs)? Of course this doesn't have to be done for the current PR, maybe we can open a separate issue to track this effort.

As for other things to be aware off, the automatic scripts that run when you create the PR will inform you about most of these:

Hope this helps, please let me know if you have any other questions and thanks again for improving termdash.

<!-- gh-comment-id:586590243 --> @mum4k commented on GitHub (Feb 15, 2020): That looks really good, glad to hear it worked out. Thank you for raising the two discussion points. In general - we don't have to limit ourselves to the functionality provided by termbox-go, i.e. it would be ok to even modify terminalapi as long as it remains backward compatible with termbox-go and with the existing functionality utilised by termdash. With that said, I don't think we should attempt to do that in a single PR as it might bloat the scope. We can add tcell now with the same functionality as termbox-go and expand on it later if desired. 1. I am assuming this is referring to the termbox.ColorMode option: https://github.com/mum4k/termdash/blob/68bf0566e6ec8effaf6e83400ef0046347a5f5f1/terminal/termbox/termbox.go#L45-L51 If yes, the way I see it - this is an optional argument specific to termbox-go, it isn't declared in terminalapi and doesn't have to be supported by the tcell implementation assuming everything works without it. 2. Support of multiple mouse buttons sounds really cool, I didn't know tcell had that. As per the reasoning above I would advise towards deferring this to a later PR. I think your choice of returning ButtonUnknown is the correct one, returning an error would end up in termdash terminating on these events (assuming the default error handler [1]). Let's make sure we document this somewhere in the new tcell package. If we choose to work on multiple mouse buttons in the future, we can modify terminalapi and indicate that this is only supported with the tcell terminal and not termbox. We could come up with some form of a capability registration. So that individual terminal implementation register which parts of the events they are capable off. That way we could return an error if the user creates termbox-go but expects to get multiple mouse button events somewhere down the stack. Or we could decide to completely abandon termbox-go in the future. Another interesting thing we should look at is performance. I wonder what is the performance impact of switching from termbox-go to termdash CPU and Memory wise. Have you thought about running termdashdemo with pprof using the two terminal implementations and compare (https://blog.golang.org/profiling-go-programs)? Of course this doesn't have to be done for the current PR, maybe we can open a separate issue to track this effort. As for other things to be aware off, the automatic scripts that run when you create the PR will inform you about most of these: - there is a script that generates license headers, I usually just run that (https://github.com/mum4k/termdash/blob/master/internal/scripts/autogen_licences.sh). I just noticed that it still contains year 2018, we should probably update that to 2020 now. - because I work for Google, all contributors have to sign the Google CLA, the process is documented in [CONTRIBUTING.md](https://github.com/mum4k/termdash/blob/master/CONTRIBUTING.md). - please create the PR against the *devel* branch instead of *master* and update the [CHANGELOG.md](https://github.com/mum4k/termdash/blob/master/CHANGELOG.md) accordingly. I will merge this into master when releasing. - we should probably update the documentation as well, indicating that we now have two terminal implementations and give two examples. The wiki should be editable by anyone, so feel free to edit directly, or I am happy to help with this if you would prefer I do it. Related pages: -- https://github.com/mum4k/termdash/wiki/Terminal-API -- https://github.com/mum4k/termdash/wiki/Termbox-API -- and we should probably create a new one for tcell Hope this helps, please let me know if you have any other questions and thanks again for improving termdash. [1]: https://github.com/mum4k/termdash/blob/68bf0566e6ec8effaf6e83400ef0046347a5f5f1/termdash.go#L64-L72
Author
Owner

@kvnxiao commented on GitHub (Feb 16, 2020):

Do you think it would be a good idea to have some sort of build flag to choose the implementation when building a project that uses termdash, so that the other implementation simply isn’t included as a dependency, thus resulting in smaller file sizes? (Not exactly sure how I would go about doing this)

I will work on the rest of the changes for the PR sometime after next week as I’ve just gotten back home for a week’s worth of break.

<!-- gh-comment-id:586657359 --> @kvnxiao commented on GitHub (Feb 16, 2020): Do you think it would be a good idea to have some sort of build flag to choose the implementation when building a project that uses termdash, so that the other implementation simply isn’t included as a dependency, thus resulting in smaller file sizes? (Not exactly sure how I would go about doing this) I will work on the rest of the changes for the PR sometime after next week as I’ve just gotten back home for a week’s worth of break.
Author
Owner

@mum4k commented on GitHub (Feb 16, 2020):

That is a good point, but I think that may already work as desired Considering that termbox and tcell are separate packages, user building termdash imports one of them, initializes the chosen terminal implementation and passes that into the container instance, e.g.:

github.com/mum4k/termdash@68bf0566e6/termdashdemo/termdashdemo.go (L470-L479)

So if the user only imports the tcell package and doesn't import the termbox package, the termbox package and any of its dependencies won't get linked or included in the build. This of course assumes that we only import termbox-go inside the termbox package. Please let me know if I am missing anything.

Enjoy your break at home and talk to you afterwards. We have a long weekend here so I too am taking it easy.

<!-- gh-comment-id:586720137 --> @mum4k commented on GitHub (Feb 16, 2020): That is a good point, but I think that may already work as desired Considering that termbox and tcell are separate packages, user building termdash imports one of them, initializes the chosen terminal implementation and passes that into the container instance, e.g.: https://github.com/mum4k/termdash/blob/68bf0566e6ec8effaf6e83400ef0046347a5f5f1/termdashdemo/termdashdemo.go#L470-L479 So if the user only imports the tcell package and doesn't import the termbox package, the termbox package and any of its dependencies won't get linked or included in the build. This of course assumes that we only import termbox-go inside the termbox package. Please let me know if I am missing anything. Enjoy your break at home and talk to you afterwards. We have a long weekend here so I too am taking it easy.
Author
Owner

@kvnxiao commented on GitHub (Feb 29, 2020):

Put up the PR, probably a few things will still need to be changed before it looks good to merge, let me know!

<!-- gh-comment-id:592912568 --> @kvnxiao commented on GitHub (Feb 29, 2020): Put up the PR, probably a few things will still need to be changed before it looks good to merge, let me know!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/termdash#123
No description provided.