Skip to content

Commit

Permalink
Console: Add Ctrl+L binding to clear the console
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Nov 1, 2023
1 parent 7cc05d1 commit dea5de3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Source/panels/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ constexpr std::string_view HelpText =
"Shift+Enter to insert a newline, PageUp/Down to scroll,"
" Up/Down to fill the input from history,"
" Shift+Up/Down to fill the input from output history,"
" Esc to close.";
" Ctrl+L to clear history, Esc to close.";

bool IsConsoleVisible;
char ConsoleInputBuffer[4096];
Expand Down Expand Up @@ -306,6 +306,14 @@ void NextOutput()
NextHistoryItem(IsHistoryOutputLine);
}

void ClearConsole()
{
ConsoleLines.clear();
HistoryIndex = -1;
ScrollOffset = 0;
AddConsoleLine(ConsoleLine { .type = ConsoleLine::Help, .text = std::string(HelpText) });
}

} // namespace

bool IsConsoleOpen()
Expand Down Expand Up @@ -362,6 +370,9 @@ bool ConsoleHandleEvent(const SDL_Event &event)
case SDLK_PAGEDOWN:
--PendingScrollPages;
return true;
case SDLK_l:
ClearConsole();
return true;
default:
return false;
}
Expand Down

0 comments on commit dea5de3

Please sign in to comment.