commit - 355bef226138f678eb361d2bf22a519aac1480db
commit + 1c412d480d6f8b782a3aa610e0396a678bfecddb
blob - 6aa7db1e21900bc97c85a23265c4d16e96f53054
blob + 0cc60ba3b81b4d29416b8225cb49eb2c98f004e7
--- ChangeLog
+++ ChangeLog
+2021-06-25 Omar Polo <op@omarpolo.com>
+
+ * cmd.c (cmd_next_heading): added next-heading (C-c n)
+ (cmd_previous_heading): added previous-heading (C-c p)
+
2021-06-24 Omar Polo <op@omarpolo.com>
* ui.c (load_default_keys): bind > to load-url
blob - 10a5e4971dcef9c4d0a7b0bfe0a5e295707b8f68
blob + 0dfc9e501a00afc9f03d3595ce80c950c1562ec6
--- cmd.c
+++ cmd.c
}
cmd_next_line(buffer);
} while (buffer->current_line->parent->type != LINE_LINK);
+}
+
+static inline int
+is_heading(const struct line *l)
+{
+ return l->type == LINE_TITLE_1 ||
+ l->type == LINE_TITLE_2 ||
+ l->type == LINE_TITLE_3;
+}
+
+void
+cmd_previous_heading(struct buffer *buffer)
+{
+ struct excursion place;
+
+ save_excursion(&place, buffer);
+
+ do {
+ if (buffer->current_line == NULL ||
+ buffer->current_line == TAILQ_FIRST(&buffer->head)) {
+ restore_excursion(&place, buffer);
+ message("No previous heading");
+ return;
+ }
+ cmd_previous_line(buffer);
+ } while (!is_heading(buffer->current_line->parent));
}
void
+cmd_next_heading(struct buffer *buffer)
+{
+ struct excursion place;
+
+ save_excursion(&place, buffer);
+
+ do {
+ if (buffer->current_line == NULL ||
+ buffer->current_line == TAILQ_LAST(&buffer->head, vhead)) {
+ restore_excursion(&place, buffer);
+ message("No next heading");
+ return;
+ }
+ cmd_next_line(buffer);
+ } while (!is_heading(buffer->current_line->parent));
+}
+
+void
cmd_previous_page(struct buffer *buffer)
{
struct tab *tab = current_tab();
blob - c7a8148ba7f7f0121425724656ae3a293546625d
blob + 8cceff520e50d166999917d6013a2024501f07f3
--- cmd.h
+++ cmd.h
CMD(cmd_push_button_new_tab);
CMD(cmd_previous_button);
CMD(cmd_next_button);
+CMD(cmd_previous_heading);
+CMD(cmd_next_heading);
CMD(cmd_previous_page);
CMD(cmd_next_page);
CMD(cmd_clear_minibuf);
blob - 837944f20a483d3f73d5777a9733be2dc905d9b3
blob + e2c7d64c07d6c03008d2aed3f47d819709ee11f7
--- telescope.1
+++ telescope.1
clear-minibuf
.It M-x
execute-extended-command
+.It C-c p
+previous-heading
+.It C-c n
+next-heading
.It >
load-url
.It C-x C-f
Move point at the end of the current (visual) line.
.It Ic next-button
Move point to the next link.
+.It Ic next-heading
+Move point to the next heading.
.It Ic next-line
Move point to the next (visual) line, in the same column if possible.
.It Ic previous-button
Move point to the previous link.
+.It Ic previous-heading
+Move point to the previous heading.
.It Ic previous-line
Move point to the previous (visual) line.
.El
blob - fd9b8a7dec36cd6bc2f201cf6ad4448100550909
blob + a5f10a6925afbd94391c9ed4af684a0889794f47
--- ui.c
+++ ui.c
global_set_key("M-x", cmd_execute_extended_command);
+ global_set_key("C-c p", cmd_previous_heading);
+ global_set_key("C-c n", cmd_next_heading);
+
global_set_key(">", cmd_load_url);
global_set_key("C-x C-f", cmd_load_url);
global_set_key("C-x M-f", cmd_load_current_url);