aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/MainWindow.cpp
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-09 22:09:09 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-09 23:41:36 +0530
commit6b1d49e607da16853d1a0f460dbe756538e4790c (patch)
treed5c784e6e568272afbb7530ea5dd752ce835b8fa /src/widgets/MainWindow.cpp
parent61f99089288138989cf244d174882aa5088b738b (diff)
downloadnull-browser-6b1d49e607da16853d1a0f460dbe756538e4790c.tar.gz
null-browser-6b1d49e607da16853d1a0f460dbe756538e4790c.zip
Add lua integration for command input (web.open, web.tabopen)
Diffstat (limited to 'src/widgets/MainWindow.cpp')
-rw-r--r--src/widgets/MainWindow.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/widgets/MainWindow.cpp b/src/widgets/MainWindow.cpp
index e660e52..14f6aa7 100644
--- a/src/widgets/MainWindow.cpp
+++ b/src/widgets/MainWindow.cpp
@@ -23,7 +23,7 @@ MainWindow::MainWindow() {
layout->addWidget(browserManager);
// Command input
- commandInput = new CommandInput(browserManager->currentUrl().toString());
+ commandInput = new CommandInput;
hideURLInput();
commandInput->move(0, 0);
connect(commandInput, &CommandInput::submitted, this,
@@ -31,6 +31,13 @@ MainWindow::MainWindow() {
connect(commandInput, &CommandInput::cancelled, this,
&MainWindow::hideURLInput);
layout->addWidget(commandInput);
+
+ // Lua runtime
+ luaRuntime = LuaRuntime::instance();
+ connect(luaRuntime, &LuaRuntime::urlOpenned, this,
+ [this](QString url, OpenType openType) {
+ this->browserManager->openUrl(QUrl(url), openType);
+ });
}
void MainWindow::hideURLInput() {
@@ -46,8 +53,14 @@ void MainWindow::showURLInput() {
}
void MainWindow::evaluateCommand(QString command) {
- if (!command.isEmpty())
- browserManager->setCurrentUrl(command);
+ if (!command.isEmpty()) {
+ // TODO: Temporary hack
+ if (command.startsWith("lua ")) {
+ luaRuntime->evaluate(command.slice(4).toStdString().c_str());
+ } else {
+ browserManager->setCurrentUrl(command);
+ }
+ }
hideURLInput();
}