aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNunoSempere <nuno.sempere@protonmail.com>2024-01-06 16:30:09 +0100
committerNunoSempere <nuno.sempere@protonmail.com>2024-01-06 16:30:09 +0100
commitc33fc76b028833a5e76fca78cdea9931aed65936 (patch)
tree06a5c85c68f203a5bcfd2e5b3f5249e76a03fd0b
parentda8a0d7624fbeacb52ae14fff8d75ff2ca1cf536 (diff)
add cycling through tabs
-rw-r--r--config.h10
-rwxr-xr-xrosebin43280 -> 43184 bytes
-rw-r--r--rose.c27
3 files changed, 16 insertions, 21 deletions
diff --git a/config.h b/config.h
index bcb8000..5b1c333 100644
--- a/config.h
+++ b/config.h
@@ -37,6 +37,7 @@ typedef enum {
zoomin,
zoomout,
zoom_reset,
+ new_tab,
next_tab,
prev_tab,
close_tab,
@@ -44,7 +45,6 @@ typedef enum {
show_finder,
finder_next,
finder_prev,
- new_tab,
prettify,
hide_bar
} func;
@@ -66,13 +66,13 @@ static struct {
{ CTRL, KEY(equal), zoomin },
{ CTRL, KEY(minus), zoomout },
{ CTRL, KEY(0), zoom_reset },
- { CTRL, KEY(Page_Up), prev_tab },
- { CTRL, KEY(Page_Down), next_tab },
- { CTRL, KEY(t), next_tab },
+ { CTRL, KEY(Page_Up), prev_tab },
+ { CTRL, KEY(Page_Down), next_tab },
+ { CTRL, KEY(t), new_tab },
{ CTRL, KEY(w), close_tab },
{ 0x0, KEY(F11), toggle_fullscreen },
{ CTRL, KEY(l), show_searchbar },
- { CTRL, KEY(semicolon), hide_bar },
+ { CTRL, KEY(semicolon), hide_bar },
{ CTRL, KEY(f), show_finder },
{ CTRL, KEY(n), finder_next },
{ CTRL | SFT, KEY(N), finder_prev },
diff --git a/rose b/rose
index 9252000..a34f1af 100755
--- a/rose
+++ b/rose
Binary files differ
diff --git a/rose.c b/rose.c
index bacb637..f7d004e 100644
--- a/rose.c
+++ b/rose.c
@@ -316,24 +316,19 @@ int handle_key(func id, GtkNotebook* notebook)
(zoom = ZOOM));
break;
- case prev_tab:
- if (gtk_notebook_get_current_page(notebook) == 0) {
- gtk_notebook_set_current_page(notebook,
- gtk_notebook_get_n_pages(notebook) - 1);
- } else {
- gtk_notebook_prev_page(notebook);
- }
-
+ case prev_tab:; // declarations aren't statements
+ // <https://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a-switch-statement>
+ int n = gtk_notebook_get_n_pages(notebook);
+ int k = gtk_notebook_get_current_page(notebook);
+ int l = (n + k - 1) % n;
+ gtk_notebook_set_current_page(notebook, l);
break;
- case next_tab:
- if (gtk_notebook_get_current_page(notebook) == gtk_notebook_get_n_pages(notebook) - 1) {
- notebook_append(notebook, NULL);
- gtk_notebook_set_show_tabs(notebook, true);
- webkit_web_view_set_zoom_level(notebook_get_webview(notebook), zoom);
- } else {
- gtk_notebook_next_page(notebook);
- }
+ case next_tab:;
+ int m = gtk_notebook_get_n_pages(notebook);
+ int i = gtk_notebook_get_current_page(notebook);
+ int j = (i + 1) % m;
+ gtk_notebook_set_current_page(notebook, j);
break;
case close_tab: