commit - b91f4f84d78cc64eebdc37b71e67f689e1b62746
commit + f26f1205275cf2849d2754beff3d9d65c161c98a
blob - 8885cec3b098d222561b983bdffe75d8776f4b46
blob + 265e705c9a2c4a1917bddc5d07f838847b635c6e
--- Makefile.am
+++ Makefile.am
telescope_SOURCES = cmd.c \
cmd.gen.c \
- cmd.h \
- compat.h \
compl.c \
- compl.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/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 \
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 \
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 \
- ui.h \
- utf8.h \
- utils.c \
- utils.h
+ utils.c
# phos bundled files
telescope_SOURCES += phos/phos.h \
CLEANFILES = cmd.gen.c compile_flags.txt u/emoji-matcher.c pages.c \
parse.c
+AM_CPPFLAGS = -I$(top_srcdir)/phos -I$(top_srcdir)/include
LDADD = $(LIBOBJS)
EXTRA_DIST = ChangeLog LICENSE README.md data/emoji.txt pages/*.gmi
dist_man1_MANS = telescope.1
-cmd.gen.c: $(srcdir)/cmd.h $(srcdir)/gencmd.awk
- ${AWK} -f $(srcdir)/gencmd.awk < $(srcdir)/cmd.h > $@
+cmd.gen.c: $(srcdir)/include/cmd.h $(srcdir)/gencmd.awk
+ ${AWK} -f $(srcdir)/gencmd.awk < $(srcdir)/include/cmd.h > $@
u/emoji-matcher.c: $(srcdir)/data/emoji.txt $(srcdir)/u/genemoji.sh
$(srcdir)/u/genemoji.sh $(srcdir)/data/emoji.txt > $@
$(srcdir)/pages/about_help.gmi \
$(srcdir)/pages/about_license.gmi \
$(srcdir)/pages/about_new.gmi
-pages.c: pagebundler $(srcdir)/pages.h ${PAGES}
+pages.c: pagebundler $(srcdir)/include/pages.h ${PAGES}
echo > $@
- echo "#include \"pages.h\"" >> $@
+ echo "#include \"include/pages.h\"" >> $@
./pagebundler $(srcdir)/pages/about_about.gmi >> $@
./pagebundler $(srcdir)/pages/about_blank.gmi >> $@
./pagebundler $(srcdir)/pages/about_crash.gmi >> $@
blob - a4fd3fbd593dc70791e26dc9239884f3769cacbd (mode 644)
blob + /dev/null
--- cmd.h
+++ /dev/null
-struct buffer;
-
-#define CMD(fnname, descr) void fnname(struct buffer *)
-#define DEFALIAS(s, d) /* nothing */
-
-DEFALIAS(q, cmd_kill_telescope)
-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_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_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_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_undo_close, "Reopen last closed tab.");
-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_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.");
blob - 50a4c8463e720db999afd8a7439dadf1d102a913 (mode 644)
blob + /dev/null
--- compat.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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 <sys/types.h>
-#include <sys/uio.h>
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdint.h>
-
-#if HAVE_EVENT2
-# include <event2/event.h>
-# include <event2/event_compat.h>
-# include <event2/event_struct.h>
-# include <event2/buffer.h>
-# include <event2/buffer_compat.h>
-# include <event2/bufferevent.h>
-# include <event2/bufferevent_struct.h>
-# include <event2/bufferevent_compat.h>
-#else
-# include <event.h>
-#endif
-
-#ifdef HAVE_QUEUE_H
-# include <sys/queue.h>
-#else
-# include "compat/queue.h"
-#endif
-
-#ifdef HAVE_IMSG
-# include <imsg.h>
-#else
-# include "compat/imsg.h"
-#endif
-
-#ifdef HAVE_LIBUTIL
-# include <ohash.h>
-# include <util.h>
-#else
-# include "compat/ohash.h"
-# define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
-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 <err.h>
-#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 - 895de6a295c781e74309b1b0bb844f82ae5e6f11 (mode 644)
blob + /dev/null
--- compl.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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_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 - adc2a2c9a0fc0506cb9b3aab32c4f063334118ad (mode 644)
blob + /dev/null
--- defaults.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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 *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 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;
-
-#endif
blob - c1a0fce9a9af9b827c7f23a1ee95b36269b4cd3f (mode 644)
blob + /dev/null
--- fs.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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
-
-#include "compat.h"
-
-#include <limits.h>
-
-extern char config_path_base[PATH_MAX];
-extern char data_path_base[PATH_MAX];
-extern char cache_path_base[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];
-
-int fs_init(void);
-int fs_main(void);
-int lock_session(void);
-
-#endif
blob - /dev/null
blob + a4fd3fbd593dc70791e26dc9239884f3769cacbd (mode 644)
--- /dev/null
+++ include/cmd.h
+struct buffer;
+
+#define CMD(fnname, descr) void fnname(struct buffer *)
+#define DEFALIAS(s, d) /* nothing */
+
+DEFALIAS(q, cmd_kill_telescope)
+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_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_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_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_undo_close, "Reopen last closed tab.");
+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_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.");
blob - /dev/null
blob + 50a4c8463e720db999afd8a7439dadf1d102a913 (mode 644)
--- /dev/null
+++ include/compat.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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 <sys/types.h>
+#include <sys/uio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#if HAVE_EVENT2
+# include <event2/event.h>
+# include <event2/event_compat.h>
+# include <event2/event_struct.h>
+# include <event2/buffer.h>
+# include <event2/buffer_compat.h>
+# include <event2/bufferevent.h>
+# include <event2/bufferevent_struct.h>
+# include <event2/bufferevent_compat.h>
+#else
+# include <event.h>
+#endif
+
+#ifdef HAVE_QUEUE_H
+# include <sys/queue.h>
+#else
+# include "compat/queue.h"
+#endif
+
+#ifdef HAVE_IMSG
+# include <imsg.h>
+#else
+# include "compat/imsg.h"
+#endif
+
+#ifdef HAVE_LIBUTIL
+# include <ohash.h>
+# include <util.h>
+#else
+# include "compat/ohash.h"
+# define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
+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 <err.h>
+#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 + 895de6a295c781e74309b1b0bb844f82ae5e6f11 (mode 644)
--- /dev/null
+++ include/compl.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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_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 + adc2a2c9a0fc0506cb9b3aab32c4f063334118ad (mode 644)
--- /dev/null
+++ include/defaults.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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 *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 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;
+
+#endif
blob - /dev/null
blob + c1a0fce9a9af9b827c7f23a1ee95b36269b4cd3f (mode 644)
--- /dev/null
+++ include/fs.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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
+
+#include "compat.h"
+
+#include <limits.h>
+
+extern char config_path_base[PATH_MAX];
+extern char data_path_base[PATH_MAX];
+extern char cache_path_base[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];
+
+int fs_init(void);
+int fs_main(void);
+int lock_session(void);
+
+#endif
blob - /dev/null
blob + 3b1ca4e8c8e72b9764f5845bffdefefd794966b8 (mode 644)
--- /dev/null
+++ include/keymap.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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 <stdint.h>
+
+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
+++ include/mcache.h
+/*
+ * Copyright (c) 2022 Omar Polo <op@omarpolo.com>
+ *
+ * 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 + 70795ac34c8058672ee0a2487c150076873f97b8 (mode 644)
--- /dev/null
+++ include/minibuffer.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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 **);
+
+extern struct histhead eecmd_history,
+ ir_history,
+ lu_history,
+ 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 histhead *history;
+ struct hist *hist_cur;
+ size_t hist_off;
+
+ struct {
+ struct buffer buffer;
+ complfn *fn;
+ void *data;
+ } 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 histhead *, complfn *, void *);
+
+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 - /dev/null
blob + 93fd09804c8dc8c83fd775626dbc9a2de14f997d (mode 644)
--- /dev/null
+++ include/pages.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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 <stddef.h>
+#include <stdint.h>
+
+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 + 372529021fd1833629b45acdab87efb6e8a76704 (mode 644)
--- /dev/null
+++ include/parser.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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_free(struct tab *);
+int parser_serialize(struct tab *, struct evbuffer *);
+
+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 + 43a69b8fbf331f85f67f3c290166e110e243b5c4 (mode 644)
--- /dev/null
+++ include/session.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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
+
+#include "telescope.h"
+
+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;
+};
+
+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 autosave_init(void);
+void autosave_timer(int, short, void *);
+void autosave_hook(void);
+
+#endif
blob - /dev/null
blob + 0cb0ce4cfe1f0a4ffcdad5198e41bc316197341e (mode 644)
--- /dev/null
+++ include/telescope.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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 <limits.h>
+
+#include "cmd.h"
+#include "phos.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;
+};
+
+enum imsg_type {
+ /* ui <-> client/fs */
+ IMSG_GET, /* data is URL, peerid the tab id */
+ IMSG_GET_FILE, /* data is path, without \r\n or such */
+ IMSG_GET_RAW, /* get but with an explicit req str */
+ 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 <-> fs */
+ IMSG_INIT,
+ IMSG_TOFU,
+ IMSG_BOOKMARK_PAGE,
+ IMSG_BOOKMARK_OK,
+ IMSG_SAVE_CERT,
+ IMSG_SAVE_CERT_OK,
+ IMSG_UPDATE_CERT,
+ IMSG_UPDATE_CERT_OK,
+
+ IMSG_FILE_OPEN,
+ IMSG_FILE_OPENED,
+
+ IMSG_SESSION_START,
+ IMSG_SESSION_TAB,
+ IMSG_SESSION_TAB_HIST,
+ IMSG_SESSION_END,
+};
+
+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,
+};
+
+/* for lines: mark as hidden */
+#define L_HIDDEN 1
+
+/* for vlines: mark as continuation */
+#define L_CONTINUATION 2
+
+struct line {
+ enum line_type type;
+ char *line;
+ char *alt;
+ void *data;
+ int flags;
+ TAILQ_ENTRY(line) lines;
+};
+
+struct vline {
+ struct line *parent;
+ char *line;
+ int flags;
+ TAILQ_ENTRY(vline) vlines;
+};
+
+struct parser;
+
+typedef int (*parsechunkfn)(struct parser*, const char*, size_t);
+typedef int (*parserfreefn)(struct parser*);
+typedef int (*parserserial)(struct parser*, struct evbuffer *);
+
+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;
+ void (*init)(struct parser *);
+ 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 histhead {
+ TAILQ_HEAD(mhisthead, hist) head;
+ size_t len;
+};
+struct hist {
+ char h[1025];
+ size_t line_off;
+ size_t current_off;
+ TAILQ_ENTRY(hist) entries;
+};
+
+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"
+
+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 phos_uri uri;
+ struct histhead hist;
+ struct hist *hist_cur;
+ size_t hist_off;
+ 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[];
+
+/* defaults.c */
+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_setcolor(int, const char *, int, int, int);
+int config_setattr(const char *, int, int, int);
+void config_apply_style(void);
+
+/* 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);
+void enqueue_download(uint32_t, const char *);
+struct download *download_by_id(uint32_t);
+
+/* help.c */
+void recompute_help(void);
+
+/* hist.c */
+void hist_clear(struct histhead *);
+void hist_clear_forward(struct histhead*, struct hist*);
+void hist_push(struct histhead*, struct hist*);
+void hist_add_before(struct histhead *, struct hist *, struct hist *);
+struct hist *hist_pop(struct histhead *);
+
+/* 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);
+void sandbox_fs_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 *);
+int 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 add_to_bookmarks(const char*);
+void humanify_url(const char *, char *, size_t);
+int ui_send_net(int, uint32_t, const void *, uint16_t);
+int ui_send_fs(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*);
+void tofu_update(struct ohash*, struct tofu_entry*);
+void tofu_temp_trust(struct ohash *, const char *, const char *, const char *);
+
+/* util.c */
+
+/* wrap.c */
+void erase_buffer(struct buffer *);
+void empty_linelist(struct buffer*);
+void empty_vlist(struct buffer*);
+int wrap_one(struct buffer *, const char *, struct line *, size_t);
+int wrap_text(struct buffer*, const char*, struct line*, size_t);
+int hardwrap_text(struct buffer*, struct line*, size_t);
+int wrap_page(struct buffer *, int width);
+
+#endif /* TELESCOPE_H */
blob - /dev/null
blob + fc246f83cadcb8f31f2b8a7fb2de68b04cd61937 (mode 644)
--- /dev/null
+++ include/ui.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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);
+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 + 8f05942c15dbe9f9e528175f4043bb86791acb67 (mode 644)
--- /dev/null
+++ include/utf8.h
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * 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 <stddef.h>
+#include <stdint.h>
+
+/* 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_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 + 86b7395a7d1e2319fcd94a1da10c3be28ff1e45c (mode 644)
--- /dev/null
+++ include/utils.h
+/*
+ * Copyright (c) 2022 Omar Polo <op@omarpolo.com>
+ *
+ * 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(int);
+
+int has_prefix(const char*, const char*);
+int has_suffix(const char *, const char *);
+int unicode_isspace(uint32_t);
+int unicode_isgraph(uint32_t);
+
+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 - 3b1ca4e8c8e72b9764f5845bffdefefd794966b8 (mode 644)
blob + /dev/null
--- keymap.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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 <stdint.h>
-
-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
--- mcache.h
+++ /dev/null
-/*
- * Copyright (c) 2022 Omar Polo <op@omarpolo.com>
- *
- * 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 - 70795ac34c8058672ee0a2487c150076873f97b8 (mode 644)
blob + /dev/null
--- minibuffer.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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 **);
-
-extern struct histhead eecmd_history,
- ir_history,
- lu_history,
- 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 histhead *history;
- struct hist *hist_cur;
- size_t hist_off;
-
- struct {
- struct buffer buffer;
- complfn *fn;
- void *data;
- } 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 histhead *, complfn *, void *);
-
-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
--- pages.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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 <stddef.h>
-#include <stdint.h>
-
-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 - 372529021fd1833629b45acdab87efb6e8a76704 (mode 644)
blob + /dev/null
--- parser.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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_free(struct tab *);
-int parser_serialize(struct tab *, struct evbuffer *);
-
-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 - 43a69b8fbf331f85f67f3c290166e110e243b5c4 (mode 644)
blob + /dev/null
--- session.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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
-
-#include "telescope.h"
-
-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;
-};
-
-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 autosave_init(void);
-void autosave_timer(int, short, void *);
-void autosave_hook(void);
-
-#endif
blob - 21778771969b58af00d8f60052518efdf7759955 (mode 644)
blob + /dev/null
--- telescope.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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 <limits.h>
-
-#include "cmd.h"
-#include "phos/phos.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;
-};
-
-enum imsg_type {
- /* ui <-> client/fs */
- IMSG_GET, /* data is URL, peerid the tab id */
- IMSG_GET_FILE, /* data is path, without \r\n or such */
- IMSG_GET_RAW, /* get but with an explicit req str */
- 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 <-> fs */
- IMSG_INIT,
- IMSG_TOFU,
- IMSG_BOOKMARK_PAGE,
- IMSG_BOOKMARK_OK,
- IMSG_SAVE_CERT,
- IMSG_SAVE_CERT_OK,
- IMSG_UPDATE_CERT,
- IMSG_UPDATE_CERT_OK,
-
- IMSG_FILE_OPEN,
- IMSG_FILE_OPENED,
-
- IMSG_SESSION_START,
- IMSG_SESSION_TAB,
- IMSG_SESSION_TAB_HIST,
- IMSG_SESSION_END,
-};
-
-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,
-};
-
-/* for lines: mark as hidden */
-#define L_HIDDEN 1
-
-/* for vlines: mark as continuation */
-#define L_CONTINUATION 2
-
-struct line {
- enum line_type type;
- char *line;
- char *alt;
- void *data;
- int flags;
- TAILQ_ENTRY(line) lines;
-};
-
-struct vline {
- struct line *parent;
- char *line;
- int flags;
- TAILQ_ENTRY(vline) vlines;
-};
-
-struct parser;
-
-typedef int (*parsechunkfn)(struct parser*, const char*, size_t);
-typedef int (*parserfreefn)(struct parser*);
-typedef int (*parserserial)(struct parser*, struct evbuffer *);
-
-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;
- void (*init)(struct parser *);
- 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 histhead {
- TAILQ_HEAD(mhisthead, hist) head;
- size_t len;
-};
-struct hist {
- char h[1025];
- size_t line_off;
- size_t current_off;
- TAILQ_ENTRY(hist) entries;
-};
-
-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"
-
-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 phos_uri uri;
- struct histhead hist;
- struct hist *hist_cur;
- size_t hist_off;
- 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[];
-
-/* defaults.c */
-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_setcolor(int, const char *, int, int, int);
-int config_setattr(const char *, int, int, int);
-void config_apply_style(void);
-
-/* 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);
-void enqueue_download(uint32_t, const char *);
-struct download *download_by_id(uint32_t);
-
-/* help.c */
-void recompute_help(void);
-
-/* hist.c */
-void hist_clear(struct histhead *);
-void hist_clear_forward(struct histhead*, struct hist*);
-void hist_push(struct histhead*, struct hist*);
-void hist_add_before(struct histhead *, struct hist *, struct hist *);
-struct hist *hist_pop(struct histhead *);
-
-/* 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);
-void sandbox_fs_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 *);
-int 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 add_to_bookmarks(const char*);
-void humanify_url(const char *, char *, size_t);
-int ui_send_net(int, uint32_t, const void *, uint16_t);
-int ui_send_fs(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*);
-void tofu_update(struct ohash*, struct tofu_entry*);
-void tofu_temp_trust(struct ohash *, const char *, const char *, const char *);
-
-/* util.c */
-
-/* wrap.c */
-void erase_buffer(struct buffer *);
-void empty_linelist(struct buffer*);
-void empty_vlist(struct buffer*);
-int wrap_one(struct buffer *, const char *, struct line *, size_t);
-int wrap_text(struct buffer*, const char*, struct line*, size_t);
-int hardwrap_text(struct buffer*, struct line*, size_t);
-int wrap_page(struct buffer *, int width);
-
-#endif /* TELESCOPE_H */
blob - e08198e4e7f2f1c4ed4d0ab0727eefbd9d7cd6af
blob + 62b676ec01fa9dbd2c6a69968d68fe119552a61f
--- test/Makefile.am
+++ test/Makefile.am
check_PROGRAMS = gmparser
gmparser_SOURCES = gmparser.c \
- $(top_srcdir)/compat.h \
- $(top_srcdir)/parser.h \
+ $(top_srcdir)/include/compat.h \
+ $(top_srcdir)/include/parser.h \
$(top_srcdir)/parser/parser.c \
$(top_srcdir)/parser/parser_gophermap.c \
$(top_srcdir)/utils.c
-gmparser_CFLAGS = -I$(top_srcdir)
+gmparser_CFLAGS = -I$(top_srcdir)/phos -I$(top_srcdir)/include
EXTRA_DIST = test-gmparser \
gm-00 \
blob - fc246f83cadcb8f31f2b8a7fb2de68b04cd61937 (mode 644)
blob + /dev/null
--- ui.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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);
-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 - 8f05942c15dbe9f9e528175f4043bb86791acb67 (mode 644)
blob + /dev/null
--- utf8.h
+++ /dev/null
-/*
- * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
- *
- * 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 <stddef.h>
-#include <stdint.h>
-
-/* 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_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 - 86b7395a7d1e2319fcd94a1da10c3be28ff1e45c (mode 644)
blob + /dev/null
--- utils.h
+++ /dev/null
-/*
- * Copyright (c) 2022 Omar Polo <op@omarpolo.com>
- *
- * 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(int);
-
-int has_prefix(const char*, const char*);
-int has_suffix(const char *, const char *);
-int unicode_isspace(uint32_t);
-int unicode_isgraph(uint32_t);
-
-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 */