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