aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CommandParser.hpp29
-rw-r--r--include/Configuration.hpp13
-rw-r--r--include/InputMediator.hpp33
-rw-r--r--include/LuaRuntime.hpp29
-rw-r--r--include/keymap/KeySeqParser.hpp44
-rw-r--r--include/keymap/KeymapEvaluator.hpp42
-rw-r--r--include/utils.hpp11
-rw-r--r--include/widgets/MainWindow.hpp19
-rw-r--r--include/widgets/WebView.hpp13
-rw-r--r--include/widgets/WebViewStack.hpp55
10 files changed, 0 insertions, 288 deletions
diff --git a/include/CommandParser.hpp b/include/CommandParser.hpp
deleted file mode 100644
index 9197df5..0000000
--- a/include/CommandParser.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-
-#include <QtCore/qcontainerfwd.h>
-#include <QtCore>
-
-enum CommandType {
- Noop,
- LuaEval,
- Open,
- TabOpen,
- TabNext,
- TabPrev,
- TabSelect,
-};
-
-struct Cmd {
- CommandType command;
- QString argsString;
- QString rawInput;
-};
-
-class CommandParser {
-public:
- CommandParser();
- Cmd parse(QString command);
-
-private:
- CommandType toCommandType(QString cmd);
-};
diff --git a/include/Configuration.hpp b/include/Configuration.hpp
deleted file mode 100644
index cc68803..0000000
--- a/include/Configuration.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-
-#include <QtCore>
-#include <cstdio>
-
-class Configuration : public QObject {
- Q_OBJECT
-
-public:
- using QObject::QObject;
-
- QUrl newTabUrl = QUrl("https://lite.duckduckgo.com");
-};
diff --git a/include/InputMediator.hpp b/include/InputMediator.hpp
deleted file mode 100644
index 7194ff9..0000000
--- a/include/InputMediator.hpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#pragma once
-
-#include <QWidget>
-#include <QtCore>
-
-#include "LuaRuntime.hpp"
-#include "keymap/KeymapEvaluator.hpp"
-#include "utils.hpp"
-#include "widgets/WebViewStack.hpp"
-
-class InputMediator : public QObject {
- Q_OBJECT
-
-public:
- InputMediator(WebViewStack *webViewStack, LuaRuntime *luaRuntime,
- KeymapEvaluator *keymapEvaluator);
- ~InputMediator();
-
- DELEGATE(webViewStack, openUrl, openUrl)
- DELEGATE(webViewStack, currentUrl, currentUrl)
- DELEGATE(webViewStack, next, nextWebView)
- DELEGATE(webViewStack, previous, previousWebView)
- DELEGATE(webViewStack, closeCurrent, closeCurrentWebView)
- DELEGATE(keymapEvaluator, evaluate, evaluateKeymap)
-
-private:
- void evaluateCommand(QString command);
-
-private:
- WebViewStack *webViewStack;
- LuaRuntime *luaRuntime;
- KeymapEvaluator *keymapEvaluator;
-};
diff --git a/include/LuaRuntime.hpp b/include/LuaRuntime.hpp
deleted file mode 100644
index 5bfc82c..0000000
--- a/include/LuaRuntime.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-#include <QtCore>
-#include <lua.hpp>
-
-#include "widgets/WebViewStack.hpp"
-
-class LuaRuntime : public QObject {
- Q_OBJECT
-
-public:
- static LuaRuntime *instance() {
- static LuaRuntime inst;
- return &inst;
- }
-
- void evaluate(QString code);
-
-signals:
- void urlOpened(QString url, OpenType openType);
-
-protected:
- LuaRuntime();
- ~LuaRuntime();
- static int lua_onUrlOpen(lua_State *state);
- static int lua_onUrlTabOpen(lua_State *state);
-
-private:
- lua_State *state;
-};
diff --git a/include/keymap/KeySeqParser.hpp b/include/keymap/KeySeqParser.hpp
deleted file mode 100644
index fac2546..0000000
--- a/include/keymap/KeySeqParser.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#pragma once
-
-#include <QtCore/qnamespace.h>
-#include <QtCore>
-#include <cmath>
-
-struct KeyChord {
- Qt::KeyboardModifiers mod;
- Qt::Key key;
-};
-bool operator==(const KeyChord a, const KeyChord b);
-
-typedef QList<KeyChord> KeySequence;
-
-enum KeyMatchType {
- NoMatch,
- Match,
- Pending,
-};
-
-class KeySeqParser {
-public:
- static const KeyMatchType keySequenceMatch(const KeySequence target,
- const KeySequence current) {
- for (int i = 0; i < target.length(); i++) {
- if (current.length() <= i)
- return KeyMatchType::Pending;
-
- if (target[i].key != current[i].key ||
- !target[i].mod.testFlags(current[i].mod))
- return KeyMatchType::NoMatch;
- }
-
- return KeyMatchType::Match;
- }
-
-public:
- KeySeqParser();
-
- KeySequence parse(QString keySequence);
-
-private:
- Qt::Key parseKey(QString keyName);
-};
diff --git a/include/keymap/KeymapEvaluator.hpp b/include/keymap/KeymapEvaluator.hpp
deleted file mode 100644
index db93900..0000000
--- a/include/keymap/KeymapEvaluator.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#pragma once
-
-#include <QWidget>
-#include <QtCore/qmap.h>
-#include <QtCore/qnamespace.h>
-#include <QtCore>
-#include <functional>
-
-#include "keymap/KeySeqParser.hpp"
-#include "utils.hpp"
-
-typedef std::function<void()> KeyAction;
-
-struct KeyMap {
- KeySequence keySequence;
- KeyAction action;
-};
-
-enum KeyMode { Normal, Insert };
-
-class KeymapEvaluator : public QObject {
- Q_OBJECT
-
-public:
- KeymapEvaluator();
-
- void addKeymap(KeyMode mode, QString key, KeyAction action);
- bool evaluate(Qt::KeyboardModifiers modifiers, Qt::Key key);
-
- DEFINE_SETTER(setCurrentMode, currentMode)
- DEFINE_GETTER(getCurrentMode, currentMode)
-
-private:
- const QList<KeyMap> *currentModeKeys();
- bool isInsertableMode();
-
-private:
- QMap<KeyMode, QList<KeyMap>> modalKeys;
- KeySeqParser keySeqParser;
- KeyMode currentMode = KeyMode::Normal;
- KeySequence activeKeySequence;
-};
diff --git a/include/utils.hpp b/include/utils.hpp
deleted file mode 100644
index 0650ac2..0000000
--- a/include/utils.hpp
+++ /dev/null
@@ -1,11 +0,0 @@
-
-#define DELEGATE(OBJ, METHOD, METHOD_AS) \
- template <typename... Args> decltype(auto) METHOD_AS(Args &&...args) { \
- return OBJ->METHOD(std::forward<Args>(args)...); \
- }
-
-#define DEFINE_SETTER(METHOD, PROPERTY) \
- template <typename Arg> void METHOD(Arg val) { PROPERTY = val; }
-
-#define DEFINE_GETTER(METHOD, EXPR) \
- template <typename Arg> decltype(auto) METHOD() { return EXPR; }
diff --git a/include/widgets/MainWindow.hpp b/include/widgets/MainWindow.hpp
deleted file mode 100644
index 2bbc42e..0000000
--- a/include/widgets/MainWindow.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-
-#include <QMainWindow>
-
-#include "Configuration.hpp"
-#include "InputMediator.hpp"
-
-class MainWindow : public QMainWindow {
-public:
- MainWindow();
-
-private:
- void keyPressEvent(QKeyEvent *event) override;
- bool eventFilter(QObject *object, QEvent *event) override;
-
-private:
- InputMediator *inputMediator;
- Configuration configuration;
-};
diff --git a/include/widgets/WebView.hpp b/include/widgets/WebView.hpp
deleted file mode 100644
index 8a95139..0000000
--- a/include/widgets/WebView.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-
-#include <QKeyEvent>
-#include <QWebEngineView>
-#include <QWidget>
-#include <QtCore>
-
-class WebView : public QWebEngineView {
- Q_OBJECT
-
-public:
- WebView(QWebEngineProfile *profile);
-};
diff --git a/include/widgets/WebViewStack.hpp b/include/widgets/WebViewStack.hpp
deleted file mode 100644
index e5b7ecc..0000000
--- a/include/widgets/WebViewStack.hpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#pragma once
-
-#include <QStackedLayout>
-#include <QWebEngineProfile>
-#include <sys/types.h>
-
-#include "Configuration.hpp"
-#include "widgets/WebView.hpp"
-
-enum OpenType { OpenUrl, OpenUrlInTab, OpenUrlInBgTab, OpenUrlInWindow };
-
-struct Tab {
- QString url;
- QString title;
-};
-
-class WebViewStack : public QWidget {
- Q_OBJECT
-
-public:
- inline static const QUrl NewtabURL = QUrl("about:blank");
-
-public:
- WebViewStack(const Configuration *configuration,
- QWebEngineProfile *profile = new QWebEngineProfile,
- QWidget *parent = nullptr);
-
- void openUrl(QUrl url, OpenType openType = OpenType::OpenUrl);
-
- std::vector<QUrl> urls();
- QList<Tab> getTabList();
- u_int32_t currentWebViewIndex();
- u_int32_t count();
- QUrl currentUrl();
-
- void focusWebView(long index);
- void next();
- void previous();
-
- void close(long index);
- void closeCurrent();
-
-private:
- void setCurrentUrl(QUrl url);
- WebView *createNewWebView(QUrl url, bool focus = false);
-
-private slots:
- void onNewWebViewRequest(QWebEngineNewWindowRequest &request);
-
-private:
- const Configuration *configuration;
- QWebEngineProfile *profile;
- QStackedLayout *layout;
- QList<WebView *> webViewList;
-};