Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8634eb78f0 |
@@ -12,7 +12,7 @@ public:
|
|||||||
virtual ~Frontend() = default;
|
virtual ~Frontend() = default;
|
||||||
|
|
||||||
// Initialize the frontend (create window/terminal, etc.)
|
// Initialize the frontend (create window/terminal, etc.)
|
||||||
virtual bool Init(Editor &ed) = 0;
|
virtual bool Init(int &argc, char **argv, Editor &ed) = 0;
|
||||||
|
|
||||||
// Execute one iteration (poll input, dispatch, draw). Set running=false to exit.
|
// Execute one iteration (poll input, dispatch, draw). Set running=false to exit.
|
||||||
virtual void Step(Editor &ed, bool &running) = 0;
|
virtual void Step(Editor &ed, bool &running) = 0;
|
||||||
|
|||||||
@@ -30,8 +30,10 @@
|
|||||||
static auto kGlslVersion = "#version 150"; // GL 3.2 core (macOS compatible)
|
static auto kGlslVersion = "#version 150"; // GL 3.2 core (macOS compatible)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GUIFrontend::Init(Editor &ed)
|
GUIFrontend::Init(int &argc, char **argv, Editor &ed)
|
||||||
{
|
{
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
// Attach editor to input handler for editor-owned features (e.g., universal argument)
|
// Attach editor to input handler for editor-owned features (e.g., universal argument)
|
||||||
input_.Attach(&ed);
|
input_.Attach(&ed);
|
||||||
// editor dimensions will be initialized during the first Step() frame
|
// editor dimensions will be initialized during the first Step() frame
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
|
|
||||||
~GUIFrontend() override = default;
|
~GUIFrontend() override = default;
|
||||||
|
|
||||||
bool Init(Editor &ed) override;
|
bool Init(int &argc, char **argv, Editor &ed) override;
|
||||||
|
|
||||||
void Step(Editor &ed, bool &running) override;
|
void Step(Editor &ed, bool &running) override;
|
||||||
|
|
||||||
|
|||||||
@@ -658,11 +658,9 @@ private:
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GUIFrontend::Init(Editor &ed)
|
GUIFrontend::Init(int &argc, char **argv, Editor &ed)
|
||||||
{
|
{
|
||||||
int argc = 0;
|
app_ = new QApplication(argc, argv);
|
||||||
char **argv = nullptr;
|
|
||||||
app_ = new QApplication(argc, argv);
|
|
||||||
|
|
||||||
window_ = new MainWindow(input_);
|
window_ = new MainWindow(input_);
|
||||||
window_->show();
|
window_->show();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
|
|
||||||
~GUIFrontend() override = default;
|
~GUIFrontend() override = default;
|
||||||
|
|
||||||
bool Init(Editor &ed) override;
|
bool Init(int &argc, char **argv, Editor &ed) override;
|
||||||
|
|
||||||
void Step(Editor &ed, bool &running) override;
|
void Step(Editor &ed, bool &running) override;
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TerminalFrontend::Init(Editor &ed)
|
TerminalFrontend::Init(int &argc, char **argv, Editor &ed)
|
||||||
{
|
{
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
// Ensure Control keys reach the app: disable XON/XOFF and dsusp/susp bindings (e.g., ^S/^Q, ^Y on macOS)
|
// Ensure Control keys reach the app: disable XON/XOFF and dsusp/susp bindings (e.g., ^S/^Q, ^Y on macOS)
|
||||||
{
|
{
|
||||||
struct termios tio{};
|
struct termios tio{};
|
||||||
@@ -121,4 +123,4 @@ TerminalFrontend::Shutdown()
|
|||||||
have_old_sigint_ = false;
|
have_old_sigint_ = false;
|
||||||
}
|
}
|
||||||
endwin();
|
endwin();
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ public:
|
|||||||
// Adjust if your terminal needs a different threshold.
|
// Adjust if your terminal needs a different threshold.
|
||||||
static constexpr int kEscDelayMs = 50;
|
static constexpr int kEscDelayMs = 50;
|
||||||
|
|
||||||
bool Init(Editor &ed) override;
|
bool Init(int &argc, char **argv, Editor &ed) override;
|
||||||
|
|
||||||
void Step(Editor &ed, bool &running) override;
|
void Step(Editor &ed, bool &running) override;
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TestFrontend::Init(Editor &ed)
|
TestFrontend::Init(int &argc, char **argv, Editor &ed)
|
||||||
{
|
{
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
ed.SetDimensions(24, 80);
|
ed.SetDimensions(24, 80);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -30,4 +32,4 @@ TestFrontend::Step(Editor &ed, bool &running)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TestFrontend::Shutdown() {}
|
TestFrontend::Shutdown() {}
|
||||||
@@ -13,7 +13,7 @@ public:
|
|||||||
|
|
||||||
~TestFrontend() override = default;
|
~TestFrontend() override = default;
|
||||||
|
|
||||||
bool Init(Editor &ed) override;
|
bool Init(int &argc, char **argv, Editor &ed) override;
|
||||||
|
|
||||||
void Step(Editor &ed, bool &running) override;
|
void Step(Editor &ed, bool &running) override;
|
||||||
|
|
||||||
|
|||||||
6
main.cc
6
main.cc
@@ -112,7 +112,7 @@ RunStressHighlighter(unsigned seconds)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, const char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
std::setlocale(LC_ALL, "");
|
std::setlocale(LC_ALL, "");
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ main(int argc, const char *argv[])
|
|||||||
int opt;
|
int opt;
|
||||||
int long_index = 0;
|
int long_index = 0;
|
||||||
unsigned stress_seconds = 0;
|
unsigned stress_seconds = 0;
|
||||||
while ((opt = getopt_long(argc, const_cast<char *const *>(argv), "gthV", long_opts, &long_index)) != -1) {
|
while ((opt = getopt_long(argc, argv, "gthV", long_opts, &long_index)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'g':
|
case 'g':
|
||||||
req_gui = true;
|
req_gui = true;
|
||||||
@@ -303,7 +303,7 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!fe->Init(editor)) {
|
if (!fe->Init(argc, argv, editor)) {
|
||||||
std::cerr << "kte: failed to initialize frontend" << std::endl;
|
std::cerr << "kte: failed to initialize frontend" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user