Skip to content

Windows Console will no longer advance lines while editing a line - #6036

Open
SilasD wants to merge 2 commits into
DFHack:developfrom
SilasD:console
Open

SilasD wants to merge 2 commits into
DFHack:developfrom
SilasD:console

Conversation

@SilasD

@SilasD SilasD commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Important

this PR has had all of five minutes of testing on one Windows 10 Pro computer. it probably should receive more testing before it is integrated into such a core part of DFHack.

Note

on the other hand, I am very confident of this code change, because blanking the line beyond the currently-valid text is done with the same API call. Tried and tested.

this PR changes the way output is printed to the console line being edited. the previous code advanced the cursor while updating the displayed text. this malfunctioned at the end of the line:

if a character was printed in the rightmost column, the cursor would move to the next line, causing the line editor to use that line. this would occur over and over with every character added or deleted.

Important

does nobody else experience this? I couldn't find a relevant issue.

now the text being edited remains on the same line, scrolling horizontally as necessary.

as a beneficial side effect, this PR removes the occasional flicker of a cursor at the start of a line of input, that could previously be seen as characters were added or deleted to the text being edited.

this PR does not resolve the issue that occurs when the console window is resized such that the resulting number of columns is less than the total length of (the prompt + the line of input). Window still spuriously wraps the line of text into the next row, scrolling the screen if necessary.

but this PR does improve that issue. the extra lines of text that the previous code left in the buffer were wrapped as if they were one long line of text, which resulted in many more spurious characters on the resized screen.

I think fixing this properly would require a callback to catch some window-resized event, and that's just not something I'm going to learn to do.

Note

code quality:

you will notice that the revised output() function is now identical to the blankout() function. I am willing to merge them, or I am willing to revise blankout() to call output(). if I do the latter, I will probably also move the creation of a string of spaces into blankout() instead of making its callers do that.

by printing the line with a method that doesn't advance the cursor
position, and by handling the cooked cursor appropriately when it is
located at the last column.

this also prevents the occasional flicker of the cursor at the
beginning of the line whenever the line is updated.

note that with this change to output(), it is now identical to
blankout().

further work could involve merging the two.

alternately, consider moving the creation of a line of spaces into
blankout() where it belongs, and changing its function parameters
accordingly.
local and gitbug branches diverged bcz I sync'ed the github branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant