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
Increasing the Far3 window size creates panel artifacts in the console window #772
Comments
Hi @Zeroes1. No, option is checked, actually I see the problem regardless of this option, checked or not. Just increase the window size (reduce it first if it's too big from the beginning). |
Far 2 is a bug-free perfection. It is known. Oh wai... @yulian5 Zeroes's suggestion is correct. |
Hi @alabuzhev, that's interesting about Far2. I was not able reproduce that, tried just now. I mentioned about Far2 just in case that it may be new related changes in Far3 that you know. Not to prove that Far2 is better, Far2 is history now, I just have it on one of my computers.
Far3 is drawing on the console canvas. It should be a way to fix that problem.
When option is not checked there are also artifacts, just in less degree: |
Conhost being conhost.
Your screenshot shows a graphical artefact outside of the screen buffer. |
Far3 5555 is history too. |
@yulian5 You try use Windows Terminal? |
@w17 Good joke. Why do you think so? Regarding this problem they're the same. |
@Zeroes1 What do you mean? I think the problem is integration Far3 with Conhost. Originally I thought it's just a redrawing problem for empty space. But it looks more serious now. Let me add some screenshots. |
@alabuzhev mentioned:
Actually for Windows 7 it's the same problem (sorry for historic Far3 6116): |
Far can work with Windows Terminal without conhost under Win10/11/srv2022 |
@alabuzhev said:
It looks now that mentioned workaround erased most content of Conhost window inside Far. Please see the screnshots (latest Windows, latest Far3). Running Conhost and Far3, the same size, print directory, reduce the width, then increase width to previous value. Conhost itself is doing fine, but Far3 console window is not. |
WT use GPU for render very usefull speed... |
@Zeroes1 How can I replace console in Far3? |
@alabuzhev Can this MS Conhost code help in that problem? |
for example try my settings? change font too or make default profile himself :) |
It's unrelated. The erasure is by design.
Depends. You've mentioned like 10 different issues here already. Some of them can (and should) be addressed in conhost, like reusing rightmost colors for new cells on resize and visual artefacts in the gap between the buffer and the window edges, some other are by (new) design and will likely be rejected. |
@Zeroes1 Thanks! I was able to run WT based on your instructions with your settings. But I see the same problem. Do I need to adjust something else? Can you check on your system? Just make Far3 smaller and increase the width with both panels on. |
Why is that? Conhost doesn't erase anything after resizing.
Sorry. Discussion went wild. Can you just select one fixable issue for this ticket? I do not have enough Far3 knowledge to properly separate them. I didn't expect so many of them from resizing. But I'm going to create one more ticket for resizing issue which is separate for sure.
Why is that? Don't we all want to fix Far Manager problems? |
"Wrap output on resize" assumes that all the output is static and stream-like. Far isn't cmd.exe. It does have dynamic UI, represented as structured, table-like blocks of text. It doesn't make any sense to reparse it on resize, so the host makes things only worse, as can be seen on your very first screenshot. The output of dir, started from Far, is not a stream of text anymore, it's a text screenshot of it and basically a part of Far UI at this point. When the buffer is resized, that screenshot is trimmed to the new size as well, so everything that doesn't fit is lost forever. Having said that, in theory we can skip that trimming and keep the captured output as is, hoping that it will be useful if the user enlarges the buffer again later. A rare scenario, but I won't mind if you create a new issue with a reference to this comment just in case.
#772 (comment) and #772 (comment) are actual (and likely entirely unrelated) conhost issues that should be relatively easy to fix.
Let's say these days MS is more interested in aligning with "other operating systems" in the command-line application space than in maintaining 100% backwards compatibility. |
@yulian5 problem still exist? I no have trouble, i change size by mouse. |
@alabuzhev, thanks for detailed info!
Sounds good to me! Anyway too many problems at once. |
@Zeroes1 I tried that. The same rendering problem. Strange that you cannot see it: Make Far window small with mouse, then make it big with both blue panels ON. Then turn OFF the panels (Ctrl+O) and check the console screen. I'm not sure exactly what "Use Virtual Terminal for rendering" means. Just found one more small problem, F1 help for this screen doesn't describe it. @Zeroes1 It looks like we have some misunderstanding about WT you mentioned before. I thought we're talking about replacing console inside Far instead of Conhost with something else not running Far from another console. |
ran: re run FAR better? |
At least that part is quite clear for me. But by default the text buffer is quite big like 3000 or 9000 lines. Changing width even to extreme small size still preserves quite a big buffer. Trimming lines doesn't feel right, especially when after enlarging they are filled with garbage. And user can copy that garbage as a text. BTW Far2 has exactly the same trimming problem. But I still cannot reproduce other garbage in Far2, it always black console screen for me with trimmed text after resizing. Far2 doesn't honor height changes well. @alabuzhev Far3 5555 has serious panels rendering problems after changing size with keyboard through Windows Alt menu. But I do not see that with the latest 6249. Are there some related rendering changes between those two versions? |
Thanks! That much better in this regard. Always black console window without extra rendering garbage. Still trimmed text but that is already expected. But one additional problem now: Far3 doesn't honor reducing the height. When I shrink the height I have to scroll to see the bottom or the top. |
@yulian5 FYI: scroll output console in WT: Shift + scroll mouse |
@Zeroes1 OK. Thanks! |
(For me, the above is a problem, but I can't say if there is some kind of bug in this or if it is purely an enhancement request). |
It is possible that a change or two slipped in over the course of 4 years. |
@alabuzhev, thanks! Actually quite a stupid question from me, consider thousands commits. I didn't realize how fast time is passing! But this one 44a55b9 looks like a right one. So @w17 is absolutely right and 5555 is a historic version. What a pity! I like number 5. Guess I have to wait till version 55555 to get an excellent version number. Do we even have enough bugs for that? |
@Zeroes1, thanks for information about running Far in WT. It's an only solution to run Far3 without ConHost I saw so far. And it's quite interesting development indeed. I tried ConEmu but it looks like it still use conhost.exe. I found "extendedconsole.dll" in Far3 code, it looks like it was some attempt to integrate it. |
@alabuzhev explained:
Thanks! I was under wrong impression that Far a has separate console window as Far console emulation is very good (except resizing). I tried to check code but it's quite complicated with comments basically only for fixes. But it looks like the screen buffer is the same for UI and console output with console text in blocks and naturally it's a crazy complicated task to resize all that stuff correctly. But the excellent news is that UI itself is resizing almost always correctly (rebuild from the scratch?)! Only console output is messed up and only after resizing. If I develop console app with user UI, the app will have separate buffers for UI (blocked based) and for console output (stream based, array of lines). Then we have mask of blocks indicating which areas are filled with UI and which areas are available for console output. The app starts with empty screen buffer, builds UI and then scans console buffer lines (starting from cursor line), fills the empty blocks with text parts available for console output based on the UI mask and conditions (text wrap and screen buffer width). Then, OK, let's resize the screen. Basically, we have no good choice but start from the empty screen buffer again and rebuild the UI. We do not have to resize console buffer, we actually do not have to do anything with it at all (except update it with new console output, if any). We again scan console buffer lines using our UI mask with empty blocks for console text output and conditions we have (wrap, width) and fill them with console text. Then everything should resized correctly (rebuilt actually). |
Console output could be anything. |
That doesn't work well and not fixed for 28 years. Does it still seem like the right approach? |
It does if the alternatives are worse, which I think is the case. |
I actually never worked with console apps except trivial cases. If you can get unwrapped lines from console output (most likely, yes), then all 3 mentioned cases are the same, just arrays of lines, and fit in the scheme I described. You can wrap and slice them to the blocks as needed. I do not believe that there was a flaw in original Far design. At that time of small expensive memory, extra slow GPU and CPU speeds, primitive console, etc. that blocked design for console output was probably the best available option. Now we have a different situation and can afford a thousand extra buffers without any sacrificing. Just my opinion. |
I am not sure I follow you. What exactly do you mean by "array of lines?" Console, at least on Windows systems, is a rectangular block of characters, 25 lines by 80 characters per line (ok, ok, these days it's more likely 9000 lines, 200 characters per line). Think of an electrical console typewriter (e.g., here and here). When a regular console application outputs stream of characters, they are printed one by one on the paper roll advancing printing position after each character by shifting the typewriter's carriage. When the printing position reaches the right edge of the paper roll, actually when the carriage traps the end-of-line lever, the carriage returns to the beginning of the line, and the paper roll is rotated by one line. All this happens automatically! The application also can control the carriage and roll movements. For example, to return the carriage to the beginning of the line, the application should output the Carriage Return character (ASCII 0D), and to feed the paper by one line, it should output, you guess it, Line Feed character (ASCII 0A). What's important here is that after the character is transferred to the paper, the typewriter does not know why it has happened here. If a character is printed at the first (leftmost) position, neither the typewriter, nor the system have any idea of whether this character continues the word truncated at the end of the previous line or the application deliberately ended the previous line with the CR+LF sequence, or even if the application sent CR without LF thus causing the typewriter to print over the already printed character at the beginning of the line. What a mess! Now, the console window, again, at least on Windows systems, is pretty much the imitation of the console typewriter. After the characters printed by a (regular console) application are set in the rectangular console buffer, neither the How does Conhost wrap the text when console window is resized? I bet nobody knows exactly, but it should be Unlike with the paper roll and the typewriter, with the console window we are blessed with the possibility to set a character in an arbitrary console buffer position (permanently overriding the unlucky previous resident of this position). So, Far draws its UI on top of whatever is in the buffer (carefully saving the original contents of the buffer to show it to you when you press To do something nice with the contents of the buffer on resizing console window, Far basically has two options: (a) reproduce the dance performed by Conhost, and (b) before allowing the window to resize, restore the content of the buffer, somehow invoke Conhost to do its magic, then draw UI in the resized window. As you can guess, (a) is not an option because nobody knows exactly ... and ... does not do a great job anyway. My educated guess is that option (b) is impossible because to "invoke Conhost," Far would need to exit and then resurrect from the ashes like Phoenix when resizing is completed. I'll leave commenting on other possibilities to Alex, though. |
And of course you may encounter with another problems when working with FAR+WT vs FAR+ConHost:) for example: be ready... |
@Zeroes1 Thanks! That is an interesting choice anyway, I didn't know before your information that Far may be run with alternative console. I do not using Far+WT now on regular basis, I think I need more testing and just to get used to it. As for the topic of this issue, Far has the same console resizing problems either with ConHost or with WT, so I guess, logical conclusion that it's not their fault. What other advantages do you know with combo Far+WT vs Far+ConHost? |
That is definitely wrong.
There is code for that MS Terminal, everybody can look.
Can you provide any proof of that? Does it have issues that fatally affect Far? Did you anyway mistaken it for the Far console emulation? Windows console was quite powerful even when Far was created, just look closer at the Far UI, it's actually a miracle for a simple console typewriter. What do you think? And all this miracle is inside the Conhost which you are blaming. As for mentioned problem so far I found only that ConHost itself doesn't resize output correctly in one case when the app prints on the same line multiple times (using '\r'). Blaming other development is not a good way to develop and fix issues. Some of them doing great job, some of them not so far for a lot of reasons. As for this resizing problems I see more blames than actual suggestions or development. But @MKadaner in general I cannot reply to you more argumentatively, I'll learn this topic a little more and will return back to this. From what I see, probably only @alabuzhev can fix that problem, as it arises from the original design and involves a lot of core changes. It's not a trivial fix, I guess. I can join to active development only about 2025. If it hasn't been fixed by then and nothing changes I'll work on it, it's a quite interesting task. I cannot say for sure currently what the solution may be. And BTW during resizing Far screwed a lot of console output beyond its UI window, it should not do that, I guess. If you have buffer (not 9000 but much more than height of Far UI), perform dir /s command, check console output before and after resizing, most of the output after resizing either empty cells or reshuffled console output. I think, that is one more problem to list (and to fix eventually). |
It is definitely correct. You can read about it (along with its evolution, some of its problems, the new ConPTY, and more) here: https://devblogs.microsoft.com/commandline/windows-command-line-backgrounder/ |
Yes, you're right. My bad. My GUI experience didn't help in that case. As I mentioned:
But I do not believe that it's all ConHost and MS fault and it's not possible to fix. |
Of course, ConHost's source code does exist. Moreover, in Microsoft, they build it daily (or rather nightly). However, by no means it means that anybody knows how it works. |
Tabs, cleartype, turbo speed of render, support unicode symbols, hotkeys (my favorite At-X - close current tab :), easy mouse selection area, scroll buffer, portable mode WT (easy my options on another computer), background picture...) |
Thank you very much for the info! It's quite impressive. Do you have a portable Far3 for WT portable mode? |
I started to look into Console API and Far 3 code, for sure it's very tricky to adjust console buffer size, my first impression is that width for console output buffer is less than width for Far UI console buffer but I didn't debug that yet. What's about ConPTY? Maybe instead of fixing this problem and use "do not recommended to use" console API start migration to ConPTY? It will help to port Far3 to Linux (I hope it'll still happen one day). |
@yulian5 |
@yulian5 yep, i use far + wt portable FAR portable: WT portable: |
Hi @shmuz , yes, I tried far2l a few years ago. I didn't know about far2m. Thanks! far2l(m) is using Wine, it's not a native port, I talked about. To port Far3 to Linux will be the titanic work. I also tried Midnight Commander, Krusader, Double Commander. Best results I had recently on Linux with Far3 under Wine on a few different distros but I also had a lot of problems with settings, colors, desktop shortcut link and dropped it. Linux shells or native file managers still look better for me. Maybe I need to try far2l/far2m again. What are the main differences between them? |
Hi @alabuzhev, Heavy rain all Saturday helps me to debug this problem. It looks like I found the root cause. At least with small change in Far code it's possible to remove all visual artifacts. I used today's code from github to build Far. Here is result of multiple resizing with original github code: Here is the same console with applied code change after much more heavy resizing: The change is in file "far\savescr.cpp", line 180, to disable code after comment "// achtung, experimental": SyncWithConsole = false;
The issue is introduced a long time ago. I see nothing wrong with that code, except it may need some synchronization with other related code as Conhost is running in separate thread and resizing happens in a few overlapping steps usually. But when this code read console buffer in lines 197 or 226
console output is already broken. Setting this flag SyncWithConsole to false, which is essentially (Global->Opt->WindowMode != 0), to disable code in lines 183-248 help to remove all visual artifacts with absolutely clean console output (except truncated lines, which we'll address separately). |
@yulian5 far2m differs from far2l mainly by its macro-system (which is almost identical to that of Far3) and (while preserving the Far2 plugins API) it has some API extensions (mostly borrowed from Far3). |
Thanks for having a look.
It did work more or less reliably back in the day. There were quite a few changes in conhost in the recent years and something might have stopped working at some point. |
Looks very interesting. Thanks! I'll check it out. |
This is strictly off-topic in this issue, especially in addition to its almost 60 comments already. Please create a new Discussion for this. |
Far Manager version
3.0.6249.0
OS version
Windows 7, 10, 11
Other software
No response
Steps to reproduce
Increase windows size, mostly width, by dragging by the corner or border, or increase width through Windows Properties->Layout->Windows Size->Width. Switch to Console window (Ctrl+O).
It maybe related to similar issues #765 and #257
Expected behavior
Clean Console window.
When having a few monitors with different resolutions (like laptop with external monitors) it's quite frequently requited to resize windows including Far3.
Actual behavior
Multiple artifacts from Panels drawing:
When dragging for the corner:
When using Properties->Layout->Windows Size->Width:
Problem exists with Legacy console too. Loos like Far 2.0 doesn't have that problem.
The text was updated successfully, but these errors were encountered: