Pioneer
LuaConsole.h
Go to the documentation of this file.
1// Copyright © 2008-2022 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 "sigc++/connection.h"
11#include <deque>
12
13struct ImGuiInputTextCallbackData;
14
16public:
17 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 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 sigc::connection 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:23
void SetupBindings()
Definition: LuaConsole.cpp:74
static void Register()
Definition: LuaConsole.cpp:573
void HandleCallback(ImGuiInputTextCallbackData *data)
Definition: LuaConsole.cpp:234
void Draw()
Definition: LuaConsole.cpp:197
~LuaConsole()
Definition: LuaConsole.cpp:63
void Toggle()
Definition: LuaConsole.cpp:81
LuaConsole()
Definition: LuaConsole.cpp:46
void AddOutput(const std::string &line)
Definition: LuaConsole.cpp:371
Definition: DateTime.h:84
Severity
Definition: Log.h:12
Definition: InputBindings.h:142
Definition: Input.h:45