aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format14
-rw-r--r--.gitignore3
-rw-r--r--config.def.h76
-rw-r--r--config.h78
-rwxr-xr-xrose-mklink7
-rw-r--r--rose.c18
6 files changed, 101 insertions, 95 deletions
diff --git a/.clang-format b/.clang-format
index 69e6656..96bec56 100644
--- a/.clang-format
+++ b/.clang-format
@@ -27,11 +27,11 @@ SpaceBeforeCtorInitializerColon: False
SpaceBeforeInheritanceColon: False
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
- AfterControlStatements: True
- AfterForeachMacros: True
- AfterFunctionDeclarationName: False
- AfterFunctionDefinitionName: False
- AfterIfMacros: True
- AfterOverloadedOperator: False
- BeforeNonEmptyParentheses: False
+ AfterControlStatements: True
+ AfterForeachMacros: True
+ AfterFunctionDeclarationName: False
+ AfterFunctionDefinitionName: False
+ AfterIfMacros: True
+ AfterOverloadedOperator: False
+ BeforeNonEmptyParentheses: False
SpaceBeforeRangeBasedForLoopColon: True
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0652ac8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+rose
+config.h
+.clang-format
diff --git a/config.def.h b/config.def.h
new file mode 100644
index 0000000..cb3c2cf
--- /dev/null
+++ b/config.def.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2022 mini-rose
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and any associated documentation
+ * files to modify, copy, merge, publish, distribute and/or
+ * sublicense copies of this sotware for their own use.
+ * This code does not come with any warranty.
+ *
+ * Author: fenze <contact@fenze.dev>
+ */
+
+#include <gdk/gdkkeysyms.h>
+
+/* See more:
+ * https://webkitgtk.org/reference/webkit2gtk/stable/class.Settings.html */
+#define WEBKIT \
+ "enable-back-forward-navigation-gestures", true, "enable-developer-extras", true, \
+ "enable-smooth-scrolling", false
+
+#define GTK "gtk-application-prefer-dark-theme", true, "gtk-enable-animations", false
+
+#define HOME "https://duckduckgo.com"
+#define SEARCH "https://duckduckgo.com/?q=%s"
+#define CACHE_DIR "/home/fenze/.cache/rose"
+
+#define KEY(x) GDK_KEY_##x
+#define ZOOM 1 /* Starting zoom level */
+#define ZOOM_VAL .1 /* Zooming value in zoomin/zoomout functions */
+#define BG_COLOR "#1E1E2E"
+
+typedef enum {
+ goback,
+ goforward,
+ refresh,
+ refresh_force,
+ back_to_home,
+ toggle_fullscreen,
+ zoomin,
+ zoomout,
+ zoom_reset,
+ next_tab,
+ prev_tab,
+ close_tab,
+ show_searchbar,
+ show_finder,
+ finder_next,
+ finder_prev
+} func;
+
+#define SFT 1 << 0
+#define CTRL 1 << 2
+#define ALT 1 << 3
+
+static struct {
+ unsigned mod;
+ unsigned key;
+ func id;
+} keys[] = {
+ { CTRL, KEY(h), goback },
+ { CTRL, KEY(l), goforward },
+ { CTRL, KEY(r), refresh },
+ { CTRL | SFT, KEY(R), refresh_force },
+ { CTRL | SFT, KEY(H), back_to_home },
+ { CTRL, KEY(equal), zoomin },
+ { CTRL, KEY(minus), zoomout },
+ { CTRL, KEY(0), zoom_reset },
+ { ALT, KEY(h), prev_tab },
+ { ALT, KEY(l), next_tab },
+ { CTRL, KEY(w), close_tab },
+ { 0x0, KEY(F11), toggle_fullscreen },
+ { CTRL, KEY(e), show_searchbar },
+ { CTRL, KEY(f), show_finder },
+ { CTRL, KEY(n), finder_next },
+ { CTRL | SFT, KEY(N), finder_prev }
+};
diff --git a/config.h b/config.h
deleted file mode 100644
index 762c1d6..0000000
--- a/config.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2022 mini-rose
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and any associated documentation
- * files to modify, copy, merge, publish, distribute and/or
- * sublicense copies of this sotware for their own use.
- * This code does not come with any warranty.
- *
- * Author: fenze <contact@fenze.dev>
- */
-
-#include <gdk/gdkkeysyms.h>
-
-/* See more: https://webkitgtk.org/reference/webkit2gtk/stable/class.Settings.html */
-#define WEBKIT \
- "enable-back-forward-navigation-gestures", true, \
- "enable-developer-extras", true, \
- "enable-smooth-scrolling", false
-
-#define GTK \
- "gtk-application-prefer-dark-theme", true, \
- "gtk-enable-animations", false
-
-#define HOME "https://duckduckgo.com"
-#define SEARCH "https://duckduckgo.com/?q=%s"
-#define CACHE_DIR "/home/fenze/.cache/rose"
-
-#define KEY(x) GDK_KEY_ ## x
-#define ZOOM 1 /* Starting zoom level */
-#define ZOOM_VAL .1 /* Zooming value in zoomin/zoomout functions */
-#define BG_COLOR "#1E1E2E"
-
-typedef enum {
- goback, goforward,
- refresh, refresh_force,
- back_to_home, toggle_fullscreen,
- zoomin, zoomout, zoom_reset,
- next_tab, prev_tab, close_tab,
- show_searchbar, show_finder,
- finder_next, finder_prev
-} func;
-
-#define SHIFT 1 << 0
-#define CTRL 1 << 2
-#define ALT 1 << 3
-
-static struct Key {
- unsigned mod;
- unsigned key;
- func id;
-} keys[] = {
- { CTRL, KEY(h), goback },
- { CTRL, KEY(l), goforward },
-
- /* Refresh keybinds */
- { CTRL, KEY(r), refresh },
- { CTRL | SHIFT, KEY(R), refresh_force },
-
- { CTRL | SHIFT, KEY(H), back_to_home },
-
- { CTRL, KEY(equal), zoomin },
- { CTRL, KEY(minus), zoomout },
- { CTRL, KEY(0), zoom_reset },
-
- { ALT, KEY(h), prev_tab },
- { ALT, KEY(l), next_tab },
-
- { CTRL, KEY(w), close_tab },
-
- { 0, KEY(F11), toggle_fullscreen },
-
- { CTRL, KEY(e), show_searchbar },
- { CTRL, KEY(f), show_finder },
-
- { CTRL, KEY(n), finder_next },
- { CTRL | SHIFT, KEY(N), finder_prev }
-};
diff --git a/rose-mklink b/rose-mklink
index eb878cf..a56f321 100755
--- a/rose-mklink
+++ b/rose-mklink
@@ -1,11 +1,12 @@
#!/bin/sh
-if [ "$1" = "--help" ] || [ -z "$1" ]; then
+test "$1" = "--help" || test -z "$1" && {
echo -e "usage: rose-mklink <alias> <url>\n"
echo "Create a /usr/bin link to a website."
-fi
+ exit
+}
-test -z "$1" || test -z "$2" || {
+test -z "$2" || {
[ -f "/usr/bin/$1" ] && {
echo "/usr/bin/$1 already exists, remove it first"
exit 1
diff --git a/rose.c b/rose.c
index 8914048..326ef8d 100644
--- a/rose.c
+++ b/rose.c
@@ -14,13 +14,17 @@
#include <webkit2/webkit2.h>
-#define CACHE \
- "base-cache-directory", CACHE_DIR, "base-data-directory", CACHE_DIR, \
- "disk-cache-directory", CACHE_DIR, "dom-cache-directory", CACHE_DIR, \
- "hsts-cache-directory", CACHE_DIR, "indexeddb-directory", CACHE_DIR, "itp-directory", \
- CACHE_DIR, "local-storage-directory", CACHE_DIR, \
- "offline-application-cache-directory", CACHE_DIR, \
- "service-worker-registrations-directory", CACHE_DIR
+#define CACHE \
+ "base-cache-directory", CACHE_DIR, \
+ "base-data-directory", CACHE_DIR, \
+ "disk-cache-directory", CACHE_DIR, \
+ "dom-cache-directory", CACHE_DIR, \
+ "hsts-cache-directory", CACHE_DIR, \
+ "indexeddb-directory", CACHE_DIR, \
+ "itp-directory", CACHE_DIR, \
+ "local-storage-directory", CACHE_DIR, \
+ "offline-application-cache-directory", CACHE_DIR, \
+ "service-worker-registrations-directory", CACHE_DIR
enum { _SEARCH, _FIND };