aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-04-13 23:00:54 +0530
committerAkshay Nair <phenax5@gmail.com>2025-04-13 23:00:54 +0530
commit9fc1e934cd2c58ed1ba03f860b09e7a8cd48e792 (patch)
tree1480698f9b9089ac51307e19e59267c2a0f243f5
parent0d9aedc087f56a3da35b6abc8a0ee233c2d2483b (diff)
downloadnull-browser-9fc1e934cd2c58ed1ba03f860b09e7a8cd48e792.tar.gz
null-browser-9fc1e934cd2c58ed1ba03f860b09e7a8cd48e792.zip
Add support for number keys and open view by number key
-rw-r--r--TODO.org5
-rw-r--r--config.lua11
-rw-r--r--src/keymap/KeySeqParser.cpp5
-rw-r--r--src/widgets/BrowserApp.cpp1
4 files changed, 18 insertions, 4 deletions
diff --git a/TODO.org b/TODO.org
index 0563cc8..dc8b1d2 100644
--- a/TODO.org
+++ b/TODO.org
@@ -23,13 +23,14 @@
- [X] Configuration lua api
- [X] Switch to __internals
- [X] Respect cli args for main window
-- [ ] Downloading/download path config
+- [X] Downloading/download path config
- [ ] Use table for internals api options?
- [ ] Tests for api
- [ ] Log stdout, errors and results from lua somewhere
- [ ] Run JS in page
+- [ ] INVESTIGATE: Check why urlchanged doesnt fire for first url open
- [ ] INVESTIGATE: Segfault on close
-- [ ] INVESTIGATE: Errors in keymap segfaults
+- [ ] INVESTIGATE: Errors in keymap/thread segfaults
** Next
- [ ] Search text in page
diff --git a/config.lua b/config.lua
index eafc413..68bd01b 100644
--- a/config.lua
+++ b/config.lua
@@ -108,6 +108,17 @@ web.keymap.set('n', 'b', function()
end)
end)
+-- 1-0 for tab indexes 1-10
+for index = 1, 10 do
+ local key = index
+ if index >= 10 then key = 0 end
+ web.keymap.set('n', '<space>' .. key, function()
+ local views = web.view.list()
+ if index > #views then return end
+ web.view.select(views[index].id)
+ end)
+end
+
-- Next view
web.keymap.set('n', 'tn', function()
local views = web.view.list()
diff --git a/src/keymap/KeySeqParser.cpp b/src/keymap/KeySeqParser.cpp
index aef3b58..555e955 100644
--- a/src/keymap/KeySeqParser.cpp
+++ b/src/keymap/KeySeqParser.cpp
@@ -57,7 +57,10 @@ Qt::Key KeySeqParser::parse_key(const QString &key_name) {
if (key_name.length() == 1) {
const char key_char = key_name.toStdString().at(0);
- return Qt::Key(Qt::Key_A + (key_char - 'a'));
+ if (key_char >= 'a' && key_char <= 'z')
+ return Qt::Key(Qt::Key_A + (key_char - 'a'));
+ if (key_char >= '0' && key_char <= '9')
+ return Qt::Key(Qt::Key_0 + (key_char - '0'));
}
if (key_name == "space")
diff --git a/src/widgets/BrowserApp.cpp b/src/widgets/BrowserApp.cpp
index 9b65b3a..502d930 100644
--- a/src/widgets/BrowserApp.cpp
+++ b/src/widgets/BrowserApp.cpp
@@ -21,7 +21,6 @@ BrowserApp::BrowserApp() {
lua.load_file_sync("./config.lua");
// Initializes profile
- QList profiles{&default_profile};
for (auto *profile : profiles) {
profile->setDownloadPath(configuration.downloads_dir());
profile->setHttpUserAgent(configuration.user_agent());