From 1dba06656d5dda3f8efc6a3dc2a8596428e17df5 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 4 Nov 2019 18:10:09 +0000 Subject: Codechange: Add utility function for whether the focused window is a console --- src/window.cpp | 9 +++++++++ src/window_func.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/window.cpp b/src/window.cpp index c25751fbb..c6a221af0 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -466,6 +466,15 @@ bool EditBoxInGlobalFocus() return _focused_window->nested_focus != nullptr && _focused_window->nested_focus->type == WWT_EDITBOX; } +/** + * Check if a console is focused. + * @return returns true if the focused window is a console, else false + */ +bool FocusedWindowIsConsole() +{ + return _focused_window && _focused_window->window_class == WC_CONSOLE; +} + /** * Makes no widget on this window have focus. The function however doesn't change which window has focus. */ diff --git a/src/window_func.h b/src/window_func.h index 45e2d71ec..7fca0d9c1 100644 --- a/src/window_func.h +++ b/src/window_func.h @@ -55,6 +55,7 @@ void DeleteWindowById(WindowClass cls, WindowNumber number, bool force = true); void DeleteWindowByClass(WindowClass cls); bool EditBoxInGlobalFocus(); +bool FocusedWindowIsConsole(); Point GetCaretPosition(); #endif /* WINDOW_FUNC_H */ -- cgit v1.2.3-70-g09d2