55 #ifndef FAPPLICATION_H 56 #define FAPPLICATION_H 58 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) 59 #error "Only <final/final.h> can be included directly." 66 #include <unordered_map> 70 #include "final/ftypes.h" 71 #include "final/fwidget.h" 100 using FLogPtr = std::shared_ptr<FLog>;
101 using Args = std::vector<std::string>;
102 using FMouseHandler = std::function<void(FMouseData)>;
123 auto getClassName()
const ->
FString override;
124 auto getArgs()
const -> Args;
126 static auto getKeyboardWidget() ->
FWidget*;
127 static auto getLog() -> FLogPtr&;
130 static void setLog (
const FLogPtr&);
133 static auto isQuit() -> bool;
136 #if defined(UNIT_TEST) 140 auto enterLoop() -> int;
141 void exitLoop()
const;
142 static void exit (
int = EXIT_SUCCESS);
146 void sendQueuedEvents();
147 auto eventInQueue()
const -> bool;
148 auto removeQueuedEvent (
const FObject*) -> bool;
149 void registerMouseHandler (
const FMouseHandler&);
150 void initTerminal()
override;
151 static void setDefaultTheme();
152 static void setDarkTheme();
153 static void setLogFile (
const FString&);
154 static void setKeyboardWidget (
FWidget*);
158 void cb_exitApp (
FWidget*)
const;
161 virtual void processExternalUserEvent();
165 using CmdOption =
struct option;
166 using EventPair = std::pair<FObject*, FEvent*>;
167 using FEventQueue = std::deque<EventPair>;
168 using FMouseHandlerList = std::vector<FMouseHandler>;
169 using CmdMap = std::unordered_map<int, std::function<void(char*)>>;
170 using rdbuf = std::streambuf*;
174 static void setTerminalEncoding (
const FString&);
175 static auto getLongOptions() ->
const std::vector<struct option>&;
176 static void setCmdOptionsMap (CmdMap&);
177 static void cmdOptions (
const Args&);
179 static void showParameterUsage();
180 void resetLog()
const;
181 void findKeyboardWidget()
const;
182 auto isKeyPressed (uInt64 = 0U)
const -> bool;
184 void keyReleased()
const;
185 void escapeKeyPressed()
const;
186 void mouseTracking()
const;
187 void performKeyboardAction();
188 void performMouseAction()
const;
190 void sendEscapeKeyPressEvent()
const;
191 auto sendKeyDownEvent (
FWidget*)
const -> bool;
192 auto sendKeyPressEvent (
FWidget*)
const -> bool;
193 auto sendKeyUpEvent (
FWidget*)
const -> bool;
194 void sendKeyboardAccelerator()
const;
195 auto hasDataInQueue()
const -> bool;
196 void queuingKeyboardInput()
const;
197 void queuingMouseInput()
const;
198 void processKeyboardEvent()
const;
199 void processMouseEvent()
const;
200 void processInput()
const;
201 auto processDialogSwitchAccelerator()
const -> bool;
202 auto processAccelerator (
const FWidget&)
const -> bool;
203 void processTerminalFocus (
const FKey&)
const;
204 static void determineClickedWidget (
const FMouseData&);
205 static void determineWheelWidget (
const FMouseData&);
206 static auto isNonActivatingMouseEvent (
const FMouseData&) -> bool;
207 static auto isWheelEvent (
const FMouseData&) -> bool;
208 static void unsetMoveResizeMode (
const FMouseData&);
209 void sendMouseEvent (
const FMouseData&)
const;
210 void sendMouseWheelEvent (
const FMouseData&)
const;
214 , MouseButton )
const;
215 void sendMouseLeftClickEvent (
const FMouseData&
218 , MouseButton )
const;
219 void sendMouseRightClickEvent (
const FMouseData&
222 , MouseButton )
const;
223 void sendMouseMiddleClickEvent (
const FMouseData&
226 , MouseButton )
const;
230 static auto processParameters (
const Args&) ->
FWidget*;
231 void processResizeEvent();
232 void processCloseWidget();
233 void processDialogResizeMove()
const;
234 void processLogger()
const;
235 auto processNextEvent() -> bool;
237 auto hasTerminalResized() -> bool;
238 static auto isEventProcessable (
FObject*,
const FEvent*) -> bool;
239 static auto isNextEventTimeout() -> bool;
243 uInt64 key_timeout{100
'000}; // 100 ms 244 uInt64 dblclick_interval{500'000};
245 FEventQueue event_queue{};
246 FMouseHandlerList mouse_handler_list{};
247 bool has_terminal_resized{
false};
248 static uInt64 next_event_wait;
249 static TimeValue time_last_event;
250 static rdbuf default_clog_rdbuf;
251 static int loop_level;
252 static int quit_code;
253 static bool quit_now;
254 static FWidget* clicked_widget;
256 static FWidget* keyboard_widget;
267 inline auto FApplication::getClassName()
const ->
FString 268 {
return "FApplication"; }
271 inline auto FApplication::getArgs()
const -> Args
275 inline void FApplication::cb_exitApp (
FWidget* w)
const 280 #endif // FAPPLICATION_H Definition: fapplication.h:96
Definition: class_template.cpp:25
Definition: fstartoptions.h:52