commit 6534017424b779f625f5fa33b69f2c6428f979d5 from: Omar Polo date: Wed Jul 21 15:23:47 2021 UTC add other-window (C-x o) and allow focusing help buffer commit - 7102f5d94d510ebd2af6b36c075d3c338a7dc338 commit + 6534017424b779f625f5fa33b69f2c6428f979d5 blob - 9deeb69cb5c2f4c0b36385c29dfccc669fee25ac blob + 41d778cbe0b60fa78a0cddd9953bbeaf9eeb519b --- ChangeLog +++ ChangeLog @@ -1,4 +1,10 @@ 2021-07-21 Omar Polo + + * defaults.c (load_default_keys): bind other-window to C-x o + + * cmd.c (cmd_other_window): add other-window + + * ui.c (ui_other_window): allow to focus the side window * fs.c (handle_get): allow about: pages to be overridden by ~/.telescope/pages/about_*.gmi blob - 2df4b08df4fc3b507f3544260f332289f7271f36 blob + fdd46fa8c1720adef0bcbb18f8c0572d4e1f5181 --- cmd.c +++ cmd.c @@ -895,4 +895,10 @@ cmd_mini_goto_end(struct buffer *buffer) vl->parent->type = LINE_COMPL_CURRENT; buffer->current_line = vl; +} + +void +cmd_other_window(struct buffer *buffer) +{ + ui_other_window(); } blob - e9bb9ef720e8a94495753a15802443db171073de blob + 35769ebca2a61cf58ef95670cdfa49afe8698247 --- cmd.h +++ cmd.h @@ -37,6 +37,7 @@ CMD(cmd_next_heading, "Move point to the next heading CMD(cmd_next_line, "Move point to the next visual line."); CMD(cmd_next_page, "Go forward in the page history."); CMD(cmd_olivetti_mode, "Toggle olivetti-mode."); +CMD(cmd_other_window, "Select the other window."); CMD(cmd_previous_button, "Move point to the previous link."); CMD(cmd_previous_completion, "Select the previous completion."); CMD(cmd_previous_heading, "Move point to the previous heading."); blob - c960436b42483e9000b39eddb74730a0252e6eda blob + 4292085f16a406089816b95288f1602ac2f30fdf --- defaults.c +++ defaults.c @@ -244,6 +244,8 @@ load_default_keys(void) global_set_key("<", cmd_load_current_url); global_set_key("C-x C-f", cmd_load_url); global_set_key("C-x M-f", cmd_load_current_url); + + global_set_key("C-x o", cmd_other_window); global_set_key("C-x t 0", cmd_tab_close); global_set_key("C-x t 1", cmd_tab_close_other); blob - 5b94d1b78da4585cb3186d6672823b719c01e096 blob + d75b20a84a125b89e724455ebe092f8c93f9f07b --- ui.c +++ ui.c @@ -98,6 +98,7 @@ struct buffer helpwin; int help_lines, help_cols; static int side_window; +static int in_side_window; static struct timeval loadingev_timer = { 0, 250000 }; @@ -180,6 +181,8 @@ current_buffer(void) { if (in_minibuffer) return &ministate.buffer; + if (in_side_window) + return &helpwin; return ¤t_tab->buffer; } @@ -701,11 +704,15 @@ trust_status_char(enum trust_state ts) static void redraw_modeline(struct tab *tab) { + struct buffer *buffer; double pct; int x, y, max_x, max_y; - const char *mode = tab->buffer.page.name; + const char *mode; const char *spin = "-\\|/"; + buffer = current_buffer(); + mode = buffer->page.name; + werase(modeline); wattr_on(modeline, modeline_face.background, NULL); wmove(modeline, 0, 0); @@ -715,21 +722,21 @@ redraw_modeline(struct tab *tab) trust_status_char(tab->trust), mode == NULL ? "(none)" : mode); - pct = (tab->buffer.line_off + tab->buffer.curs_y) * 100.0 - / tab->buffer.line_max; - - if (tab->buffer.line_max <= (size_t)body_lines) + pct = (buffer->line_off + buffer->curs_y) * 100.0 + / buffer->line_max; + + if (buffer->line_max <= (size_t)body_lines) wprintw(modeline, "All "); - else if (tab->buffer.line_off == 0) + else if (buffer->line_off == 0) wprintw(modeline, "Top "); - else if (tab->buffer.line_off + body_lines >= tab->buffer.line_max) + else if (buffer->line_off + body_lines >= buffer->line_max) wprintw(modeline, "Bottom "); else wprintw(modeline, "%.0f%% ", pct); wprintw(modeline, "%d/%d %s ", - tab->buffer.line_off + tab->buffer.curs_y, - tab->buffer.line_max, + buffer->line_off + buffer->curs_y, + buffer->line_max, tab->hist_cur->h); getyx(modeline, y, x); @@ -841,9 +848,17 @@ place_cursor(int soft) touch = wrefresh; if (in_minibuffer) { + if (side_window) + touch(help); + touch(body); + touch(echoarea); + } else if (in_side_window) { touch(body); touch(echoarea); + touch(help); } else { + if (side_window) + touch(help); touch(echoarea); touch(body); } @@ -1086,6 +1101,7 @@ ui_init() /* non-blocking input */ wtimeout(body, 0); + wtimeout(help, 0); mvwprintw(body, 0, 0, ""); @@ -1143,6 +1159,8 @@ ui_toggle_side_window(void) side_window = !side_window; if (side_window) recompute_help(); + else + in_side_window = 0; /* * ugly hack, but otherwise the window doesn't get updated @@ -1197,6 +1215,15 @@ ui_read(const char *prompt, void (*fn)(const char*, st } void +ui_other_window(void) +{ + if (side_window) + in_side_window = !in_side_window; + else + message("No other window to select"); +} + +void ui_suspend(void) { endwin(); blob - 1c19636b76ec0edab111d99ca338311175ac624e blob + db3789d6001bd4fab4e04a800b1e045e5b9748ad --- ui.h +++ ui.h @@ -118,8 +118,9 @@ void ui_toggle_side_window(void); void ui_schedule_redraw(void); void ui_after_message_hook(void); void ui_require_input(struct tab *, int); -void ui_read(const char *, void (*)(const char *, struct tab *), struct tab *); void ui_yornp(const char *, void (*)(int, struct tab *), struct tab *); +void ui_read(const char *, void (*)(const char *, struct tab *), struct tab *); +void ui_other_window(void); void ui_suspend(void); void ui_end(void);