Skip to content
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

Fix broken terminal output #458

Merged
merged 1 commit into from
May 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 6 additions & 49 deletions src/NetBox/FarPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,10 @@ int32_t TCustomFarPlugin::Message(uint32_t Flags,
nullptr,
static_cast<const wchar_t * const *>(static_cast<const void *>(Items.c_str())), 0, 0));
}
if (FTerminalScreenShowing)
{
FarControl(FCTL_GETUSERSCREEN, 0, nullptr);
}
return Result;
}

Expand Down Expand Up @@ -1560,55 +1564,8 @@ void TCustomFarPlugin::ScrollTerminalScreen(int32_t Rows)
void TCustomFarPlugin::ShowTerminalScreen(const UnicodeString & Command)
{
DebugAssert(!FTerminalScreenShowing);
TPoint Size, Cursor;
TerminalInfo(&Size, &Cursor);

if (Size.y >= 2)
{
// clean menu keybar area before command output
int32_t Y = Size.y - 2;
// if any panel is visible -- clear all screen (don't scroll panel)
{
PanelInfo Info{};
nb::ClearStruct(Info);
Info.StructSize = sizeof(Info);
FarControl(FCTL_GETPANELINFO, 0, &Info, PANEL_ACTIVE);
if (Info.Flags & PFLAGS_VISIBLE)
{
Y = 0;
}
else
{
nb::ClearStruct(Info);
Info.StructSize = sizeof(Info);
FarControl(FCTL_GETPANELINFO, 0, &Info, PANEL_PASSIVE);
if (Info.Flags & PFLAGS_VISIBLE)
{
Y = 0;
}
}
}
UnicodeString Blank = ::StringOfChar(L' ', Size.x);
do
{
Text(0, Y, 7 /*LIGHTGRAY*/, Blank);
} while (++Y < Size.y);
if (Command.Length() && Size.x > 2)
{
Blank = Command;
Blank.Insert(0, L"$ ", 2);
if (Blank.Length() > Size.x) Blank.SetLength(Size.x);
if (Cursor.y == Y-1) --Cursor.y; // !'Show key bar'
Text(0, Cursor.y, 7 /*LIGHTGRAY*/, Blank);
++Cursor.y;
}
}
FlushText();

COORD Coord{};
Coord.X = 0;
Coord.Y = static_cast<SHORT>(Cursor.y);
::SetConsoleCursorPosition(FConsoleOutput, Coord);
FarControl(FCTL_GETUSERSCREEN, 0, nullptr);
FarWriteConsole(L"$ " + Command + "\n");
FTerminalScreenShowing = true;
}

Expand Down