From 8c6b837eb3dfe26c48bee1ddff709f1d4b772e2c Mon Sep 17 00:00:00 2001 From: Alex Alabuzhev Date: Tue, 10 Sep 2024 19:38:37 +0100 Subject: [PATCH] Minor visual correction of 6348 --- far/changelog | 5 +++++ far/console_session.cpp | 8 ++++++-- far/interf.cpp | 15 +++++++++++---- far/interf.hpp | 2 +- far/main.cpp | 2 +- far/vbuild.m4 | 2 +- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/far/changelog b/far/changelog index 3d694cf456..5abb492e1c 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,8 @@ +-------------------------------------------------------------------------------- +drkns 2024-09-10 19:37:57+01:00 - build 6368 + +1. Minor visual correction of 6348. + -------------------------------------------------------------------------------- drkns 2024-09-05 21:27:14+01:00 - build 6367 diff --git a/far/console_session.cpp b/far/console_session.cpp index a8571386cb..a02db05cfc 100644 --- a/far/console_session.cpp +++ b/far/console_session.cpp @@ -153,9 +153,13 @@ class context final: noncopyable, public i_context m_Consolised = false; } - if (Scroll && DoWeReallyHaveToScroll(Global->Opt->ShowKeyBar? 3 : 2)) + if (Scroll) { - std::wcout << std::endl; + const auto SpaceNeeded = Global->Opt->ShowKeyBar? 3uz : 2uz; + + if (const auto SpaceAvailable = NumberOfEmptyLines(SpaceNeeded); SpaceAvailable < SpaceNeeded) + std::wcout << string(SpaceNeeded - SpaceAvailable, L'\n') << std::flush; + Global->ScrBuf->FillBuf(); } diff --git a/far/interf.cpp b/far/interf.cpp index 7d8d0e1bc4..333c8d2818 100644 --- a/far/interf.cpp +++ b/far/interf.cpp @@ -1185,7 +1185,7 @@ const FarColor& GetColor() return CurColor; } -bool DoWeReallyHaveToScroll(short Rows) +size_t NumberOfEmptyLines(size_t const Desired) { /* Q: WTF is this magic? @@ -1200,13 +1200,20 @@ bool DoWeReallyHaveToScroll(short Rows) This function reads the specified number of the last lines from the screen buffer and checks if there's anything else in them but spaces. */ - rectangle const Region{ 0, ScrY - Rows + 1, ScrX, ScrY }; + rectangle const Region{ 0, static_cast(ScrY - Desired + 1), ScrX, ScrY }; // TODO: matrix_view to avoid copying - matrix BufferBlock(Rows, ScrX + 1); + matrix BufferBlock(Desired, ScrX + 1); Global->ScrBuf->Read(Region, BufferBlock); - return !std::ranges::all_of(BufferBlock.vector(), [](const FAR_CHAR_INFO& i) { return i.Char == L' '; }); + for (size_t i = 0, Height = BufferBlock.height(); i != Height; ++i) + { + const auto& Row = BufferBlock[Height - 1 - i]; + if (!std::ranges::all_of(Row, [](const FAR_CHAR_INFO& i){ return i.Char == L' '; })) + return i; + } + + return Desired; } size_t string_pos_to_visual_pos(string_view Str, size_t const StringPos, size_t const TabSize, position_parser_state* SavedState) diff --git a/far/interf.hpp b/far/interf.hpp index e63d5e397f..d14c2c4ce9 100644 --- a/far/interf.hpp +++ b/far/interf.hpp @@ -158,7 +158,7 @@ void ShowCursor(); void SetInitialCursorType(); void GetCursorType(bool& Visible, size_t& Size); void MoveRealCursor(int X,int Y); -bool DoWeReallyHaveToScroll(short Rows); +size_t NumberOfEmptyLines(size_t Desired); struct position_parser_state { diff --git a/far/main.cpp b/far/main.cpp index 28ab24ccb3..4fe9333f55 100644 --- a/far/main.cpp +++ b/far/main.cpp @@ -424,7 +424,7 @@ static void ShowVersion(bool const Direct) if (!Direct) { // Version, copyright, empty line, command line, keybar - if (const auto SpaceNeeded = 5; !DoWeReallyHaveToScroll(SpaceNeeded)) + if (const auto SpaceNeeded = 5; NumberOfEmptyLines(SpaceNeeded) == SpaceNeeded) { EnoughSpace = true; console.SetCursorPosition({ 0, ScrY - (SpaceNeeded - 1) }); diff --git a/far/vbuild.m4 b/far/vbuild.m4 index f5044d832d..e509d7584b 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -6367 +6368