/* This file is released into the public domain. * No rights reserved. Copy, modify, do whatever you want. */ #ifndef CONFIG_H #define CONFIG_H #include #include /* forward declarations from main.c */ extern void tabopen(Cinnamon* cinnamon); extern void tabclose(Cinnamon* cinnamon); extern void set_mode(Cinnamon* cinnamon, int new_mode); /* guard ensures config exists/enables brower */ #define CINNAMON_ENABLED /* default window width/height, can be resized after. */ #define WINDOW_WIDTH 1024 #define WINDOW_HEIGHT 768 #define HOMEPAGE "https://start.duckduckgo.com" /* if a keybind is unbound, still don't send when not in insert mode */ #define NO_SEND_UNBOUND_KEYBINDS /* if the last tab is closed, don't quit, just make a fresh one */ #define NO_QUIT_ON_CLOSE_LAST_TAB /* hide the tab bar, unless a keybind or command shows it */ #define HIDE_TAB_BAR /* Keybind definitions */ /* we use the _kbd prefix here just because, idk, good practice to keep keybinds isolated? in practice use whatever the hell you want as long as it doesnt interfere with builtin functions */ static void _kbd_insmode(Cinnamon* cinnamon, void* arg) { set_mode(cinnamon, 1); } static void _kbd_tabopen(Cinnamon* cinnamon, void* arg) { /* wrapper to satisfy the arg + keep keybinds isolated */ tabopen(cinnamon); } static void _kbd_scroll(Cinnamon* cinnamon, void* arg) { GtkWidget *webview = gtk_notebook_get_nth_page(GTK_NOTEBOOK(cinnamon->notebook), gtk_notebook_get_current_page(GTK_NOTEBOOK(cinnamon->notebook))); const char* js; if (strcmp((const char*)arg, "left") == 0) { js = "window.scrollBy(-100, 0);"; } else if (strcmp((const char*)arg, "right") == 0) { js = "window.scrollBy(100, 0);"; } else if (strcmp((const char*)arg, "up") == 0) { js = "window.scrollBy(0, -100);"; } else if (strcmp((const char*)arg, "down") == 0) { js = "window.scrollBy(0, 100);"; } else { js = "alert(\"an unexpected error occurred in the scroll handler\");"; } /* some distros ship older versions of webkit2gtk-4.1, use the deprecated run_javascript api to ensure compatibility */ /* this entire scroll mechanism is scuffed, first of all, i should have abstracted that in main.c, second of all, we're using JS apis of all things just to scroll T_T */ /* this code sucks, * you know it, * i know it. * call me an idiot later and just use the browser. */ webkit_web_view_run_javascript(WEBKIT_WEB_VIEW(webview), js, NULL, NULL, NULL); } static void _kbd_tabsel(Cinnamon* cinnamon, void* arg) { gtk_notebook_set_current_page(GTK_NOTEBOOK(cinnamon->notebook), (int)(intptr_t)arg); } static void _kbd_tabclose(Cinnamon* cinnamon, void* arg) { tabclose(cinnamon); } static const Keybind keybinds[] = { { "t", &_kbd_tabopen, NULL }, { "d", &_kbd_tabclose, NULL }, // { "o", ":commandline_show \":open\"" }, { "i", &_kbd_insmode, NULL }, { "j", &_kbd_scroll, "down" }, { "k", &_kbd_scroll, "up" }, { "h", &_kbd_scroll, "left" }, { "l", &_kbd_scroll, "right" }, { "", &_kbd_tabsel, (void*)(intptr_t)0 }, { "", &_kbd_tabsel, (void*)(intptr_t)1 }, { "", &_kbd_tabsel, (void*)(intptr_t)2 }, { "", &_kbd_tabsel, (void*)(intptr_t)3 }, { "", &_kbd_tabsel, (void*)(intptr_t)4 }, { "", &_kbd_tabsel, (void*)(intptr_t)5 }, { "", &_kbd_tabsel, (void*)(intptr_t)6 }, { "", &_kbd_tabsel, (void*)(intptr_t)7 }, { "", &_kbd_tabsel, (void*)(intptr_t)8 }, { "", &_kbd_tabsel, (void*)(intptr_t)-1 }, }; #endif