Skip to content

Commit

Permalink
PR #12472 from AviaAv: making terminal only functional when focused
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir-Az authored Dec 4, 2023
2 parents 56309b2 + ed9cc31 commit b18cea1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions common/output-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,7 @@ void output_model::draw(ux_window& win, rect view_rect, device_models_list & dev
ImGui::PushItemWidth(0.7f * w - 32);

bool force_refresh = false;

if (ImGui::IsKeyPressed(GLFW_KEY_UP) || ImGui::IsKeyPressed(GLFW_KEY_DOWN))
if (ImGui::IsWindowFocused() && (ImGui::IsKeyPressed(GLFW_KEY_UP) || ImGui::IsKeyPressed(GLFW_KEY_DOWN)))
{
if (commands_histroy.size())
{
Expand All @@ -540,7 +539,7 @@ void output_model::draw(ux_window& win, rect view_rect, device_models_list & dev
}
}

if (ImGui::IsKeyPressed(GLFW_KEY_TAB))
if (ImGui::IsWindowFocused() && ImGui::IsKeyPressed(GLFW_KEY_TAB))
{
if (!autocomplete.size() || !starts_with(to_lower(autocomplete.front()), to_lower(command_line)))
{
Expand Down Expand Up @@ -597,7 +596,7 @@ void output_model::draw(ux_window& win, rect view_rect, device_models_list & dev
ImGui::PopFont();
ImGui::PopStyleColor();

if (ImGui::IsKeyPressed(GLFW_KEY_ENTER) || ImGui::IsKeyPressed(GLFW_KEY_KP_ENTER))
if (ImGui::IsWindowFocused() && (ImGui::IsKeyPressed(GLFW_KEY_ENTER) || ImGui::IsKeyPressed(GLFW_KEY_KP_ENTER)))
{
if (commands_histroy.size() > 100) commands_histroy.pop_back();
commands_histroy.push_front(command_line);
Expand All @@ -607,7 +606,7 @@ void output_model::draw(ux_window& win, rect view_rect, device_models_list & dev
}
else command_focus = false;

if (ImGui::IsKeyPressed(GLFW_KEY_ESCAPE))
if (ImGui::IsWindowFocused() && ImGui::IsKeyPressed(GLFW_KEY_ESCAPE))
{
command_line = "";
}
Expand Down

0 comments on commit b18cea1

Please sign in to comment.