Pioneer
Loading...
Searching...
No Matches
LuaConsole.h
Go to the documentation of this file.
1// Copyright © 2008-2024 Pioneer Developers. See AUTHORS.txt for details
2// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3
4#ifndef _LUACONSOLE_H
5#define _LUACONSOLE_H
6
7#include "Input.h"
8#include "LuaManager.h"
9#include "RefCounted.h"
10#include "ConnectionTicket.h"
11#include "core/Log.h"
12#include <deque>
13
14struct ImGuiInputTextCallbackData;
15
17public:
18 LuaConsole();
19
20 void SetupBindings();
21 void Toggle();
22
23 bool IsActive() const { return m_active; }
24 void AddOutput(const std::string &line);
25
26#ifdef REMOTE_LUA_REPL
27 void OpenTCPDebugConnection(int portnumber);
28 void CloseTCPDebugConnection();
29 void HandleTCPDebugConnections();
30#endif
31
32 static void Register();
33 void HandleCallback(ImGuiInputTextCallbackData *data);
34 void Draw();
35
36private:
37 bool OnCompletion(bool backward);
38 bool OnHistory(bool upArrow);
39 void LogCallback(Time::DateTime, Log::Severity, std::string_view);
40
41 bool ExecOrContinue(const std::string &stmt, bool repeatStatement = true);
42 void UpdateCompletion(const std::string &statement);
43 void RegisterAutoexec();
44
45#ifdef REMOTE_LUA_REPL
46 void HandleNewDebugTCPConnection(int socket);
47 void HandleDebugTCPConnection(int socket);
48 void BroadcastToDebuggers(const std::string &message);
49#endif
50
51 bool m_active;
52 Input::InputFrame m_inputFrame;
53 InputBindings::Action *toggleLuaConsole;
54 ConnectionTicket m_logCallbackConn;
55
56 // Output log
57 std::vector<std::string> m_outputLines;
58
59 // statement history
60 std::deque<std::string> m_statementHistory;
61 std::string m_stashedStatement;
62 std::string m_activeStr;
63 std::unique_ptr<char[]> m_editBuffer;
64 int m_historyPosition;
65
66 // autocompletion
67 std::string m_precompletionStatement;
68 std::vector<std::string> m_completionList;
69 unsigned int m_currentCompletion;
70
71#ifdef REMOTE_LUA_REPL
72 int m_debugSocket;
73 std::vector<int> m_debugConnections;
74#endif
75};
76
77#endif /* _LUACONSOLE_H */
Definition: LuaConsole.h:16
bool IsActive() const
Definition: LuaConsole.h:23
void SetupBindings()
Definition: LuaConsole.cpp:69
static void Register()
Definition: LuaConsole.cpp:568
void HandleCallback(ImGuiInputTextCallbackData *data)
Definition: LuaConsole.cpp:229
void Draw()
Definition: LuaConsole.cpp:192
void Toggle()
Definition: LuaConsole.cpp:76
LuaConsole()
Definition: LuaConsole.cpp:46
void AddOutput(const std::string &line)
Definition: LuaConsole.cpp:366
Definition: DateTime.h:84
Severity
Definition: Log.h:13
Definition: ConnectionTicket.h:12
Definition: InputBindings.h:144
Definition: Input.h:48