commit 6ab857d5a87585ace35a923121550f178f74a46d from: Omar Polo date: Tue Jan 23 20:06:06 2024 UTC move includes back to the root directory Splitting stuff into sub-directories was just a big mistake. commit - 65c4966563d067115fc09f5e5c8c43a917b1cf03 commit + 6ab857d5a87585ace35a923121550f178f74a46d blob - 914fabd10021b1b34ec015a7b0dc1d132efa87db blob + 447a94d25a0d8a43b3f440d1ff67b0c8a3f1db5d --- Makefile.am +++ Makefile.am @@ -6,39 +6,34 @@ EXTRA_telescope_SOURCES = compat/ohash.h compat/queue. telescope_SOURCES = cmd.c \ cmd.gen.c \ + cmd.h \ + compat.h \ compl.c \ + compl.h \ control.c \ + control.h \ defaults.c \ + defaults.h \ downloads.c \ fs.c \ + fs.h \ gencmd.awk \ help.c \ hist.c \ - include/cmd.h \ - include/compat.h \ - include/compl.h \ - include/control.h \ - include/defaults.h \ - include/fs.h \ - include/keymap.h \ - include/mcache.h \ - include/minibuffer.h \ - include/pages.h \ - include/parser.h \ - include/session.h \ - include/telescope.h \ - include/ui.h \ - include/utf8.h \ - include/utils.h \ iri.c \ iri.h \ keymap.c \ + keymap.h \ mcache.c \ + mcache.h \ mime.c \ minibuffer.c \ + minibuffer.h \ net.c \ pages.c \ + pages.h \ parse.y \ + parser.h \ parser/parser.c \ parser/parser_gemtext.c \ parser/parser_gophermap.c \ @@ -46,14 +41,19 @@ telescope_SOURCES = cmd.c \ parser/parser_textplain.c \ sandbox.c \ session.c \ + session.h \ telescope.c \ + telescope.h \ tofu.c \ u/emoji-matcher.c \ u/genemoji.sh \ u/utf8.c \ u/wrap.c \ ui.c \ - utils.c + ui.h \ + utf8.h \ + utils.c \ + utils.h noinst_PROGRAMS = pagebundler pagebundler_SOURCES = pagebundler.c @@ -74,7 +74,7 @@ BUILT_SOURCES = cmd.gen.c u/emoji-matcher.c pages.c CLEANFILES = cmd.gen.c u/emoji-matcher.c pages.c \ parse.c -AM_CPPFLAGS = -I$(top_srcdir)/phos -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/phos LDADD = $(LIBOBJS) $(LIBGRAPHEME) EXTRA_telescope_DEPENDENCIES = $(LIBGRAPHEME) @@ -82,8 +82,8 @@ EXTRA_DIST = ChangeLog LICENSE README.md data/emoji.t dist_man1_MANS = telescope.1 -cmd.gen.c: $(srcdir)/include/cmd.h $(srcdir)/gencmd.awk - ${AWK} -f $(srcdir)/gencmd.awk < $(srcdir)/include/cmd.h > $@ +cmd.gen.c: $(srcdir)/cmd.h $(srcdir)/gencmd.awk + ${AWK} -f $(srcdir)/gencmd.awk < $(srcdir)/cmd.h > $@ u/emoji-matcher.c: $(srcdir)/data/emoji.txt $(srcdir)/u/genemoji.sh $(srcdir)/u/genemoji.sh $(srcdir)/data/emoji.txt > $@ @@ -94,9 +94,9 @@ PAGES = $(builddir)/pages/about_about.gmi \ $(builddir)/pages/about_help.gmi \ $(builddir)/pages/about_license.gmi \ $(builddir)/pages/about_new.gmi -pages.c: pagebundler $(srcdir)/include/pages.h ${PAGES} +pages.c: pagebundler $(srcdir)/pages.h ${PAGES} echo > $@ - echo "#include \"include/pages.h\"" >> $@ + echo "#include \"pages.h\"" >> $@ ./pagebundler $(builddir)/pages/about_about.gmi >> $@ ./pagebundler $(builddir)/pages/about_blank.gmi >> $@ ./pagebundler $(builddir)/pages/about_crash.gmi >> $@ blob - /dev/null blob + 9c1c5b40b82b072c84b713e30fa10a65b0807987 (mode 644) --- /dev/null +++ cmd.h @@ -0,0 +1,85 @@ +struct buffer; + +#define CMD(fnname, descr) void fnname(struct buffer *) +#define DEFALIAS(s, d) /* nothing */ + +DEFALIAS(q, cmd_kill_telescope) +DEFALIAS(w, cmd_write_buffer) +DEFALIAS(tabn, cmd_tab_next) +DEFALIAS(tabnew, cmd_tab_new) +DEFALIAS(tabp, cmd_tab_previous) +DEFALIAS(wq, cmd_kill_telescope) +DEFALIAS(open, cmd_load_url) + +CMD(cmd_backward_char, "Move point one character backward."); +CMD(cmd_backward_paragraph, "Move point on paragraph backward."); +CMD(cmd_beginning_of_buffer, "Move point to the beginning of the buffer."); +CMD(cmd_bookmark_page, "Save a page in the bookmark file."); +CMD(cmd_cache_info, "Show cache stats."); +CMD(cmd_clear_minibuf, "Clear the echo area."); +CMD(cmd_dec_fill_column, "Decrement fill-column by two."); +CMD(cmd_end_of_buffer, "Move the point to the end of the buffer."); +CMD(cmd_execute_extended_command, "Execute an internal command."); +CMD(cmd_forward_char, "Move point one character forward."); +CMD(cmd_forward_paragraph, "Move point one paragraph forward."); +CMD(cmd_home, "Go to the home directory."); +CMD(cmd_inc_fill_column, "Increment fill-column by two"); +CMD(cmd_insert_current_candidate, "Copy the current selection text as minibuffer input."); +CMD(cmd_kill_telescope, "Quit Telescope."); +CMD(cmd_link_select, "Select and visit a link using the minibuffer."); +CMD(cmd_list_bookmarks, "Load the bookmarks page."); +CMD(cmd_load_current_url, "Edit the current URL."); +CMD(cmd_load_url, "Prompt for an URL."); +CMD(cmd_mini_abort, "Abort the current minibuffer action."); +CMD(cmd_mini_complete_and_exit, "Complete the current minibuffer action."); +CMD(cmd_mini_delete_backward_char, "Delete the character before the point."); +CMD(cmd_mini_delete_char, "Delete the character after the point."); +CMD(cmd_mini_goto_beginning, "Select the first completion."); +CMD(cmd_mini_goto_end, "Select the last completion."); +CMD(cmd_mini_kill_line, "Delete from point until the end of the line."); +CMD(cmd_mini_kill_whole_line, "Delete the whole line."); +CMD(cmd_mini_next_history_element, "Load the next history element."); +CMD(cmd_mini_previous_history_element, "Load the previous history element."); +CMD(cmd_mini_scroll_down, "Scroll completions up by one visual page"); +CMD(cmd_mini_scroll_up, "Scroll completions up by one visual page"); +CMD(cmd_move_beginning_of_line, "Move point at the beginning of the current visual line."); +CMD(cmd_move_end_of_line, "Move point at the end of the current visual line."); +CMD(cmd_next_button, "Move point to the next link."); +CMD(cmd_next_completion, "Select the next completion."); +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."); +CMD(cmd_previous_line, "Move point to the previous visual line."); +CMD(cmd_previous_page, "Go backward in the page history."); +CMD(cmd_push_button, "Follow link at point or toggle pre-visibility."); +CMD(cmd_push_button_new_tab, "Follow link at point in a new tab.n"); +CMD(cmd_redraw, "Redraw the screen."); +CMD(cmd_reload_page, "Reload the current page."); +CMD(cmd_reply_last_input, "Reply last input request."); +CMD(cmd_root, "Go to the root directory."); +CMD(cmd_scroll_down, "Scroll down by one visual page"); +CMD(cmd_scroll_line_down, "Scroll down by one line"); +CMD(cmd_scroll_line_up, "Scroll up by one line."); +CMD(cmd_scroll_up, "Scroll up by one visual page"); +CMD(cmd_suspend_telescope, "Suspend the current Telescope session."); +CMD(cmd_swiper, "Jump to a line using the minibuffer."); +CMD(cmd_tab_close, "Close the current tab."); +CMD(cmd_tab_close_other, "Close all tabs but the current one."); +CMD(cmd_tab_move, "Move the current tab to the right."); +CMD(cmd_tab_move_to, "Move the current tab to the left."); +CMD(cmd_tab_new, "Open a new tab."); +CMD(cmd_tab_next, "Focus next tab."); +CMD(cmd_tab_previous, "Focus previous tab."); +CMD(cmd_tab_select, "Switch to a tab using the minibuffer."); +CMD(cmd_tab_undo_close, "Reopen last closed tab."); +CMD(cmd_toc, "Jump to a heading using the minibuffer."); +CMD(cmd_toggle_downloads, "Toggle the downloads side window."); +CMD(cmd_toggle_help, "Toggle side window with help."); +CMD(cmd_toggle_pre_wrap, "Toggle the wrapping of preformatted blocks."); +CMD(cmd_up, "Go up one level."); +CMD(cmd_write_buffer, "Save the current page to the disk."); blob - /dev/null blob + 2d2216f7e204c10465ec1431d32f3643fe82713d (mode 644) --- /dev/null +++ compat.h @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef COMPAT_H +#define COMPAT_H + +#include "config.h" + +#include +#include + +#include +#include +#include + +#if HAVE_ENDIAN_H +# include +#elif HAVE_SYS_ENDIAN_H +# include +#elif HAVE_LIBKERN_OSBYTEORDER_H +# include +# include + +# define htobe16(x) OSSwapHostToBigInt16(x) +# define htole16(x) OSSwapHostToLittleInt16(x) +# define be16toh(x) OSSwapBigToHostInt16(x) +# define le16toh(x) OSSwapLittleToHostInt16(x) + +# define htobe32(x) OSSwapHostToBigInt32(x) +# define htole32(x) OSSwapHostToLittleInt32(x) +# define be32toh(x) OSSwapBigToHostInt32(x) +# define le32toh(x) OSSwapLittleToHostInt32(x) + +# define htobe64(x) OSSwapHostToBigInt64(x) +# define htole64(x) OSSwapHostToLittleInt64(x) +# define be64toh(x) OSSwapBigToHostInt64(x) +# define le64toh(x) OSSwapLittleToHostInt64(x) +#else +# error no compatible endian.h header found +#endif + +#if HAVE_EVENT2 +# include +# include +# include +# include +# include +# include +# include +# include +#else +# include +#endif + +#ifdef HAVE_QUEUE_H +# include +#else +# include "compat/queue.h" +#endif + +#ifdef HAVE_IMSG +# include +#else +# include "compat/imsg.h" +#endif + +#ifdef HAVE_LIBUTIL +# include +# include +#else +# include "compat/ohash.h" +# define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */ +int scan_scaled(char *, long long *); +int fmt_scaled(long long, char *); +#endif + +#ifndef HAVE_ASPRINTF +int asprintf(char**, const char*, ...); +int vasprintf(char**, const char*, va_list); +#endif + +#ifndef HAVE_ERR +void err(int, const char*, ...); +void errx(int, const char*, ...); +void warn(int, const char*, ...); +void warnx(int, const char*, ...); +#else +# include +#endif + +#ifndef HAVE_EXPLICIT_BZERO +void explicit_bzero(void *, size_t); +#endif + +#ifndef HAVE_FREEZERO +void freezero(void*, size_t); +#endif + +#ifndef HAVE_GETDTABLECOUNT +int getdtablecount(void); +#endif + +#ifndef HAVE_GETDTABLESIZE +int getdtablesize(void); +#endif + +#ifndef HAVE_GETPROGNAME +const char *getprogname(void); +#endif + +#ifndef HAVE_MEMMEM +void *memmem(const void*, size_t, const void*, size_t); +#endif + +#ifndef HAVE_RECALLOCARRAY +void *recallocarray(void*, size_t, size_t, size_t); +#endif + +#ifndef HAVE_STRCASESTR +char *strcasestr(const char *, const char *); +#endif + +#ifndef HAVE_STRLCPY +size_t strlcpy(char*, const char*, size_t); +#endif + +#ifndef HAVE_STRLCAT +size_t strlcat(char*, const char*, size_t); +#endif + +#ifndef HAVE_STRSEP +char *strsep(char**, const char*); +#endif + +#ifndef HAVE_STRTONUM +long long strtonum(const char*, long long, long long, const char**); +#endif + +#ifndef HAVE_SETPROCTITLE +void setproctitle(const char*, ...); +#endif + +#endif /* COMPAT_H */ blob - /dev/null blob + c2d3ddef9936e81d473da6e75de86d4af340c7e3 (mode 644) --- /dev/null +++ compl.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef COMPL_H +#define COMPL_H + +const char *compl_lu(void **, void **, const char **); +const char *compl_eecmd(void **, void **, const char **); +const char *compl_ts(void **, void **, const char **); +const char *compl_ls(void **, void **, const char **); +const char *compl_swiper(void **, void **, const char **); +const char *compl_toc(void **, void **, const char **); + +#endif blob - /dev/null blob + c779aaeb95cf5546bf933fe861acf75b7474d386 (mode 644) --- /dev/null +++ control.h @@ -0,0 +1,24 @@ +/* $OpenBSD: control.h,v 1.1 2021/02/26 16:16:37 florian Exp $ */ + +/* + * Copyright (c) 2003, 2004 Henning Brauer + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef SMALL +int control_init(char *); +int control_listen(int); +void control_accept(int, short, void *); +void control_dispatch_imsg(int, short, void *); +#endif /* SMALL */ blob - /dev/null blob + 2a9d1be7b0c7a7f2c3038fe66a2255b334104d45 (mode 644) --- /dev/null +++ defaults.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2021, 2024 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef DEFAULTS_H +#define DEFAULTS_H + +extern char *default_protocol; +extern char *download_path; +extern char *new_tab_url; + +extern int autosave; +extern int dont_wrap_pre; +extern int emojify_link; +extern int enable_colors; +extern int fill_column; +extern int fringe_ignore_offset; +extern int hide_pre_blocks; +extern int hide_pre_closing_line; +extern int hide_pre_context; +extern int load_url_use_heuristic; +extern int max_killed_tabs; +extern int olivetti_mode; +extern int set_title; +extern int tab_bar_show; + +extern struct vline fringe; + +struct lineprefix { + const char *prfx1; + const char *prfx2; +}; +extern struct lineprefix line_prefixes[]; + +struct line_face { + int prfx_pair, pair, trail_pair; + int prfx_bg, bg, trail_bg; + int prfx_fg, fg, trail_fg; + int prfx_attr, attr, trail_attr; + + int prefix, text, trail; +}; +extern struct line_face line_faces[]; + +struct tab_face { + int bg_attr, bg_bg, bg_fg; + int t_attr, t_bg, t_fg; + int c_attr, c_bg, c_fg; + + int background, tab, current; +}; +extern struct tab_face tab_face; + +struct body_face { + int lbg, lfg; + int bg, fg; + int rbg, rfg; + + int left, body, right; +}; +extern struct body_face body_face; + +struct download_face { + int bg, fg, attr; + int background; +}; +extern struct download_face download_face; + +struct modeline_face { + int bg, fg, attr; + int background; +}; +extern struct modeline_face modeline_face; + +struct minibuffer_face { + int bg, fg, attr; + int background; +}; +extern struct minibuffer_face minibuffer_face; + +void config_init(void); +int config_setprfx(const char *, const char *, const char *); +int config_setvari(const char *, int); +int config_setvars(const char *, char *); +int config_setvarb(const char *, int); +int config_setcolor(int, const char *, int, int, int); +int config_setattr(const char *, int, int, int); +void config_apply_style(void); + +#endif blob - 9c1c5b40b82b072c84b713e30fa10a65b0807987 (mode 644) blob + /dev/null --- include/cmd.h +++ /dev/null @@ -1,85 +0,0 @@ -struct buffer; - -#define CMD(fnname, descr) void fnname(struct buffer *) -#define DEFALIAS(s, d) /* nothing */ - -DEFALIAS(q, cmd_kill_telescope) -DEFALIAS(w, cmd_write_buffer) -DEFALIAS(tabn, cmd_tab_next) -DEFALIAS(tabnew, cmd_tab_new) -DEFALIAS(tabp, cmd_tab_previous) -DEFALIAS(wq, cmd_kill_telescope) -DEFALIAS(open, cmd_load_url) - -CMD(cmd_backward_char, "Move point one character backward."); -CMD(cmd_backward_paragraph, "Move point on paragraph backward."); -CMD(cmd_beginning_of_buffer, "Move point to the beginning of the buffer."); -CMD(cmd_bookmark_page, "Save a page in the bookmark file."); -CMD(cmd_cache_info, "Show cache stats."); -CMD(cmd_clear_minibuf, "Clear the echo area."); -CMD(cmd_dec_fill_column, "Decrement fill-column by two."); -CMD(cmd_end_of_buffer, "Move the point to the end of the buffer."); -CMD(cmd_execute_extended_command, "Execute an internal command."); -CMD(cmd_forward_char, "Move point one character forward."); -CMD(cmd_forward_paragraph, "Move point one paragraph forward."); -CMD(cmd_home, "Go to the home directory."); -CMD(cmd_inc_fill_column, "Increment fill-column by two"); -CMD(cmd_insert_current_candidate, "Copy the current selection text as minibuffer input."); -CMD(cmd_kill_telescope, "Quit Telescope."); -CMD(cmd_link_select, "Select and visit a link using the minibuffer."); -CMD(cmd_list_bookmarks, "Load the bookmarks page."); -CMD(cmd_load_current_url, "Edit the current URL."); -CMD(cmd_load_url, "Prompt for an URL."); -CMD(cmd_mini_abort, "Abort the current minibuffer action."); -CMD(cmd_mini_complete_and_exit, "Complete the current minibuffer action."); -CMD(cmd_mini_delete_backward_char, "Delete the character before the point."); -CMD(cmd_mini_delete_char, "Delete the character after the point."); -CMD(cmd_mini_goto_beginning, "Select the first completion."); -CMD(cmd_mini_goto_end, "Select the last completion."); -CMD(cmd_mini_kill_line, "Delete from point until the end of the line."); -CMD(cmd_mini_kill_whole_line, "Delete the whole line."); -CMD(cmd_mini_next_history_element, "Load the next history element."); -CMD(cmd_mini_previous_history_element, "Load the previous history element."); -CMD(cmd_mini_scroll_down, "Scroll completions up by one visual page"); -CMD(cmd_mini_scroll_up, "Scroll completions up by one visual page"); -CMD(cmd_move_beginning_of_line, "Move point at the beginning of the current visual line."); -CMD(cmd_move_end_of_line, "Move point at the end of the current visual line."); -CMD(cmd_next_button, "Move point to the next link."); -CMD(cmd_next_completion, "Select the next completion."); -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."); -CMD(cmd_previous_line, "Move point to the previous visual line."); -CMD(cmd_previous_page, "Go backward in the page history."); -CMD(cmd_push_button, "Follow link at point or toggle pre-visibility."); -CMD(cmd_push_button_new_tab, "Follow link at point in a new tab.n"); -CMD(cmd_redraw, "Redraw the screen."); -CMD(cmd_reload_page, "Reload the current page."); -CMD(cmd_reply_last_input, "Reply last input request."); -CMD(cmd_root, "Go to the root directory."); -CMD(cmd_scroll_down, "Scroll down by one visual page"); -CMD(cmd_scroll_line_down, "Scroll down by one line"); -CMD(cmd_scroll_line_up, "Scroll up by one line."); -CMD(cmd_scroll_up, "Scroll up by one visual page"); -CMD(cmd_suspend_telescope, "Suspend the current Telescope session."); -CMD(cmd_swiper, "Jump to a line using the minibuffer."); -CMD(cmd_tab_close, "Close the current tab."); -CMD(cmd_tab_close_other, "Close all tabs but the current one."); -CMD(cmd_tab_move, "Move the current tab to the right."); -CMD(cmd_tab_move_to, "Move the current tab to the left."); -CMD(cmd_tab_new, "Open a new tab."); -CMD(cmd_tab_next, "Focus next tab."); -CMD(cmd_tab_previous, "Focus previous tab."); -CMD(cmd_tab_select, "Switch to a tab using the minibuffer."); -CMD(cmd_tab_undo_close, "Reopen last closed tab."); -CMD(cmd_toc, "Jump to a heading using the minibuffer."); -CMD(cmd_toggle_downloads, "Toggle the downloads side window."); -CMD(cmd_toggle_help, "Toggle side window with help."); -CMD(cmd_toggle_pre_wrap, "Toggle the wrapping of preformatted blocks."); -CMD(cmd_up, "Go up one level."); -CMD(cmd_write_buffer, "Save the current page to the disk."); blob - 2d2216f7e204c10465ec1431d32f3643fe82713d (mode 644) blob + /dev/null --- include/compat.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef COMPAT_H -#define COMPAT_H - -#include "config.h" - -#include -#include - -#include -#include -#include - -#if HAVE_ENDIAN_H -# include -#elif HAVE_SYS_ENDIAN_H -# include -#elif HAVE_LIBKERN_OSBYTEORDER_H -# include -# include - -# define htobe16(x) OSSwapHostToBigInt16(x) -# define htole16(x) OSSwapHostToLittleInt16(x) -# define be16toh(x) OSSwapBigToHostInt16(x) -# define le16toh(x) OSSwapLittleToHostInt16(x) - -# define htobe32(x) OSSwapHostToBigInt32(x) -# define htole32(x) OSSwapHostToLittleInt32(x) -# define be32toh(x) OSSwapBigToHostInt32(x) -# define le32toh(x) OSSwapLittleToHostInt32(x) - -# define htobe64(x) OSSwapHostToBigInt64(x) -# define htole64(x) OSSwapHostToLittleInt64(x) -# define be64toh(x) OSSwapBigToHostInt64(x) -# define le64toh(x) OSSwapLittleToHostInt64(x) -#else -# error no compatible endian.h header found -#endif - -#if HAVE_EVENT2 -# include -# include -# include -# include -# include -# include -# include -# include -#else -# include -#endif - -#ifdef HAVE_QUEUE_H -# include -#else -# include "compat/queue.h" -#endif - -#ifdef HAVE_IMSG -# include -#else -# include "compat/imsg.h" -#endif - -#ifdef HAVE_LIBUTIL -# include -# include -#else -# include "compat/ohash.h" -# define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */ -int scan_scaled(char *, long long *); -int fmt_scaled(long long, char *); -#endif - -#ifndef HAVE_ASPRINTF -int asprintf(char**, const char*, ...); -int vasprintf(char**, const char*, va_list); -#endif - -#ifndef HAVE_ERR -void err(int, const char*, ...); -void errx(int, const char*, ...); -void warn(int, const char*, ...); -void warnx(int, const char*, ...); -#else -# include -#endif - -#ifndef HAVE_EXPLICIT_BZERO -void explicit_bzero(void *, size_t); -#endif - -#ifndef HAVE_FREEZERO -void freezero(void*, size_t); -#endif - -#ifndef HAVE_GETDTABLECOUNT -int getdtablecount(void); -#endif - -#ifndef HAVE_GETDTABLESIZE -int getdtablesize(void); -#endif - -#ifndef HAVE_GETPROGNAME -const char *getprogname(void); -#endif - -#ifndef HAVE_MEMMEM -void *memmem(const void*, size_t, const void*, size_t); -#endif - -#ifndef HAVE_RECALLOCARRAY -void *recallocarray(void*, size_t, size_t, size_t); -#endif - -#ifndef HAVE_STRCASESTR -char *strcasestr(const char *, const char *); -#endif - -#ifndef HAVE_STRLCPY -size_t strlcpy(char*, const char*, size_t); -#endif - -#ifndef HAVE_STRLCAT -size_t strlcat(char*, const char*, size_t); -#endif - -#ifndef HAVE_STRSEP -char *strsep(char**, const char*); -#endif - -#ifndef HAVE_STRTONUM -long long strtonum(const char*, long long, long long, const char**); -#endif - -#ifndef HAVE_SETPROCTITLE -void setproctitle(const char*, ...); -#endif - -#endif /* COMPAT_H */ blob - c2d3ddef9936e81d473da6e75de86d4af340c7e3 (mode 644) blob + /dev/null --- include/compl.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef COMPL_H -#define COMPL_H - -const char *compl_lu(void **, void **, const char **); -const char *compl_eecmd(void **, void **, const char **); -const char *compl_ts(void **, void **, const char **); -const char *compl_ls(void **, void **, const char **); -const char *compl_swiper(void **, void **, const char **); -const char *compl_toc(void **, void **, const char **); - -#endif blob - c779aaeb95cf5546bf933fe861acf75b7474d386 (mode 644) blob + /dev/null --- include/control.h +++ /dev/null @@ -1,24 +0,0 @@ -/* $OpenBSD: control.h,v 1.1 2021/02/26 16:16:37 florian Exp $ */ - -/* - * Copyright (c) 2003, 2004 Henning Brauer - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef SMALL -int control_init(char *); -int control_listen(int); -void control_accept(int, short, void *); -void control_dispatch_imsg(int, short, void *); -#endif /* SMALL */ blob - 2a9d1be7b0c7a7f2c3038fe66a2255b334104d45 (mode 644) blob + /dev/null --- include/defaults.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2021, 2024 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef DEFAULTS_H -#define DEFAULTS_H - -extern char *default_protocol; -extern char *download_path; -extern char *new_tab_url; - -extern int autosave; -extern int dont_wrap_pre; -extern int emojify_link; -extern int enable_colors; -extern int fill_column; -extern int fringe_ignore_offset; -extern int hide_pre_blocks; -extern int hide_pre_closing_line; -extern int hide_pre_context; -extern int load_url_use_heuristic; -extern int max_killed_tabs; -extern int olivetti_mode; -extern int set_title; -extern int tab_bar_show; - -extern struct vline fringe; - -struct lineprefix { - const char *prfx1; - const char *prfx2; -}; -extern struct lineprefix line_prefixes[]; - -struct line_face { - int prfx_pair, pair, trail_pair; - int prfx_bg, bg, trail_bg; - int prfx_fg, fg, trail_fg; - int prfx_attr, attr, trail_attr; - - int prefix, text, trail; -}; -extern struct line_face line_faces[]; - -struct tab_face { - int bg_attr, bg_bg, bg_fg; - int t_attr, t_bg, t_fg; - int c_attr, c_bg, c_fg; - - int background, tab, current; -}; -extern struct tab_face tab_face; - -struct body_face { - int lbg, lfg; - int bg, fg; - int rbg, rfg; - - int left, body, right; -}; -extern struct body_face body_face; - -struct download_face { - int bg, fg, attr; - int background; -}; -extern struct download_face download_face; - -struct modeline_face { - int bg, fg, attr; - int background; -}; -extern struct modeline_face modeline_face; - -struct minibuffer_face { - int bg, fg, attr; - int background; -}; -extern struct minibuffer_face minibuffer_face; - -void config_init(void); -int config_setprfx(const char *, const char *, const char *); -int config_setvari(const char *, int); -int config_setvars(const char *, char *); -int config_setvarb(const char *, int); -int config_setcolor(int, const char *, int, int, int); -int config_setattr(const char *, int, int, int); -void config_apply_style(void); - -#endif blob - c18c4d95757e523512b6cf129160fa9189ceb0cb (mode 644) blob + /dev/null --- include/fs.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021, 2022 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef FS_H -#define FS_H - -struct tab; -struct tofu_entry; - -extern char config_path_base[PATH_MAX]; -extern char data_path_base[PATH_MAX]; -extern char cache_path_base[PATH_MAX]; - -extern char ctlsock_path[PATH_MAX]; -extern char config_path[PATH_MAX]; -extern char lockfile_path[PATH_MAX]; -extern char bookmark_file[PATH_MAX]; -extern char known_hosts_file[PATH_MAX], known_hosts_tmp[PATH_MAX]; -extern char crashed_file[PATH_MAX]; -extern char session_file[PATH_MAX], session_file_tmp[PATH_MAX]; -extern char history_file[PATH_MAX], history_file_tmp[PATH_MAX]; - -extern char cwd[PATH_MAX]; - -int fs_init(void); -void fs_load_url(struct tab *, const char *); - -#endif blob - 3b1ca4e8c8e72b9764f5845bffdefefd794966b8 (mode 644) blob + /dev/null --- include/keymap.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef KEYMAP_H -#define KEYMAP_H - -#include "compat.h" - -#include - -struct buffer; - -struct kmap { - TAILQ_HEAD(map, keymap) m; - void (*unhandled_input)(void); -}; -extern struct kmap global_map, minibuffer_map; - -typedef void(interactivefn)(struct buffer *); - -struct keymap { - int meta; - int key; - struct kmap map; - interactivefn *fn; - - TAILQ_ENTRY(keymap) keymaps; -}; - -struct thiskey { - short meta; - int key; - uint32_t cp; -}; - -enum { - LK_ADVANCED_MAP, - LK_MATCHED, - LK_UNBOUND, -}; - -int kbd(const char *); -const char *unkbd(int); -int kmap_define_key(struct kmap *, const char *, interactivefn *); -int lookup_key(struct kmap **, struct thiskey *, struct buffer *); - -#endif blob - e4bb1a34d16bf0c72cdd5c0ae6ff1cd3e89fa783 (mode 644) blob + /dev/null --- include/mcache.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MCACHE_H -#define MCACHE_H - -struct tab; - -void mcache_init(void); -int mcache_tab(struct tab *); -int mcache_lookup(const char *, struct tab *); -void mcache_info(size_t *, size_t *); - -#endif blob - d993896dd79343bae46a2ba6dc48362c4b802c8a (mode 644) blob + /dev/null --- include/minibuffer.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MINIBUFFER_H -#define MINIBUFFER_H - -#include "telescope.h" - -/* need to be true-ish */ -#define MB_READ 1 -#define MB_COMPREAD 2 - -/* - * Completion provider function. These functions are called - * asynchronously. The function should compute the next completion - * using the given parameter `state' and modify it eventually. To - * signal the end of the completions, complfn should return NULL: the - * value of state will then be discarded and the function never called - * again. The second parameter is some extra metadata per-line; it'll - * be available as line->data on the selected line during the - * minibuffer lifecycle. The third parameter is an extra description - * field for the current item. - */ -typedef const char *(complfn)(void **, void **, const char **); - -struct hist; -extern struct hist *eecmd_history; -extern struct hist *ir_history; -extern struct hist *lu_history; -extern struct hist *read_history; - -struct ministate { - char *curmesg; - - char prompt[64]; - void (*donefn)(void); - void (*abortfn)(void); - - char buf[1025]; - struct line line; - struct vline vline; - struct buffer buffer; - - struct hist *hist; - int editing; - - struct { - struct buffer buffer; - complfn *fn; - void *data; - int must_select; - } compl; -}; -extern struct ministate ministate; - -extern struct buffer minibufferwin; -extern int in_minibuffer; - -void recompute_completions(int); -int minibuffer_insert_current_candidate(void); -void minibuffer_taint_hist(void); -void minibuffer_self_insert(void); -void sensible_self_insert(void); -void eecmd_select(void); -void ir_select_gemini(void); -void ir_select_reply(void); -void ir_select_gopher(void); -void lu_select(void); -void bp_select(void); -void ts_select(void); -void ls_select(void); -void swiper_select(void); -void toc_select(void); - -void enter_minibuffer(void(*)(void), void(*)(void), void(*)(void), - struct hist *, complfn *, void *, int); - -void exit_minibuffer(void); -void yornp(const char *, void (*)(int, struct tab *), struct tab *); - -/* - * minibuffer_read asks the user for something using the minibuffer. - * The first argument is the string prompt. The second and third are - * the callback to call when done and the data; the callback function - * can't be NULL. - */ -void minibuffer_read(const char *, - void (*)(const char *, struct tab *), struct tab *); - -void vmessage(const char *, va_list); -void message(const char *, ...) __attribute__((format(printf, 1, 2))); -void minibuffer_init(void); - -#endif blob - 93fd09804c8dc8c83fd775626dbc9a2de14f997d (mode 644) blob + /dev/null --- include/pages.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef PAGES_H -#define PAGES_H - -#include -#include - -extern const uint8_t about_about[]; -extern size_t about_about_len; - -extern const uint8_t about_blank[]; -extern size_t about_blank_len; - -extern const uint8_t about_crash[]; -extern size_t about_crash_len; - -extern const uint8_t about_help[]; -extern size_t about_help_len; - -extern const uint8_t about_license[]; -extern size_t about_license_len; - -extern const uint8_t about_new[]; -extern size_t about_new_len; - -extern const uint8_t bookmarks[]; -extern size_t bookmarks_len; - -#endif blob - 7dcf584964c0faeedfd4bcc0337a56535601d897 (mode 644) blob + /dev/null --- include/parser.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef PARSER_H -#define PARSER_H - -#include "telescope.h" - -typedef void (*parserfn)(struct parser *); - -void parser_init(struct tab *, parserfn); -int parser_parse(struct tab *, const char *, size_t); -int parser_parsef(struct tab *, const char *, ...); -int parser_free(struct tab *); -int parser_serialize(struct tab *, FILE *); - -int parser_append(struct parser*, const char*, size_t); -int parser_set_buf(struct parser*, const char*, size_t); -int parser_foreach_line(struct parser*, const char*, size_t, parsechunkfn); - -/* parser_gemtext.c */ -void gemtext_initparser(struct parser*); - -/* parser_gophermap.c */ -void gophermap_initparser(struct parser *); - -/* parser_textpatch.c */ -void textpatch_initparser(struct parser *); - -/* parser_textplain.c */ -void textplain_initparser(struct parser*); - -#endif blob - bf1ec4d751e38ebc8a2188849d6202fd717c1a79 (mode 644) blob + /dev/null --- include/session.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef SESSION_H -#define SESSION_H - -struct ohash; - -struct session_tab { - uint32_t flags; - char uri[GEMINI_URL_LEN]; - char title[TITLE_MAX]; - size_t top_line; - size_t current_line; -}; - -struct session_tab_hist { - char uri[GEMINI_URL_LEN]; - int future; -}; - -struct histitem { - time_t ts; - char uri[GEMINI_URL_LEN]; -}; - -struct history_item { - time_t ts; - char *uri; - int dirty; -}; - -#define HISTORY_CAP 1000 -struct history { - struct history_item items[HISTORY_CAP]; - size_t len; - size_t dirty; - size_t extra; -}; -extern struct history history; - -void switch_to_tab(struct tab *); -unsigned int tab_new_id(void); -struct tab *new_tab(const char *, const char *base, struct tab *); -void kill_tab(struct tab *, int); -struct tab *unkill_tab(void); -void free_tab(struct tab *); -void stop_tab(struct tab*); - -void save_session(void); - -void history_push(struct histitem *); -void history_sort(void); -void history_add(const char *); - -void autosave_init(void); -void autosave_timer(int, short, void *); -void autosave_hook(void); - -int load_session(struct ohash *); -int lock_session(void); - -#endif blob - acb3a2423988a8d005fdc3feb99dc4e6348683c0 (mode 644) blob + /dev/null --- include/telescope.h +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef TELESCOPE_H -#define TELESCOPE_H - -#include "compat.h" - -#include -#include /* XXX: for parsers.h */ - -#include "cmd.h" -#include "iri.h" - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -#define GEMINI_URL_LEN 1024 -#define TITLE_MAX 128+1 /* account for NUL too */ - -#define SIDE_WINDOW_LEFT 0x1 -#define SIDE_WINDOW_BOTTOM 0x2 - -struct imsgev { - struct imsgbuf ibuf; - void (*handler)(int, short, void *); - struct event ev; - short events; -}; - -#define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE) - -enum imsg_type { - /* ui <-> net */ - IMSG_GET, /* struct get_req, peerid is the tab id */ - IMSG_ERR, - IMSG_CHECK_CERT, - IMSG_CERT_STATUS, - IMSG_GOT_CODE, - IMSG_GOT_META, - IMSG_PROCEED, - IMSG_STOP, - IMSG_BUF, - IMSG_EOF, - IMSG_QUIT, - - /* ui <-> ctl */ - IMSG_CTL_OPEN_URL, -}; - -enum line_type { - /* text/gemini */ - LINE_TEXT, - LINE_LINK, - LINE_TITLE_1, - LINE_TITLE_2, - LINE_TITLE_3, - LINE_ITEM, - LINE_QUOTE, - LINE_PRE_START, - LINE_PRE_CONTENT, - LINE_PRE_END, - - /* text/x-patch */ - LINE_PATCH, - LINE_PATCH_HDR, - LINE_PATCH_HUNK_HDR, - LINE_PATCH_ADD, - LINE_PATCH_DEL, - - /* minibuffer */ - LINE_COMPL, - LINE_COMPL_CURRENT, - - /* help */ - LINE_HELP, - - /* download */ - LINE_DOWNLOAD, - LINE_DOWNLOAD_DONE, - LINE_DOWNLOAD_INFO, - - /* misc ui */ - LINE_FRINGE, -}; - -struct line { - enum line_type type; - char *line; - char *alt; - void *data; - -#define L_HIDDEN 0x1 - int flags; - TAILQ_ENTRY(line) lines; -}; - -struct vline { - struct line *parent; - size_t from; - size_t len; - size_t cplen; - -#define L_CONTINUATION 0x2 - int flags; - TAILQ_ENTRY(vline) vlines; -}; - -struct parser; - -typedef int (*printfn)(void *, const char *, ...); - -typedef void (*parserinit)(struct parser *); - -typedef int (*parsechunkfn)(struct parser *, const char *, size_t); -typedef int (*parserfreefn)(struct parser *); -typedef int (*parserserial)(struct parser *, FILE *); - -typedef void (imsg_handlerfn)(struct imsg*, size_t); - -struct parser { - const char *name; - char title[128+1]; - char *buf; - size_t len; - size_t cap; - -#define PARSER_IN_BODY 1 -#define PARSER_IN_PRE 2 -#define PARSER_IN_PATCH_HDR 4 - int flags; - parserinit init; - parsechunkfn parse; - parserfreefn free; - parserserial serialize; - - TAILQ_HEAD(, line) head; -}; - -/* - * differnt types of trust for a certificate. Following - * gemini://thfr.info/gemini/modified-trust-verify.gmi - */ -enum trust_state { - TS_UNKNOWN, - TS_UNTRUSTED, - TS_TEMP_TRUSTED, - TS_TRUSTED, - TS_VERIFIED, -}; - -struct tofu_entry { - char domain[GEMINI_URL_LEN]; - - /* - * enough space for ``PROTO:HASH''. probably isn't a good - * idea tho. - */ - char hash[128+1]; - int verified; -}; - -struct buffer { - struct parser page; - - size_t last_line_off; - int force_redraw; - - int curs_x; - int curs_y; - size_t line_off; - size_t line_max; - struct vline *top_line; - struct vline *current_line; - size_t cpoff; - TAILQ_HEAD(vhead, vline) head; -}; - -#define TAB_CURRENT 0x1 /* only for save_session */ -#define TAB_KILLED 0x2 /* only for save_session */ -#define TAB_URGENT 0x4 -#define TAB_LAZY 0x8 /* to lazy load tabs */ - -#define NEW_TAB_URL "about:new" - -struct hist; - -TAILQ_HEAD(tabshead, tab); -extern struct tabshead tabshead; -extern struct tabshead ktabshead; -struct tab { - TAILQ_ENTRY(tab) tabs; - uint32_t id; - uint32_t flags; - - char *cert; - enum trust_state trust; - struct proxy *proxy; - struct iri iri; - struct hist *hist; - char *last_input_url; - - int code; - char meta[GEMINI_URL_LEN]; - int redirect_count; - - struct buffer buffer; - - short loading_anim; - short loading_anim_step; - struct event loadingev; -}; - -extern TAILQ_HEAD(proxylist, proxy) proxies; -struct proxy { - char *match_proto; - - char *host; - char *port; - int proto; - - TAILQ_ENTRY(proxy) proxies; -}; - -enum { - PROTO_FINGER, - PROTO_GEMINI, - PROTO_GOPHER, - /* ... */ -}; - -struct get_req { - int proto; - char host[254]; - char port[16]; - char req[1027]; -}; - -struct cmd { - const char *cmd; - void (*fn)(struct buffer *); - const char *descr; -}; -extern struct cmd cmds[]; - -/* downloads.c */ -extern STAILQ_HEAD(downloads, download) downloads; -struct download { - uint32_t id; - int fd; - size_t bytes; - char *path; - STAILQ_ENTRY(download) entries; -}; - -void recompute_downloads(void); -struct download *enqueue_download(uint32_t, const char *); -struct download *download_by_id(uint32_t); - -/* help.c */ -void recompute_help(void); - -/* mime.c */ -int setup_parser_for(struct tab*); - -/* net.c */ -int net_main(void); - -/* parse.y */ -void parseconfig(const char *, int); - -/* sandbox.c */ -void sandbox_net_process(void); -void sandbox_ui_process(void); - -/* telescope.c */ -extern int operating; -extern int safe_mode; - -#define LU_MODE_NONE 0x0 -#define LU_MODE_NOHIST 0x1 -#define LU_MODE_NOCACHE 0x2 - -void gopher_send_search_req(struct tab *, const char *); -void load_page_from_str(struct tab *, const char *); -void load_url(struct tab *, const char *, const char *, int); -void load_url_in_tab(struct tab *, const char *, const char *, int); -int load_previous_page(struct tab*); -int load_next_page(struct tab*); -void write_buffer(const char *, struct tab *); -void humanify_url(const char *, const char *, char *, size_t); -int bookmark_page(const char *); -int ui_send_net(int, uint32_t, const void *, uint16_t); - -/* tofu.c */ -void tofu_init(struct ohash*, unsigned int, ptrdiff_t); -struct tofu_entry *tofu_lookup(struct ohash*, const char*, const char*); -void tofu_add(struct ohash*, struct tofu_entry*); -int tofu_save(struct ohash *, struct tofu_entry *); -void tofu_update(struct ohash*, struct tofu_entry*); -int tofu_update_persist(struct ohash *, struct tofu_entry *); -void tofu_temp_trust(struct ohash *, const char *, const char *, const char *); - -/* wrap.c */ -void erase_buffer(struct buffer *); -void empty_linelist(struct buffer*); -void empty_vlist(struct buffer*); -int wrap_text(struct buffer*, const char*, struct line*, size_t, int); -int wrap_page(struct buffer *, int width); - -#endif /* TELESCOPE_H */ blob - fcf976c7f57b6998925409975bc245eb3a05fc5b (mode 644) blob + /dev/null --- include/ui.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef UI_H -#define UI_H - -#include "keymap.h" -#include "telescope.h" - -extern int body_lines; -extern int body_cols; - -extern struct kmap global_map, minibuffer_map, *current_map, *base_map; - -struct excursion { - int curs_x, curs_y; - size_t line_off; - struct vline *current_line; - struct vline *top_line; - size_t cpoff; -}; - -enum pairs { - PTL_BG = 1, - PTL_TAB, - PTL_CURR, - - PBODY, - PBLEFT, - PBRIGHT, - - PT, - PT_PRFX, - PT_TRAIL, - PL, - PL_PRFX, - PL_TRAIL, - PT1, - PT1_PRFX, - PT1_TRAIL, - PT2, - PT2_PRFX, - PT2_TRAIL, - PT3, - PT3_PRFX, - PT3_TRAIL, - PI, - PI_PRFX, - PI_TRAIL, - PQ, - PQ_PRFX, - PQ_TRAIL, - PPSTART, - PPSTART_PRFX, - PPSTART_TRAIL, - PP, - PP_PRFX, - PP_TRAIL, - PPEND, - PPEND_PRFX, - PPEND_TRAIL, - - PPATCH, - PPATCH_PRFX, - PPATCH_TRAIL, - PPATCH_HDR, - PPATCH_HDR_PRFX, - PPATCH_HDR_TRAIL, - PPATCH_HUNK_HDR, - PPATCH_HUNK_HDR_PRFX, - PPATCH_HUNK_HDR_TRAIL, - PPATCH_ADD, - PPATCH_ADD_PRFX, - PPATCH_ADD_TRAIL, - PPATCH_DEL, - PPATCH_DEL_PRFX, - PPATCH_DEL_TRAIL, - - PCOMPL_PRFX, - PCOMPL, - PCOMPL_TRAIL, - - PCOMPL_CURR_PRFX, - PCOMPL_CURR, - PCOMPL_CURR_TRAIL, - - PHELP_PRFX, - PHELP, - PHELP_TRAIL, - - PDOWNLOAD_PRFX, - PDOWNLOAD, - PDOWNLOAD_TRAIL, - - PDOWNLOAD_DONE_PRFX, - PDOWNLOAD_DONE, - PDOWNLOAD_DONE_TRAIL, - - PDOWNLOAD_INFO_PRFX, - PDOWNLOAD_INFO, - PDOWNLOAD_INFO_TRAIL, - - PDOWNLOAD_WIN, - - PMODELINE, - - PMINIBUF, - - PFRINGE_PRFX, - PFRINGE, - PFRINGE_TRAIL, -}; - -extern struct thiskey thiskey; - -extern struct tab *current_tab; - -extern struct buffer helpwin; -extern int help_lines, help_cols; - -extern struct buffer downloadwin; -extern int download_lines; -extern int download_cols; - -void get_scroll_position(struct tab *, size_t *, size_t *); -void save_excursion(struct excursion *, struct buffer *); -void restore_excursion(struct excursion *, struct buffer *); -void global_key_unbound(void); -struct buffer *current_buffer(void); -struct vline *adjust_line(struct vline *, struct buffer *); -void start_loading_anim(struct tab *); - -int ui_print_colors(void); -int ui_init(void); -void ui_main_loop(void); -void ui_on_tab_loaded(struct tab *); -void ui_on_tab_refresh(struct tab *); -void ui_on_download_refresh(void); -void ui_remotely_open_link(const char *); -const char *ui_keyname(int); -void ui_toggle_side_window(int); -void ui_show_downloads_pane(void); -void ui_schedule_redraw(void); -void ui_after_message_hook(void); -void ui_require_input(struct tab *, int, void (*)(void)); -void ui_yornp(const char *, void (*)(int, struct tab *), struct tab *); -void ui_read(const char *, void (*)(const char *, struct tab *), struct tab *, const char *); -void ui_other_window(void); -void ui_suspend(void); -void ui_end(void); - -#endif blob - 2c6273046d618fe14d98dc139adee0409a99cf42 (mode 644) blob + /dev/null --- include/utf8.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef UTF8_H -#define UTF8_H - -#include -#include - -/* utf8.c */ -uint32_t utf8_decode(uint32_t*restrict, uint32_t*restrict, uint8_t); -size_t utf8_encode(uint32_t, char*); -char *utf8_nth(char*, size_t); -size_t utf8_cplen(char*); -size_t utf8_ncplen(const char *, size_t); -size_t utf8_chwidth(uint32_t); -size_t utf8_snwidth(const char*, size_t); -size_t utf8_swidth(const char*); -size_t utf8_swidth_between(const char*, const char*); -char *utf8_next_cp(const char*); -char *utf8_prev_cp(const char*, const char*); -int emojied_line(const char *, const char **); - -/* emoji-matcher.c */ -int is_emoji(uint32_t); - -#endif blob - 588673966051ca334bb6556f4e9054308ee8bc64 (mode 644) blob + /dev/null --- include/utils.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 Omar Polo - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef UTILS_H -#define UTILS_H - -int mark_nonblock_cloexec(int); - -int has_suffix(const char *, const char *); -int unicode_isspace(uint32_t); -int unicode_isgraph(uint32_t); - -void imsg_event_add(struct imsgev *); -int dispatch_imsg(struct imsgev *, short, imsg_handlerfn **, size_t); -int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t, int, const void *, uint16_t); - -void *hash_alloc(size_t, void *); -void *hash_calloc(size_t, size_t, void *); -void hash_free(void *, void *); - -#endif /* UTILS_H */ blob - /dev/null blob + c18c4d95757e523512b6cf129160fa9189ceb0cb (mode 644) --- /dev/null +++ fs.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021, 2022 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef FS_H +#define FS_H + +struct tab; +struct tofu_entry; + +extern char config_path_base[PATH_MAX]; +extern char data_path_base[PATH_MAX]; +extern char cache_path_base[PATH_MAX]; + +extern char ctlsock_path[PATH_MAX]; +extern char config_path[PATH_MAX]; +extern char lockfile_path[PATH_MAX]; +extern char bookmark_file[PATH_MAX]; +extern char known_hosts_file[PATH_MAX], known_hosts_tmp[PATH_MAX]; +extern char crashed_file[PATH_MAX]; +extern char session_file[PATH_MAX], session_file_tmp[PATH_MAX]; +extern char history_file[PATH_MAX], history_file_tmp[PATH_MAX]; + +extern char cwd[PATH_MAX]; + +int fs_init(void); +void fs_load_url(struct tab *, const char *); + +#endif blob - /dev/null blob + 3b1ca4e8c8e72b9764f5845bffdefefd794966b8 (mode 644) --- /dev/null +++ keymap.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef KEYMAP_H +#define KEYMAP_H + +#include "compat.h" + +#include + +struct buffer; + +struct kmap { + TAILQ_HEAD(map, keymap) m; + void (*unhandled_input)(void); +}; +extern struct kmap global_map, minibuffer_map; + +typedef void(interactivefn)(struct buffer *); + +struct keymap { + int meta; + int key; + struct kmap map; + interactivefn *fn; + + TAILQ_ENTRY(keymap) keymaps; +}; + +struct thiskey { + short meta; + int key; + uint32_t cp; +}; + +enum { + LK_ADVANCED_MAP, + LK_MATCHED, + LK_UNBOUND, +}; + +int kbd(const char *); +const char *unkbd(int); +int kmap_define_key(struct kmap *, const char *, interactivefn *); +int lookup_key(struct kmap **, struct thiskey *, struct buffer *); + +#endif blob - /dev/null blob + e4bb1a34d16bf0c72cdd5c0ae6ff1cd3e89fa783 (mode 644) --- /dev/null +++ mcache.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef MCACHE_H +#define MCACHE_H + +struct tab; + +void mcache_init(void); +int mcache_tab(struct tab *); +int mcache_lookup(const char *, struct tab *); +void mcache_info(size_t *, size_t *); + +#endif blob - /dev/null blob + d993896dd79343bae46a2ba6dc48362c4b802c8a (mode 644) --- /dev/null +++ minibuffer.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef MINIBUFFER_H +#define MINIBUFFER_H + +#include "telescope.h" + +/* need to be true-ish */ +#define MB_READ 1 +#define MB_COMPREAD 2 + +/* + * Completion provider function. These functions are called + * asynchronously. The function should compute the next completion + * using the given parameter `state' and modify it eventually. To + * signal the end of the completions, complfn should return NULL: the + * value of state will then be discarded and the function never called + * again. The second parameter is some extra metadata per-line; it'll + * be available as line->data on the selected line during the + * minibuffer lifecycle. The third parameter is an extra description + * field for the current item. + */ +typedef const char *(complfn)(void **, void **, const char **); + +struct hist; +extern struct hist *eecmd_history; +extern struct hist *ir_history; +extern struct hist *lu_history; +extern struct hist *read_history; + +struct ministate { + char *curmesg; + + char prompt[64]; + void (*donefn)(void); + void (*abortfn)(void); + + char buf[1025]; + struct line line; + struct vline vline; + struct buffer buffer; + + struct hist *hist; + int editing; + + struct { + struct buffer buffer; + complfn *fn; + void *data; + int must_select; + } compl; +}; +extern struct ministate ministate; + +extern struct buffer minibufferwin; +extern int in_minibuffer; + +void recompute_completions(int); +int minibuffer_insert_current_candidate(void); +void minibuffer_taint_hist(void); +void minibuffer_self_insert(void); +void sensible_self_insert(void); +void eecmd_select(void); +void ir_select_gemini(void); +void ir_select_reply(void); +void ir_select_gopher(void); +void lu_select(void); +void bp_select(void); +void ts_select(void); +void ls_select(void); +void swiper_select(void); +void toc_select(void); + +void enter_minibuffer(void(*)(void), void(*)(void), void(*)(void), + struct hist *, complfn *, void *, int); + +void exit_minibuffer(void); +void yornp(const char *, void (*)(int, struct tab *), struct tab *); + +/* + * minibuffer_read asks the user for something using the minibuffer. + * The first argument is the string prompt. The second and third are + * the callback to call when done and the data; the callback function + * can't be NULL. + */ +void minibuffer_read(const char *, + void (*)(const char *, struct tab *), struct tab *); + +void vmessage(const char *, va_list); +void message(const char *, ...) __attribute__((format(printf, 1, 2))); +void minibuffer_init(void); + +#endif blob - 4e0bd211862a0c6209dfa1da48a5479fcaf9af2d blob + 362319b127175d9d04d45864e11858bfda199336 --- test/Makefile.am +++ test/Makefile.am @@ -1,15 +1,15 @@ check_PROGRAMS = gmparser gmiparser iritest gmparser_SOURCES = gmparser.c \ - $(top_srcdir)/include/compat.h \ - $(top_srcdir)/include/parser.h \ + $(top_srcdir)/compat.h \ + $(top_srcdir)/parser.h \ $(top_srcdir)/parser/parser.c \ $(top_srcdir)/parser/parser_gophermap.c \ $(top_srcdir)/utils.c gmiparser_SOURCES = gmiparser.c \ - $(top_srcdir)/include/compat.h \ - $(top_srcdir)/include/parser.h \ + $(top_srcdir)/compat.h \ + $(top_srcdir)/parser.h \ $(top_srcdir)/parser/parser.c \ $(top_srcdir)/parser/parser_gemtext.c \ $(top_srcdir)/utils.c @@ -18,9 +18,9 @@ iritest_SOURCES = iritest.c \ $(top_srcdir)/iri.c \ $(top_srcdir)/iri.h -gmparser_CFLAGS = -I$(top_srcdir)/include -gmiparser_CFLAGS = -I$(top_srcdir)/include -iritest_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include +gmparser_CFLAGS = -I$(top_srcdir) +gmiparser_CFLAGS = -I$(top_srcdir) +iritest_CFLAGS = -I$(top_srcdir) EXTRA_DIST = test-gmparser \ gm-00 \ blob - /dev/null blob + 93fd09804c8dc8c83fd775626dbc9a2de14f997d (mode 644) --- /dev/null +++ pages.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef PAGES_H +#define PAGES_H + +#include +#include + +extern const uint8_t about_about[]; +extern size_t about_about_len; + +extern const uint8_t about_blank[]; +extern size_t about_blank_len; + +extern const uint8_t about_crash[]; +extern size_t about_crash_len; + +extern const uint8_t about_help[]; +extern size_t about_help_len; + +extern const uint8_t about_license[]; +extern size_t about_license_len; + +extern const uint8_t about_new[]; +extern size_t about_new_len; + +extern const uint8_t bookmarks[]; +extern size_t bookmarks_len; + +#endif blob - /dev/null blob + 7dcf584964c0faeedfd4bcc0337a56535601d897 (mode 644) --- /dev/null +++ parser.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef PARSER_H +#define PARSER_H + +#include "telescope.h" + +typedef void (*parserfn)(struct parser *); + +void parser_init(struct tab *, parserfn); +int parser_parse(struct tab *, const char *, size_t); +int parser_parsef(struct tab *, const char *, ...); +int parser_free(struct tab *); +int parser_serialize(struct tab *, FILE *); + +int parser_append(struct parser*, const char*, size_t); +int parser_set_buf(struct parser*, const char*, size_t); +int parser_foreach_line(struct parser*, const char*, size_t, parsechunkfn); + +/* parser_gemtext.c */ +void gemtext_initparser(struct parser*); + +/* parser_gophermap.c */ +void gophermap_initparser(struct parser *); + +/* parser_textpatch.c */ +void textpatch_initparser(struct parser *); + +/* parser_textplain.c */ +void textplain_initparser(struct parser*); + +#endif blob - /dev/null blob + bf1ec4d751e38ebc8a2188849d6202fd717c1a79 (mode 644) --- /dev/null +++ session.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef SESSION_H +#define SESSION_H + +struct ohash; + +struct session_tab { + uint32_t flags; + char uri[GEMINI_URL_LEN]; + char title[TITLE_MAX]; + size_t top_line; + size_t current_line; +}; + +struct session_tab_hist { + char uri[GEMINI_URL_LEN]; + int future; +}; + +struct histitem { + time_t ts; + char uri[GEMINI_URL_LEN]; +}; + +struct history_item { + time_t ts; + char *uri; + int dirty; +}; + +#define HISTORY_CAP 1000 +struct history { + struct history_item items[HISTORY_CAP]; + size_t len; + size_t dirty; + size_t extra; +}; +extern struct history history; + +void switch_to_tab(struct tab *); +unsigned int tab_new_id(void); +struct tab *new_tab(const char *, const char *base, struct tab *); +void kill_tab(struct tab *, int); +struct tab *unkill_tab(void); +void free_tab(struct tab *); +void stop_tab(struct tab*); + +void save_session(void); + +void history_push(struct histitem *); +void history_sort(void); +void history_add(const char *); + +void autosave_init(void); +void autosave_timer(int, short, void *); +void autosave_hook(void); + +int load_session(struct ohash *); +int lock_session(void); + +#endif blob - /dev/null blob + acb3a2423988a8d005fdc3feb99dc4e6348683c0 (mode 644) --- /dev/null +++ telescope.h @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef TELESCOPE_H +#define TELESCOPE_H + +#include "compat.h" + +#include +#include /* XXX: for parsers.h */ + +#include "cmd.h" +#include "iri.h" + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +#define GEMINI_URL_LEN 1024 +#define TITLE_MAX 128+1 /* account for NUL too */ + +#define SIDE_WINDOW_LEFT 0x1 +#define SIDE_WINDOW_BOTTOM 0x2 + +struct imsgev { + struct imsgbuf ibuf; + void (*handler)(int, short, void *); + struct event ev; + short events; +}; + +#define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE) + +enum imsg_type { + /* ui <-> net */ + IMSG_GET, /* struct get_req, peerid is the tab id */ + IMSG_ERR, + IMSG_CHECK_CERT, + IMSG_CERT_STATUS, + IMSG_GOT_CODE, + IMSG_GOT_META, + IMSG_PROCEED, + IMSG_STOP, + IMSG_BUF, + IMSG_EOF, + IMSG_QUIT, + + /* ui <-> ctl */ + IMSG_CTL_OPEN_URL, +}; + +enum line_type { + /* text/gemini */ + LINE_TEXT, + LINE_LINK, + LINE_TITLE_1, + LINE_TITLE_2, + LINE_TITLE_3, + LINE_ITEM, + LINE_QUOTE, + LINE_PRE_START, + LINE_PRE_CONTENT, + LINE_PRE_END, + + /* text/x-patch */ + LINE_PATCH, + LINE_PATCH_HDR, + LINE_PATCH_HUNK_HDR, + LINE_PATCH_ADD, + LINE_PATCH_DEL, + + /* minibuffer */ + LINE_COMPL, + LINE_COMPL_CURRENT, + + /* help */ + LINE_HELP, + + /* download */ + LINE_DOWNLOAD, + LINE_DOWNLOAD_DONE, + LINE_DOWNLOAD_INFO, + + /* misc ui */ + LINE_FRINGE, +}; + +struct line { + enum line_type type; + char *line; + char *alt; + void *data; + +#define L_HIDDEN 0x1 + int flags; + TAILQ_ENTRY(line) lines; +}; + +struct vline { + struct line *parent; + size_t from; + size_t len; + size_t cplen; + +#define L_CONTINUATION 0x2 + int flags; + TAILQ_ENTRY(vline) vlines; +}; + +struct parser; + +typedef int (*printfn)(void *, const char *, ...); + +typedef void (*parserinit)(struct parser *); + +typedef int (*parsechunkfn)(struct parser *, const char *, size_t); +typedef int (*parserfreefn)(struct parser *); +typedef int (*parserserial)(struct parser *, FILE *); + +typedef void (imsg_handlerfn)(struct imsg*, size_t); + +struct parser { + const char *name; + char title[128+1]; + char *buf; + size_t len; + size_t cap; + +#define PARSER_IN_BODY 1 +#define PARSER_IN_PRE 2 +#define PARSER_IN_PATCH_HDR 4 + int flags; + parserinit init; + parsechunkfn parse; + parserfreefn free; + parserserial serialize; + + TAILQ_HEAD(, line) head; +}; + +/* + * differnt types of trust for a certificate. Following + * gemini://thfr.info/gemini/modified-trust-verify.gmi + */ +enum trust_state { + TS_UNKNOWN, + TS_UNTRUSTED, + TS_TEMP_TRUSTED, + TS_TRUSTED, + TS_VERIFIED, +}; + +struct tofu_entry { + char domain[GEMINI_URL_LEN]; + + /* + * enough space for ``PROTO:HASH''. probably isn't a good + * idea tho. + */ + char hash[128+1]; + int verified; +}; + +struct buffer { + struct parser page; + + size_t last_line_off; + int force_redraw; + + int curs_x; + int curs_y; + size_t line_off; + size_t line_max; + struct vline *top_line; + struct vline *current_line; + size_t cpoff; + TAILQ_HEAD(vhead, vline) head; +}; + +#define TAB_CURRENT 0x1 /* only for save_session */ +#define TAB_KILLED 0x2 /* only for save_session */ +#define TAB_URGENT 0x4 +#define TAB_LAZY 0x8 /* to lazy load tabs */ + +#define NEW_TAB_URL "about:new" + +struct hist; + +TAILQ_HEAD(tabshead, tab); +extern struct tabshead tabshead; +extern struct tabshead ktabshead; +struct tab { + TAILQ_ENTRY(tab) tabs; + uint32_t id; + uint32_t flags; + + char *cert; + enum trust_state trust; + struct proxy *proxy; + struct iri iri; + struct hist *hist; + char *last_input_url; + + int code; + char meta[GEMINI_URL_LEN]; + int redirect_count; + + struct buffer buffer; + + short loading_anim; + short loading_anim_step; + struct event loadingev; +}; + +extern TAILQ_HEAD(proxylist, proxy) proxies; +struct proxy { + char *match_proto; + + char *host; + char *port; + int proto; + + TAILQ_ENTRY(proxy) proxies; +}; + +enum { + PROTO_FINGER, + PROTO_GEMINI, + PROTO_GOPHER, + /* ... */ +}; + +struct get_req { + int proto; + char host[254]; + char port[16]; + char req[1027]; +}; + +struct cmd { + const char *cmd; + void (*fn)(struct buffer *); + const char *descr; +}; +extern struct cmd cmds[]; + +/* downloads.c */ +extern STAILQ_HEAD(downloads, download) downloads; +struct download { + uint32_t id; + int fd; + size_t bytes; + char *path; + STAILQ_ENTRY(download) entries; +}; + +void recompute_downloads(void); +struct download *enqueue_download(uint32_t, const char *); +struct download *download_by_id(uint32_t); + +/* help.c */ +void recompute_help(void); + +/* mime.c */ +int setup_parser_for(struct tab*); + +/* net.c */ +int net_main(void); + +/* parse.y */ +void parseconfig(const char *, int); + +/* sandbox.c */ +void sandbox_net_process(void); +void sandbox_ui_process(void); + +/* telescope.c */ +extern int operating; +extern int safe_mode; + +#define LU_MODE_NONE 0x0 +#define LU_MODE_NOHIST 0x1 +#define LU_MODE_NOCACHE 0x2 + +void gopher_send_search_req(struct tab *, const char *); +void load_page_from_str(struct tab *, const char *); +void load_url(struct tab *, const char *, const char *, int); +void load_url_in_tab(struct tab *, const char *, const char *, int); +int load_previous_page(struct tab*); +int load_next_page(struct tab*); +void write_buffer(const char *, struct tab *); +void humanify_url(const char *, const char *, char *, size_t); +int bookmark_page(const char *); +int ui_send_net(int, uint32_t, const void *, uint16_t); + +/* tofu.c */ +void tofu_init(struct ohash*, unsigned int, ptrdiff_t); +struct tofu_entry *tofu_lookup(struct ohash*, const char*, const char*); +void tofu_add(struct ohash*, struct tofu_entry*); +int tofu_save(struct ohash *, struct tofu_entry *); +void tofu_update(struct ohash*, struct tofu_entry*); +int tofu_update_persist(struct ohash *, struct tofu_entry *); +void tofu_temp_trust(struct ohash *, const char *, const char *, const char *); + +/* wrap.c */ +void erase_buffer(struct buffer *); +void empty_linelist(struct buffer*); +void empty_vlist(struct buffer*); +int wrap_text(struct buffer*, const char*, struct line*, size_t, int); +int wrap_page(struct buffer *, int width); + +#endif /* TELESCOPE_H */ blob - /dev/null blob + fcf976c7f57b6998925409975bc245eb3a05fc5b (mode 644) --- /dev/null +++ ui.h @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef UI_H +#define UI_H + +#include "keymap.h" +#include "telescope.h" + +extern int body_lines; +extern int body_cols; + +extern struct kmap global_map, minibuffer_map, *current_map, *base_map; + +struct excursion { + int curs_x, curs_y; + size_t line_off; + struct vline *current_line; + struct vline *top_line; + size_t cpoff; +}; + +enum pairs { + PTL_BG = 1, + PTL_TAB, + PTL_CURR, + + PBODY, + PBLEFT, + PBRIGHT, + + PT, + PT_PRFX, + PT_TRAIL, + PL, + PL_PRFX, + PL_TRAIL, + PT1, + PT1_PRFX, + PT1_TRAIL, + PT2, + PT2_PRFX, + PT2_TRAIL, + PT3, + PT3_PRFX, + PT3_TRAIL, + PI, + PI_PRFX, + PI_TRAIL, + PQ, + PQ_PRFX, + PQ_TRAIL, + PPSTART, + PPSTART_PRFX, + PPSTART_TRAIL, + PP, + PP_PRFX, + PP_TRAIL, + PPEND, + PPEND_PRFX, + PPEND_TRAIL, + + PPATCH, + PPATCH_PRFX, + PPATCH_TRAIL, + PPATCH_HDR, + PPATCH_HDR_PRFX, + PPATCH_HDR_TRAIL, + PPATCH_HUNK_HDR, + PPATCH_HUNK_HDR_PRFX, + PPATCH_HUNK_HDR_TRAIL, + PPATCH_ADD, + PPATCH_ADD_PRFX, + PPATCH_ADD_TRAIL, + PPATCH_DEL, + PPATCH_DEL_PRFX, + PPATCH_DEL_TRAIL, + + PCOMPL_PRFX, + PCOMPL, + PCOMPL_TRAIL, + + PCOMPL_CURR_PRFX, + PCOMPL_CURR, + PCOMPL_CURR_TRAIL, + + PHELP_PRFX, + PHELP, + PHELP_TRAIL, + + PDOWNLOAD_PRFX, + PDOWNLOAD, + PDOWNLOAD_TRAIL, + + PDOWNLOAD_DONE_PRFX, + PDOWNLOAD_DONE, + PDOWNLOAD_DONE_TRAIL, + + PDOWNLOAD_INFO_PRFX, + PDOWNLOAD_INFO, + PDOWNLOAD_INFO_TRAIL, + + PDOWNLOAD_WIN, + + PMODELINE, + + PMINIBUF, + + PFRINGE_PRFX, + PFRINGE, + PFRINGE_TRAIL, +}; + +extern struct thiskey thiskey; + +extern struct tab *current_tab; + +extern struct buffer helpwin; +extern int help_lines, help_cols; + +extern struct buffer downloadwin; +extern int download_lines; +extern int download_cols; + +void get_scroll_position(struct tab *, size_t *, size_t *); +void save_excursion(struct excursion *, struct buffer *); +void restore_excursion(struct excursion *, struct buffer *); +void global_key_unbound(void); +struct buffer *current_buffer(void); +struct vline *adjust_line(struct vline *, struct buffer *); +void start_loading_anim(struct tab *); + +int ui_print_colors(void); +int ui_init(void); +void ui_main_loop(void); +void ui_on_tab_loaded(struct tab *); +void ui_on_tab_refresh(struct tab *); +void ui_on_download_refresh(void); +void ui_remotely_open_link(const char *); +const char *ui_keyname(int); +void ui_toggle_side_window(int); +void ui_show_downloads_pane(void); +void ui_schedule_redraw(void); +void ui_after_message_hook(void); +void ui_require_input(struct tab *, int, void (*)(void)); +void ui_yornp(const char *, void (*)(int, struct tab *), struct tab *); +void ui_read(const char *, void (*)(const char *, struct tab *), struct tab *, const char *); +void ui_other_window(void); +void ui_suspend(void); +void ui_end(void); + +#endif blob - /dev/null blob + 2c6273046d618fe14d98dc139adee0409a99cf42 (mode 644) --- /dev/null +++ utf8.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef UTF8_H +#define UTF8_H + +#include +#include + +/* utf8.c */ +uint32_t utf8_decode(uint32_t*restrict, uint32_t*restrict, uint8_t); +size_t utf8_encode(uint32_t, char*); +char *utf8_nth(char*, size_t); +size_t utf8_cplen(char*); +size_t utf8_ncplen(const char *, size_t); +size_t utf8_chwidth(uint32_t); +size_t utf8_snwidth(const char*, size_t); +size_t utf8_swidth(const char*); +size_t utf8_swidth_between(const char*, const char*); +char *utf8_next_cp(const char*); +char *utf8_prev_cp(const char*, const char*); +int emojied_line(const char *, const char **); + +/* emoji-matcher.c */ +int is_emoji(uint32_t); + +#endif blob - /dev/null blob + 588673966051ca334bb6556f4e9054308ee8bc64 (mode 644) --- /dev/null +++ utils.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef UTILS_H +#define UTILS_H + +int mark_nonblock_cloexec(int); + +int has_suffix(const char *, const char *); +int unicode_isspace(uint32_t); +int unicode_isgraph(uint32_t); + +void imsg_event_add(struct imsgev *); +int dispatch_imsg(struct imsgev *, short, imsg_handlerfn **, size_t); +int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t, int, const void *, uint16_t); + +void *hash_alloc(size_t, void *); +void *hash_calloc(size_t, size_t, void *); +void hash_free(void *, void *); + +#endif /* UTILS_H */