Skip to content

Commit

Permalink
Minor visual correction of 6348
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Sep 10, 2024
1 parent b280d1e commit 8c6b837
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 6 additions & 2 deletions far/console_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
15 changes: 11 additions & 4 deletions far/interf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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<int>(ScrY - Desired + 1), ScrX, ScrY };

// TODO: matrix_view to avoid copying
matrix<FAR_CHAR_INFO> BufferBlock(Rows, ScrX + 1);
matrix<FAR_CHAR_INFO> 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)
Expand Down
2 changes: 1 addition & 1 deletion far/interf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion far/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) });
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6367
6368

0 comments on commit 8c6b837

Please sign in to comment.