mc display messed up #166

Closed
opened 2026-01-30 21:44:20 +00:00 by claunia · 26 comments
Owner

Originally created by @bitcrazed on GitHub (Feb 16, 2018).

From @axelfontaine on April 11, 2017 12:24

Here is what I did:

  • Updated Win 10 x64 system with BashOnWindows to Creators Update (Microsoft Windows [Version 10.0.15063])
  • lxrun /uninstall /full
  • lxrun /install
  • Run bash.exe
  • sudo apt-get install mc
  • mc

Expected to see correct rendering, instead I got this:
image

Copied from original issue: Microsoft/WSL#1879

Originally created by @bitcrazed on GitHub (Feb 16, 2018). _From @axelfontaine on April 11, 2017 12:24_ Here is what I did: - Updated Win 10 x64 system with BashOnWindows to Creators Update (`Microsoft Windows [Version 10.0.15063]`) - `lxrun /uninstall /full` - `lxrun /install` - Run `bash.exe` - `sudo apt-get install mc` - `mc` Expected to see correct rendering, instead I got this: ![image](https://cloud.githubusercontent.com/assets/684824/24908978/75cb2bb0-1ec2-11e7-94b1-be4ac0038b27.png) _Copied from original issue: Microsoft/WSL#1879_
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @axelfontaine on April 11, 2017 12:33

More strange behavior:

  • exiting and relaunching mc changes the TrueType font of the console window!
  • resizing the window while mc is running changes the color settings of the console window!

(yes, you read that correctly!)

After forcing the font back to Consolas and resizing the window with the mouse (by dragging the border), the rendering appears mostly correct, except

  • for the new permanently overlaid scroll bars (no amount of resizing of the window with the mouse makes them go away)
  • the background & foreground color of the prompt line

image

@bitcrazed commented on GitHub (Feb 16, 2018): _From @axelfontaine on April 11, 2017 12:33_ More strange behavior: - exiting and relaunching `mc` changes the TrueType font of the console window! - resizing the window while `mc` is running changes the color settings of the console window! (yes, you read that correctly!) After forcing the font back to `Consolas` and resizing the window with the mouse (by dragging the border), the rendering appears mostly correct, except - for the new permanently overlaid scroll bars (no amount of resizing of the window with the mouse makes them go away) - the background & foreground color of the prompt line ![image](https://cloud.githubusercontent.com/assets/684824/24909287/980b8c32-1ec3-11e7-9e0e-2d8ced521fa6.png)
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @ryanerwin on April 12, 2017 7:37

Perhaps this is terminal definition or ncurses related... Seeing the same behavior in dialog...
dialog --yesno "Would you like a dialog?" 10 50

image

@bitcrazed commented on GitHub (Feb 16, 2018): _From @ryanerwin on April 12, 2017 7:37_ Perhaps this is terminal definition or ncurses related... Seeing the same behavior in dialog... ```dialog --yesno "Would you like a dialog?" 10 50``` ![image](https://cloud.githubusercontent.com/assets/2156415/24946458/9041c840-1f95-11e7-95fa-b726d12beaef.png)
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @zadjii-msft on April 13, 2017 16:41

@axelfontaine I can actually explain the peculiarity of the fonts switching back once you close mc!

As it so happens, mc runs in the "Alternate Buffer" of the terminal. In conhost, this buffer just so happens to have it's own separate set of settings, independent of the "main" buffer (which is running your shell that launched mc). So, if you use the property pages to set the settings while you're in the alt buffer, the changes don't propagate to the main buffer.

I'd say for now, the best advice I have is don't change the properties while you're in the alt buffer. I've opened MSFT:11643965 to try and address that.

As far as the bars being messed up lengths, I believe this is a font rendering issue. I've seen it before, but IIRC there was nothing I could to about it. It's kinda related to #1907

@bitcrazed commented on GitHub (Feb 16, 2018): _From @zadjii-msft on April 13, 2017 16:41_ @axelfontaine I can actually explain the peculiarity of the fonts switching back once you close `mc`! As it so happens, `mc` runs in the "Alternate Buffer" of the terminal. In conhost, this buffer just so happens to have it's own separate set of settings, independent of the "main" buffer (which is running your shell that launched `mc`). So, if you use the property pages to set the settings while you're in the alt buffer, the changes don't propagate to the main buffer. I'd say for now, the best advice I have is don't change the properties while you're in the alt buffer. I've opened MSFT:11643965 to try and address that. As far as the bars being messed up lengths, I believe this is a font rendering issue. I've seen it before, but IIRC there was nothing I could to about it. It's kinda related to #1907
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @axelfontaine on April 13, 2017 17:18

@zadjii-msft Thanks for looking into this. My display is scaled at 100% so not related to #1907

Also if you look carefully it clearly shows the wrong characters being printed at various positions in the console, not some scaling issue. I have tried with both raster and TT fonts at various sizes. Same issue.

Also don't forget the weird scrollbar behavior.

@bitcrazed commented on GitHub (Feb 16, 2018): _From @axelfontaine on April 13, 2017 17:18_ @zadjii-msft Thanks for looking into this. My display is scaled at 100% so not related to #1907 Also if you look carefully it clearly shows the wrong characters being printed at various positions in the console, not some scaling issue. I have tried with both raster and TT fonts at various sizes. Same issue. Also don't forget the weird scrollbar behavior.
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @zadjii-msft on April 13, 2017 18:8

@axelfontaine Yea, #1907 says it's a DPI thing, but it's really less about the DPI and more about the fact that those characters are ambiguous width. Some fonts are simply going to work better for this scenario than others.

BUT NEVER RASTER FONTS. Raster fonts have a whole host of problems, so protip, never use them.

I have no idea how you got the scroll bars to show up. I've been playing with an mc window for a bit now and I can't seem to get them to show up.

The prompt line's color change again came from changing the settings - It looks like in mc the settings page picks up the attributes of the character at 0,0 (or more likely, 'mc' left those attributes as the current ones) so submitting the settings page makes those colors the default for the buffer.

@bitcrazed commented on GitHub (Feb 16, 2018): _From @zadjii-msft on April 13, 2017 18:8_ @axelfontaine Yea, #1907 says it's a DPI thing, but it's really less about the DPI and more about the fact that those characters are ambiguous width. Some fonts are simply going to work better for this scenario than others. BUT NEVER RASTER FONTS. Raster fonts have a whole host of problems, so protip, never use them. I have no idea how you got the scroll bars to show up. I've been playing with an `mc` window for a bit now and I can't seem to get them to show up. The prompt line's color change again came from changing the settings - It looks like in `mc` the settings page picks up the attributes of the character at 0,0 (or more likely, 'mc' left those attributes as the current ones) so submitting the settings page makes those colors the default for the buffer.
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @axelfontaine on April 14, 2017 9:37

More testing keeps on revealing more weird behavior. When mc is running (and only then) resizing the window down to 1 line vertical, causes the whole console window to crash and terminate. This does not happen outside mc.

@bitcrazed commented on GitHub (Feb 16, 2018): _From @axelfontaine on April 14, 2017 9:37_ More testing keeps on revealing more weird behavior. When `mc` is running (and only then) resizing the window down to 1 line vertical, causes the whole console window to crash and terminate. This does not happen outside mc.
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @zadjii-msft on April 17, 2017 16:7

Ooof. That's definitely a bug too. To avoid polluting this issue, I opened a new issue to track that particularly, #1938. Thanks fir the investigation @axelfontaine!

@bitcrazed commented on GitHub (Feb 16, 2018): _From @zadjii-msft on April 17, 2017 16:7_ Ooof. That's definitely a bug too. To avoid polluting this issue, I opened a new issue to track that particularly, #1938. Thanks fir the investigation @axelfontaine!
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @Line117 on April 17, 2017 16:24

I solved the problems with the windows console. I use PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/)

@bitcrazed commented on GitHub (Feb 16, 2018): _From @Line117 on April 17, 2017 16:24_ I solved the problems with the windows console. I use PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/)
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @lilred on April 18, 2017 2:21

@zadjii-msft I'm intrigued by this "alternate buffer"! Do you know of any blog posts/readings on the topic?

@bitcrazed commented on GitHub (Feb 16, 2018): _From @lilred on April 18, 2017 2:21_ @zadjii-msft I'm intrigued by this "alternate buffer"! Do you know of any blog posts/readings on the topic?
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @zadjii-msft on April 18, 2017 16:0

@lilred Well I guess there's https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx#Alternate_Screen_Buffer__ but it looks like I didn't write all that much there :P

There's also http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer:

Xterm maintains two screen buffers. The normal screen buffer allows you
to scroll back to view saved lines of output up to the maximum set by
the saveLines resource. The alternate screen buffer is exactly as large
as the display, contains no additional saved lines. When the alternate
screen buffer is active, you cannot scroll back to view saved lines.
Xterm provides control sequences and menu entries for switching between
the two.

Different terminals handle it differently, and not all TERM settings support it the same way. I tried to implement it as close to xterm as possible.

@bitcrazed commented on GitHub (Feb 16, 2018): _From @zadjii-msft on April 18, 2017 16:0_ @lilred Well I guess there's [https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx#Alternate_Screen_Buffer__](https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx#Alternate_Screen_Buffer__) but it looks like I didn't write all that much there :P There's also http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer: > Xterm maintains two screen buffers. The normal screen buffer allows you to scroll back to view saved lines of output up to the maximum set by the saveLines resource. The alternate screen buffer is exactly as large as the display, contains no additional saved lines. When the alternate screen buffer is active, you cannot scroll back to view saved lines. Xterm provides control sequences and menu entries for switching between the two. Different terminals handle it differently, and not all TERM settings support it the same way. I tried to implement it as close to xterm as possible.
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @zadjii-msft on May 25, 2017 23:28

Okay, I'm gonna do some cleanup of issues here. There are three issues in this thread:

  1. Box drawing characters don't render right in some fonts
  2. Resizing the buffer to 0 lines causes conhost.exe to crash
  3. Changing the settings in the alt buffer doesn't propagate to the main buffer.

Now, for details.

  1. is a dupe of #2010, #2099 and others, but not #1907. #1907 is for all the ambiguous width chars, while the others are specific to the box-drawing range, 0x2500-0x257F. This portion of the issue has been checked in, and should make your experience with tmux, mc, and others generally better.

  2. This has also been checked in, and was duped into #1938.

  3. This has NOT been fixed. I'm pulling that out into #2157.

I'm gonna mark this one as fixinbound, #2010, #2099 as closed dupes to this.

@bitcrazed commented on GitHub (Feb 16, 2018): _From @zadjii-msft on May 25, 2017 23:28_ Okay, I'm gonna do some cleanup of issues here. There are three issues in this thread: 1. Box drawing characters don't render right in some fonts 2. Resizing the buffer to 0 lines causes conhost.exe to crash 3. Changing the settings in the alt buffer doesn't propagate to the main buffer. Now, for details. 1. is a dupe of #2010, #2099 and others, but _not_ #1907. #1907 is for all the ambiguous width chars, while the others are specific to the box-drawing range, 0x2500-0x257F. This portion of the issue has been checked in, and should make your experience with tmux, mc, and others generally better. 2. This has also been checked in, and was duped into #1938. 3. This has NOT been fixed. I'm pulling that out into #2157. I'm gonna mark this one as fixinbound, #2010, #2099 as closed dupes to this.
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @fanthos on July 11, 2017 9:55

I found a temprary work around is to use mintty with wsltty.
Tested with dialog and aptitude, and it works as expected.

@bitcrazed commented on GitHub (Feb 16, 2018): _From @fanthos on July 11, 2017 9:55_ I found a temprary work around is to use mintty with wsltty. Tested with dialog and aptitude, and it works as expected.
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @ryanerwin on September 30, 2017 2:55

FYI, mc works great in the most recent inisder builds...
no need to use wsltty at this point

@bitcrazed commented on GitHub (Feb 16, 2018): _From @ryanerwin on September 30, 2017 2:55_ FYI, mc works great in the most recent inisder builds... no need to use wsltty at this point
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @axelfontaine on October 18, 2017 10:52

Small update using Fall Creators Update: first of all, things have improved a lot! Unfortunately there are still some quirks:

image

See the right and bottom side of the window.

What did I do:

  • sudo apt-get install mc
  • mc
  • wildly resized window in all directions
@bitcrazed commented on GitHub (Feb 16, 2018): _From @axelfontaine on October 18, 2017 10:52_ Small update using Fall Creators Update: first of all, things have improved a lot! Unfortunately there are still some quirks: ![image](https://user-images.githubusercontent.com/684824/31715173-0a136da2-b403-11e7-84ff-41e982f8adeb.png) See the right and bottom side of the window. What did I do: - `sudo apt-get install mc` - `mc` - wildly resized window in all directions
Author
Owner

@axelfontaine commented on GitHub (May 2, 2018):

Status after April Update: No improvement over Fall Creators Update

@axelfontaine commented on GitHub (May 2, 2018): Status after April Update: No improvement over Fall Creators Update
Author
Owner

@bitcrazed commented on GitHub (May 2, 2018):

@axelfontaine Could you share some details on your PC?

  • Manufacturer
  • Model
  • CPU
  • Memory
  • Disk (max/used)
  • RAM

Unable to repro your border issue above - do you have more specific repro steps?

@bitcrazed commented on GitHub (May 2, 2018): @axelfontaine Could you share some details on your PC? - Manufacturer - Model - CPU - Memory - Disk (max/used) - RAM Unable to repro your border issue above - do you have more specific repro steps?
Author
Owner

@axelfontaine commented on GitHub (May 2, 2018):

Repro steps are still the same. Open mc. Then drag for example window corner to resize rapidly from 80x25 to say 5x1 and back a few times.

PC is a homemade desktop with i7-4770, 16gb ram and plenty of available diskpace on a SATA Samsung 840 SSD.

@axelfontaine commented on GitHub (May 2, 2018): Repro steps are still the same. Open mc. Then drag for example window corner to resize rapidly from 80x25 to say 5x1 and back a few times. PC is a homemade desktop with i7-4770, 16gb ram and plenty of available diskpace on a SATA Samsung 840 SSD.
Author
Owner

@axelfontaine commented on GitHub (May 3, 2018):

Ok, here are the definite repro steps, successfully tried with both bash.exe and fresh Ubuntu install from Windows Store:

  1. sudo apt-get install mc
  2. ensure the console window has no visible scrollbars! (adjust buffer accordingly to make it so)
  3. mc
  4. resize window vertically by dragging with mouse to zero lines and back
  5. Bingo!
@axelfontaine commented on GitHub (May 3, 2018): Ok, here are the definite repro steps, successfully tried with both bash.exe and fresh Ubuntu install from Windows Store: 1. `sudo apt-get install mc` 2. **ensure the console window has no visible scrollbars!** (adjust buffer accordingly to make it so) 3. `mc` 4. resize window vertically by dragging with mouse to zero lines and back 5. Bingo!
Author
Owner

@bitcrazed commented on GitHub (May 3, 2018):

Thanks for the report @axelfontaine. We'll take a look at improving some of the layout/rendering in our bug-fix phase, once we've gotten past feature-complete for the next release.

@bitcrazed commented on GitHub (May 3, 2018): Thanks for the report @axelfontaine. We'll take a look at improving some of the layout/rendering in our bug-fix phase, once we've gotten past feature-complete for the next release.
Author
Owner

@alganet commented on GitHub (Mar 25, 2019):

To reproduce it in the current version: printf '\033[?1049h; cat <ANY_FILE_WITH_TABS>;'

The file output will be garbage. It's doubling lines. Each line double contains only the first character of the line at the last position in the terminal. The original line is missing the first character.

Seems to be a silly offset bug. The CSI ?47h and ?47l should also behave exactly the same way, but they aren't implemented. Fixing it will probably make vi behave like intended (it returns the previous shell buffer on quit) (edit: vi works, I'm trying to find out what it does).

Edit: The file needs to contain tabs.

@alganet commented on GitHub (Mar 25, 2019): To reproduce it in the current version: `printf '\033[?1049h; cat <ANY_FILE_WITH_TABS>;'` The file output will be garbage. It's doubling lines. Each line double contains only the first character of the line at the last position in the terminal. The original line is missing the first character. Seems to be a silly offset bug. The CSI `?47h` and `?47l` should also behave exactly the same way, but they aren't implemented. Fixing it will probably make `vi` behave like intended (it returns the previous shell buffer on quit) (edit: vi works, I'm trying to find out what it does). Edit: The file needs to contain tabs.
Author
Owner

@alganet commented on GitHub (Mar 27, 2019):

To reproduce it in the current version: printf '\033[?1049h; cat <ANY_FILE_WITH_TABS>;'

The file output will be garbage. It's doubling lines. Each line double contains only the first character of the line at the last position in the terminal. The original line is missing the first character.

Seems to be a silly offset bug. The CSI ?47h and ?47l should also behave exactly the same way, but they aren't implemented. Fixing it will probably make vi behave like intended (it returns the previous shell buffer on quit) (edit: vi works, I'm trying to find out what it does).

Edit: The file needs to contain tabs.

After fiddling around with many applications I've discovered that if I switch to the alternate buffer, I need to set tabs manually:

	tcont=0
        tabsize=4
	while test $tcont -lt ${COLUMNS}
	do
		echo -ne '\033['$tabsize'C\033H' 
		tcont=$((tcont + tabsize))
	done
	echo -ne '\r'

Apparently the previous tabs were set to COLUMNS - 1, making the last character in each line break unintentionally.

By using this snippet I can work around that. WSL is the only terminal that displays this behavior though so it would be nice to find out why this happens.

@alganet commented on GitHub (Mar 27, 2019): > > > To reproduce it in the current version: `printf '\033[?1049h; cat <ANY_FILE_WITH_TABS>;'` > > The file output will be garbage. It's doubling lines. Each line double contains only the first character of the line at the last position in the terminal. The original line is missing the first character. > > Seems to be a silly offset bug. The CSI `?47h` and `?47l` should also behave exactly the same way, but they aren't implemented. Fixing it will probably make `vi` behave like intended (it returns the previous shell buffer on quit) (edit: vi works, I'm trying to find out what it does). > > Edit: The file needs to contain tabs. After fiddling around with many applications I've discovered that if I switch to the alternate buffer, I need to set tabs manually: ``` tcont=0 tabsize=4 while test $tcont -lt ${COLUMNS} do echo -ne '\033['$tabsize'C\033H' tcont=$((tcont + tabsize)) done echo -ne '\r' ``` Apparently the previous tabs were set to `COLUMNS - 1`, making the last character in each line break unintentionally. By using this snippet I can work around that. WSL is the only terminal that displays this behavior though so it would be nice to find out why this happens.
Author
Owner

@oising commented on GitHub (Mar 27, 2019):

@alganet I remember reading that there is a bug concerning the alternate buffer and tab stops. I'm not sure if it's been fixed yet. What windows build are you on?

@oising commented on GitHub (Mar 27, 2019): @alganet I remember reading that there is a bug concerning the alternate buffer and tab stops. I'm not sure if it's been fixed yet. What windows build are you on?
Author
Owner

@alganet commented on GitHub (Mar 28, 2019):

@oising I'm on 17763.379.

@alganet commented on GitHub (Mar 28, 2019): @oising I'm on 17763.379.
Author
Owner

@miniksa commented on GitHub (May 29, 2019):

We need to re-repro this on latest bits.

@miniksa commented on GitHub (May 29, 2019): We need to re-repro this on latest bits.
Author
Owner

@axelfontaine commented on GitHub (May 29, 2019):

Just tested on 19H1. Following my original instructions the display is fine now.

However a new weird thing appeared.

In mc, press ctrl+o to hide blue panes. Now wildly resize window with mouse multiple times from current size all the way to zero height+zero width and back. You will hear beeps and the output will become messed up and gradually fill up with 1;0 and 1;0c stuff. See

image

@axelfontaine commented on GitHub (May 29, 2019): Just tested on 19H1. Following my original instructions the display is fine now. However a new weird thing appeared. In mc, press `ctrl+o` to **hide blue panes**. Now wildly resize window with mouse multiple times from current size all the way to zero height+zero width and back. You will hear beeps and the output will become messed up and gradually fill up with `1;0` and `1;0c` stuff. See ![image](https://user-images.githubusercontent.com/684824/58579399-44351b80-824b-11e9-8aa9-8e109541c91b.png)
Author
Owner

@zadjii-msft commented on GitHub (Aug 21, 2023):

Woah, look at this old issue!

April 11, 2017

6 years old? Last updated in 2019? There's probably been 100 commits to our VT implementation since then. I can't repro this original bug anymore on the latest bits. (The last comment does mention #3088, but that's tracked separately).

I bet we can close this out as fixed. Whatever this was, I'm sure j4james has fixed this along the way ☺️

@zadjii-msft commented on GitHub (Aug 21, 2023): Woah, look at this old issue! > April 11, 2017 _6 years old_? Last updated in **2019**? There's probably been 100 commits to our VT implementation since then. I can't repro this original bug anymore on the latest bits. (The last comment does mention #3088, but that's tracked separately). I bet we can close this out as fixed. Whatever this was, I'm sure j4james has fixed this along the way ☺️
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#166