In C++, how to get coordinates of first displayed line on window console relatively to DATA-BUFFER ?

schlebe 21 Points de réputation
2025-08-13T06:12:55.58+00:00

In C++, how to get coordinates of first displayed line on window console relatively to DATA-BUFFER where DATA-BUFFER contains all rows displayed and all rows that has been displayed before and that are currently only visible in scrolling console vertically.

My question with more explanation can be found on StackOverflow on https://stackoverflow.com/questions/79725603/on-windows-terminal-in-visual-c-how-can-i-overwrite-previous-lines

I also posted this question on Github/Microsoft/Terminal at

https://github.com/microsoft/terminal/discussions/19224

In resume, I search a solution to write and overwrite last displayed lines (1 or more rows; line is not only a row).

I already have a solution but it is tricking and depends of line's content ! (see solution on StackOverflow)

Personnaly, I consider that there is a bug on GetConsoleScreenBufferInfo() function !

When data displayed on screen is moved up, srWindow.Top value must is always equal to 0 ! I think that it is not normal because if console buffer is a view in data buffer, position in data buffer of first line displayed on console has been incremented !

If my understanding of srWindow element is false, how can I detect in a console application that vertical scroll position has been incremented ?

And how can I get number of rows scrolled ?

If I have this information, I can use Console API to overwrite all last written lines even when lines are written at bottom of console.

Since I use API and not ANSI sequence, I can also overwrite more lines than last lines !

Thanks for any help.

Technologies de développement | C++
Technologies de développement | C++

Langage de programmation général de haut niveau, créé en tant qu'extension du langage de programmation C, qui possède des caractéristiques orientées objet, génériques et fonctionnelles, ainsi que des fonctions de manipulation de la mémoire de bas niveau.

0 commentaires Aucun commentaire

Votre réponse

Les réponses peuvent être marquées comme « Acceptées » par l’auteur(e) de la question et « Recommandées » par les modérateurs, ce qui aide les utilisateurs à savoir que la réponse a résolu le problème de l’auteur(e).