formatting pass

This commit is contained in:
NunoSempere 2024-03-23 23:29:26 -03:00
parent a988ce965c
commit 204508bd0d
3 changed files with 21 additions and 17 deletions

View File

@ -5,7 +5,7 @@ This branch contains a bare-bones version of rosenrot, a webkit and gtk based br
- similar in many ways to the [original version of rose](https://github.com/mini-rose/rose-browser/tree/60173b6f5b562861b11dea17e3869ad6c3462bbb/src). - similar in many ways to the [original version of rose](https://github.com/mini-rose/rose-browser/tree/60173b6f5b562861b11dea17e3869ad6c3462bbb/src).
- But with the up to date libwebkit2gtk-4.1! - But with the up to date libwebkit2gtk-4.1!
- compilable with [tcc](https://bellard.org/tcc/)! (also with gcc/clang) - compilable with [tcc](https://bellard.org/tcc/)! (also with gcc/clang)
- *One c file*, 390 lines (~356 excluding comments) - *One c file*, 320 lines (~256 excluding comments & extraneous newlines)
- Still some minimal niceties: zoom, parsing more than one url from the command line, max number of tabs, plenty of shortcuts. - Still some minimal niceties: zoom, parsing more than one url from the command line, max number of tabs, plenty of shortcuts.
- Missing many quality of life features - Missing many quality of life features
- Meant for developers seeking to understand or replicate rosenrot - Meant for developers seeking to understand or replicate rosenrot

View File

@ -38,6 +38,10 @@ depsdebian:
STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true, AllowShortEnumsOnASingleLine: true}" STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true, AllowShortEnumsOnASingleLine: true}"
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
stats:
cat rosenrot.c | wc -l
gcc -fpreprocessed -dD -E -P rosenrot.c | wc -l
format: $(SRC) format: $(SRC)
$(FORMATTER) $(SRC) $(FORMATTER) $(SRC)

View File

@ -189,42 +189,42 @@ int handle_signal_keypress(void* self, GdkEvent* event, GtkNotebook* notebook)
case KEY(h): // go back case KEY(h): // go back
webkit_web_view_go_back(view); webkit_web_view_go_back(view);
break; break;
case KEY(j): // go forward case KEY(j): // go forward
webkit_web_view_go_forward(view); webkit_web_view_go_forward(view);
break; break;
case KEY(r): // reload case KEY(r): // reload
webkit_web_view_reload(view); webkit_web_view_reload(view);
break; break;
case KEY(R): // force reload case KEY(R): // force reload
webkit_web_view_reload_bypass_cache(view); webkit_web_view_reload_bypass_cache(view);
break; break;
case KEY(H): // back to home case KEY(H): // back to home
load_uri(view, HOME); load_uri(view, HOME);
break; break;
case KEY(equal): // zoom in case KEY(equal): // zoom in
webkit_web_view_set_zoom_level(view, (zoom += ZOOM_VAL)); webkit_web_view_set_zoom_level(view, (zoom += ZOOM_VAL));
break; break;
case KEY(minus): // zoom out case KEY(minus): // zoom out
webkit_web_view_set_zoom_level(view, (zoom -= ZOOM_VAL)); webkit_web_view_set_zoom_level(view, (zoom -= ZOOM_VAL));
break; break;
case KEY(0): // restore zoom case KEY(0): // restore zoom
webkit_web_view_set_zoom_level(view, (zoom = ZOOM)); webkit_web_view_set_zoom_level(view, (zoom = ZOOM));
break; break;
case KEY(KP_Page_Up):{ case KEY(KP_Page_Up): {
int n = gtk_notebook_get_n_pages(notebook); int n = gtk_notebook_get_n_pages(notebook);
int k = gtk_notebook_get_current_page(notebook); int k = gtk_notebook_get_current_page(notebook);
int l = (n + k - 1) % n; int l = (n + k - 1) % n;
gtk_notebook_set_current_page(notebook, l); gtk_notebook_set_current_page(notebook, l);
break; break;
} // previous tab } // previous tab
case KEY(KP_Page_Down): { // next tab case KEY(KP_Page_Down): { // next tab
int m = gtk_notebook_get_n_pages(notebook); int m = gtk_notebook_get_n_pages(notebook);
int i = gtk_notebook_get_current_page(notebook); int i = gtk_notebook_get_current_page(notebook);
int j = (i + 1) % m; int j = (i + 1) % m;
gtk_notebook_set_current_page(notebook, j); gtk_notebook_set_current_page(notebook, j);
break; break;
} }
case KEY(w): // close tab case KEY(w): // close tab
gtk_notebook_remove_page(notebook, gtk_notebook_get_current_page(notebook)); gtk_notebook_remove_page(notebook, gtk_notebook_get_current_page(notebook));
num_tabs -= 1; num_tabs -= 1;
if (gtk_notebook_get_n_pages(notebook) == 0) { if (gtk_notebook_get_n_pages(notebook) == 0) {
@ -250,17 +250,17 @@ int handle_signal_keypress(void* self, GdkEvent* event, GtkNotebook* notebook)
gtk_window_set_focus(window, GTK_WIDGET(bar.line)); gtk_window_set_focus(window, GTK_WIDGET(bar.line));
break; break;
} break; } break;
case KEY(n): // find next case KEY(n): // find next
webkit_find_controller_search_next(webkit_web_view_get_find_controller(view)); webkit_find_controller_search_next(webkit_web_view_get_find_controller(view));
break; break;
case KEY(N): // find previous case KEY(N): // find previous
webkit_find_controller_search_previous(webkit_web_view_get_find_controller(view)); webkit_find_controller_search_previous(webkit_web_view_get_find_controller(view));
break; break;
case KEY(t): // new tab case KEY(t): // new tab
notebook_create_new_tab(notebook, NULL); notebook_create_new_tab(notebook, NULL);
break; break;
} }
} else if(event_state == 0x0 && event_keyval == KEY(F11)){ } else if (event_state == 0x0 && event_keyval == KEY(F11)) {
if (is_fullscreen) if (is_fullscreen)
gtk_window_unfullscreen(window); gtk_window_unfullscreen(window);
else else