Blob
- Date:
- Message:
- save and restore scroll position Save the offset to the first and current line of the buffers and restore it when the page is loaded. This restores almost the exact viewport: we save the offset of the *real* line in the document, but they get wrapped before being displayed, so the actual restored position may be slightly above from the original one (think of a long paragraph that gets wrapped over multiple visual lines.) In practice, this isn't a drawback but only an improvement over the current behaviour. In the future we could save also the offset *inside* the line, to restore the exact position, but that felt unnecessary for now. Persisting the postion on the session file ensures that even when re-opening telescope the scroll position is correct. There are some very active pages, such as antenna or other aggregator, where this feature doesn't really work well if you re-open the page after a while, since new links are available, but otherwise is a god sent! See also github issue #1
- Actions:
- History | Blame | Raw File
1 /*2 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>3 *4 * Permission to use, copy, modify, and distribute this software for any5 * purpose with or without fee is hereby granted, provided that the above6 * copyright notice and this permission notice appear in all copies.7 *8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.15 */17 #ifndef UI_H18 #define UI_H20 #include "keymap.h"21 #include "telescope.h"23 extern int body_lines;24 extern int body_cols;26 extern struct kmap global_map, minibuffer_map, *current_map, *base_map;28 struct excursion {29 int curs_x, curs_y;30 size_t line_off;31 struct vline *current_line;32 struct vline *top_line;33 size_t cpoff;34 };36 enum pairs {37 PTL_BG = 1,38 PTL_TAB,39 PTL_CURR,41 PBODY,42 PBLEFT,43 PBRIGHT,45 PT,46 PT_PRFX,47 PT_TRAIL,48 PL,49 PL_PRFX,50 PL_TRAIL,51 PT1,52 PT1_PRFX,53 PT1_TRAIL,54 PT2,55 PT2_PRFX,56 PT2_TRAIL,57 PT3,58 PT3_PRFX,59 PT3_TRAIL,60 PI,61 PI_PRFX,62 PI_TRAIL,63 PQ,64 PQ_PRFX,65 PQ_TRAIL,66 PPSTART,67 PPSTART_PRFX,68 PPSTART_TRAIL,69 PP,70 PP_PRFX,71 PP_TRAIL,72 PPEND,73 PPEND_PRFX,74 PPEND_TRAIL,76 PPATCH,77 PPATCH_PRFX,78 PPATCH_TRAIL,79 PPATCH_HDR,80 PPATCH_HDR_PRFX,81 PPATCH_HDR_TRAIL,82 PPATCH_HUNK_HDR,83 PPATCH_HUNK_HDR_PRFX,84 PPATCH_HUNK_HDR_TRAIL,85 PPATCH_ADD,86 PPATCH_ADD_PRFX,87 PPATCH_ADD_TRAIL,88 PPATCH_DEL,89 PPATCH_DEL_PRFX,90 PPATCH_DEL_TRAIL,92 PCOMPL_PRFX,93 PCOMPL,94 PCOMPL_TRAIL,96 PCOMPL_CURR_PRFX,97 PCOMPL_CURR,98 PCOMPL_CURR_TRAIL,100 PHELP_PRFX,101 PHELP,102 PHELP_TRAIL,104 PDOWNLOAD_PRFX,105 PDOWNLOAD,106 PDOWNLOAD_TRAIL,108 PDOWNLOAD_DONE_PRFX,109 PDOWNLOAD_DONE,110 PDOWNLOAD_DONE_TRAIL,112 PDOWNLOAD_INFO_PRFX,113 PDOWNLOAD_INFO,114 PDOWNLOAD_INFO_TRAIL,116 PDOWNLOAD_WIN,118 PMODELINE,120 PMINIBUF,122 PFRINGE_PRFX,123 PFRINGE,124 PFRINGE_TRAIL,125 };127 extern struct thiskey thiskey;129 extern struct tab *current_tab;131 extern struct buffer helpwin;132 extern int help_lines, help_cols;134 extern struct buffer downloadwin;135 extern int download_lines;136 extern int download_cols;138 void get_scroll_position(struct tab *, size_t *, size_t *);139 void save_excursion(struct excursion *, struct buffer *);140 void restore_excursion(struct excursion *, struct buffer *);141 void global_key_unbound(void);142 struct buffer *current_buffer(void);143 struct vline *adjust_line(struct vline *, struct buffer *);144 void start_loading_anim(struct tab *);146 int ui_print_colors(void);147 int ui_init(void);148 void ui_main_loop(void);149 void ui_on_tab_loaded(struct tab *);150 void ui_on_tab_refresh(struct tab *);151 void ui_on_download_refresh(void);152 const char *ui_keyname(int);153 void ui_toggle_side_window(int);154 void ui_show_downloads_pane(void);155 void ui_schedule_redraw(void);156 void ui_after_message_hook(void);157 void ui_require_input(struct tab *, int, int);158 void ui_yornp(const char *, void (*)(int, struct tab *), struct tab *);159 void ui_read(const char *, void (*)(const char *, struct tab *), struct tab *, const char *);160 void ui_other_window(void);161 void ui_suspend(void);162 void ui_end(void);164 #endif