Repository navigation
Expand file tree
/
Copy patheterm.hpp
More file actions
190 lines (144 loc) · 5.69 KB
/
Copy patheterm.hpp
File metadata and controls
190 lines (144 loc) · 5.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#pragma once
#include "appconfig.hpp"
#include "settingsactions.hpp"
#include <args/args.hxx>
#include <atomic>
#include <eepp/core/small_vector.hpp>
#include <eepp/ee.hpp>
#include <eepp/ui/iconmanager.hpp>
#include <eepp/ui/tools/uisettingspanel.hpp>
#include <eepp/ui/tools/uitabwidgetsplitter.hpp>
#include <eepp/ui/tools/uiwidgetinspector.hpp>
#include <eepp/ui/uiapplication.hpp>
#include <eepp/ui/uilinearlayout.hpp>
#include <eepp/ui/uimessagebox.hpp>
#include <efsw/efsw.hpp>
#include <eterm/ui/uiterminal.hpp>
using namespace EE;
using namespace EE::Graphics;
using namespace EE::Scene;
using namespace EE::System;
using namespace EE::UI;
using namespace EE::UI::Tools;
using namespace EE::Window;
using namespace eterm::Terminal;
using namespace eterm::UI;
using namespace eterm;
namespace eterm {
struct TerminalLaunchConfig {
std::string program;
std::vector<std::string> arguments;
std::string workingDirectory;
std::string executeInShell;
size_t historySize{ 10000 };
TerminalCursorMode cursorStyle{ TerminalCursorMode::SteadyUnderline };
FontHinting fontHinting{ FontHinting::Full };
FontAntialiasing fontAntialiasing{ FontAntialiasing::Grayscale };
bool useFrameBuffer{ false };
bool keepAlive{ true };
bool closeOnExit{ false };
};
class App : private efsw::FileWatchListener {
public:
int run( int argc, char* argv[] );
class TerminalSplitterClient : public UITabWidgetSplitter::Client {
public:
explicit TerminalSplitterClient( App& app ) : mApp( app ) {}
void onTabCreated( UITab* tab, UIWidget* ) override;
void onWidgetFocusChange( UIWidget* ) override;
private:
App& mApp;
};
private:
friend struct SettingsPanel;
friend class SettingsActions;
std::string getResourcePath() const;
String i18n( const std::string& key, const String& defaultValue ) const;
void loadColorSchemes( const std::string& resPath );
static UITerminal* terminalFromTab( UITab* tab );
void updateWindowTitle();
bool hasTerminals() const;
static bool hasRunningChildren( UITab* tab );
void closeTab( UITab* tab );
void queueExitCloseTab( UITab* tab );
void queueExitedTabs();
void requestCloseTab( UITab* tab );
void renameSession( UITerminal* terminal );
void maximizeTabWidget( UITabWidget* tabWidget );
void restoreMaximizedTabWidget();
void configureTab( UITab* tab );
UITerminal* createTerminal( UITabWidget* target = nullptr );
UITerminal* createTerminalSplit( SplitDirection direction, UIWidget* widget );
void moveTab( UIWidget* widget, int offset );
template <typename T> void registerTabCommands( T& commandTarget, UIWidget* widget ) {
tabSplitter->registerSplitterCommands( commandTarget );
commandTarget.setCommand( "create-new-terminal", [this] { createNewTerminal(); } );
commandTarget.setCommand( "open-settings", [this] { settingsActions->showSettings(); } );
commandTarget.setCommand( "open-keybindings", [this] { openKeybindings(); } );
commandTarget.setCommand( "debug-widget-tree-view",
[this] { UIWidgetInspector::create( scene ); } );
commandTarget.setCommand( "move-tab-left", [this, widget] { moveTab( widget, -1 ); } );
commandTarget.setCommand( "move-tab-right", [this, widget] { moveTab( widget, 1 ); } );
commandTarget.setCommand( "split-right", [this, widget] {
createTerminalSplit( SplitDirection::Right, widget );
} );
commandTarget.setCommand( "split-bottom", [this, widget] {
createTerminalSplit( SplitDirection::Bottom, widget );
} );
commandTarget.setCommand(
"split-left", [this, widget] { createTerminalSplit( SplitDirection::Left, widget ); } );
commandTarget.setCommand(
"split-top", [this, widget] { createTerminalSplit( SplitDirection::Top, widget ); } );
}
void addTabKeyBindings( UITerminal* terminal );
#if EE_PLATFORM == EE_PLATFORM_MACOS
void createGlobalMenuBar();
void executeMenuCommand( const std::string& command );
void syncGlobalMenuKeybindings();
#endif
KeyBindings::ShortcutMap getDefaultKeybindings() const;
void loadKeybindings();
void reloadKeybindings();
void applyKeybindings( UITerminal* terminal );
void applyKeybindings( UICodeEditor* editor );
void openKeybindings();
void handleFileAction( efsw::WatchID, const std::string& dir, const std::string& filename,
efsw::Action action, const std::string& oldFilename ) override;
void forEachTerminal( const std::function<void( UITerminal* )>& fn );
void savePreferences();
void saveWindowState();
void createNewTerminal();
bool closeWindow( EE::Window::Window* );
EE::Window::Window* appWindow{ nullptr };
UISceneNode* scene{ nullptr };
UILinearLayout* mainLayout{ nullptr };
#if EE_PLATFORM == EE_PLATFORM_MACOS
UIMenuBar* menuBar{ nullptr };
#endif
UITabWidgetSplitter* tabSplitter{ nullptr };
FontTrueType* terminalFont{ nullptr };
UIIcon* terminalIcon{ nullptr };
UIMessageBox* closeDialog{ nullptr };
UICodeEditor* keybindingsEditor{ nullptr };
UIWidget* closeDialogWidget{ nullptr };
UIWindow* maximizedTabWidgetWindow{ nullptr };
UITabWidget* maximizedTabWidget{ nullptr };
UINodeLink* maximizedTabWidgetLink{ nullptr };
TerminalLaunchConfig terminalConfig;
std::unique_ptr<eterm::AppConfig> config;
std::unique_ptr<SettingsActions> settingsActions;
std::map<std::string, TerminalColorScheme> terminalColorSchemes;
std::unordered_map<std::string, std::string> keybindings;
std::string keybindingsPath;
std::unique_ptr<efsw::FileWatcher> fileWatcher;
std::atomic<bool> keybindingsChanged{ false };
const TerminalColorScheme* selectedColorScheme{ nullptr };
Float terminalFontSize{ 12 };
bool warnBeforeClose{ false };
bool closeApproved{ false };
bool benchmarkMode{ false };
Clock secondsCounter;
SmallVector<UITab*, 8> pendingExitCloseTabs;
TerminalSplitterClient splitterClient{ *this };
};
} // namespace eterm