Commit Diff


commit - 63f1dea533df57b76416da34497c48e84552c0ed
commit + d1a0f2a344977e9d699dc16cf981e31059bdf5bb
blob - 74ec84973f8a92ff8712093e7bb14509367b728f
blob + e3c9f948f067616de32c93bbd494d76046e1787e
--- cmd.c
+++ cmd.c
@@ -20,6 +20,7 @@
 
 #include "minibuffer.h"
 #include "telescope.h"
+#include "ui.h"
 
 /* return 1 if moved, 0 otherwise */
 static inline int
blob - 735d8d361873df4be8a102212d792ff1389f69f4
blob + f81e782d05e5dbef3d4e068c7c27f7fc4a6d9c2d
--- defaults.c
+++ defaults.c
@@ -14,14 +14,15 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include "telescope.h"
-
 #include <curses.h>
 #include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
+#include "telescope.h"
+#include "ui.h"
+
 char *new_tab_url = NULL;
 int fill_column = 80;
 int olivetti_mode = 1;
blob - 7f7665cd44d28d5bd889e526cfae83afccd9d0ec
blob + 08e58b71bbcc2a015e99277e2cca513ec26475de
--- minibuffer.c
+++ minibuffer.c
@@ -18,6 +18,7 @@
 #include <string.h>
 
 #include "minibuffer.h"
+#include "ui.h"
 
 static void		 minibuffer_hist_save_entry(void);
 static void		 minibuffer_self_insert(void);
blob - 1023614c7626fc769995dc7583ab0b649b67d568
blob + ab78b5c149238a9964b489ab5c4e0f8839c4c53c
--- telescope.c
+++ telescope.c
@@ -10,6 +10,7 @@
 
 #include "parser.h"
 #include "telescope.h"
+#include "ui.h"
 
 struct event		 netev, fsev;
 struct tabshead		 tabshead = TAILQ_HEAD_INITIALIZER(tabshead);
blob - f6026c70b315c71149f6948ce233491ce03fe55d
blob + 61bd2c2060b8693e1a2860d6946df94652d0f97e
--- telescope.h
+++ telescope.h
@@ -377,127 +377,7 @@ struct tofu_entry	*tofu_lookup(struct ohash*, const ch
 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 *);
-
-/* ui.c */
-extern int	 body_lines;
-extern int	 body_cols;
-extern int	 in_minibuffer;
-
-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;
-	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,
-
-	PMODELINE,
-
-	PMINIBUF,
-};
-
-struct thiskey {
-	short meta;
-	int key;
-	uint32_t cp;
-};
-extern struct thiskey thiskey;
 
-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;
-};
-extern struct ministate ministate;
-
-void		 save_excursion(struct excursion *, struct buffer *);
-void		 restore_excursion(struct excursion *, struct buffer *);
-void		 global_key_unbound(void);
-void		 minibuffer_taint_hist(void);
-void		 eecmd_self_insert(void);
-void		 eecmd_select(void);
-void		 ir_self_insert(void);
-void		 ir_select(void);
-void		 lu_self_insert(void);
-void		 lu_select(void);
-void		 bp_select(void);
-void		 vmessage(const char*, va_list);
-void		 message(const char*, ...) __attribute__((format(printf, 1, 2)));
-void		 start_loading_anim(struct tab *tab);
-void		 load_url_in_tab(struct tab *, const char *);
-void		 switch_to_tab(struct tab *);
-struct tab	*current_tab(void);
-struct buffer	*current_buffer(void);
-struct tab	*new_tab(const char *);
-unsigned int	 tab_new_id(void);
-int		 ui_init(void);
-void		 ui_on_tab_loaded(struct tab*);
-void		 ui_on_tab_refresh(struct tab*);
-const char	*ui_keyname(int);
-void		 ui_toggle_side_window(void);
-void		 ui_schedule_redraw(void);
-void		 ui_require_input(struct tab*, int);
-void		 ui_read(const char*, void(*)(const char*, unsigned int), unsigned int);
-void		 ui_yornp(const char*, void (*)(int, struct tab *), struct tab *);
-void		 ui_end(void);
-
 /* utf.8 */
 uint32_t	 utf8_decode(uint32_t*restrict, uint32_t*restrict, uint8_t);
 size_t		 utf8_encode(uint32_t, char*);
blob - 45987d73e1268e311d608a0b3f38cd58055c2168
blob + 7b5e2eb83e3b3c9ea01dc74ccef33fcf439641f6
--- ui.c
+++ ui.c
@@ -30,9 +30,6 @@
  *
  */
 
-#include "minibuffer.h"
-#include "telescope.h"
-
 #include <assert.h>
 #include <curses.h>
 #include <event.h>
@@ -43,6 +40,10 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "minibuffer.h"
+#include "telescope.h"
+#include "ui.h"
+
 static struct event	stdioev, winchev;
 
 static void		 restore_curs_x(struct buffer *);
blob - /dev/null
blob + 6e5be047ea41d7688ac36022396b3801e7b3075a (mode 644)
--- /dev/null
+++ ui.h
@@ -0,0 +1,141 @@
+/*
+ * 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 "telescope.h"
+
+extern int	 body_lines;
+extern int	 body_cols;
+extern int	 in_minibuffer;
+
+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;
+	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,
+
+	PMODELINE,
+
+	PMINIBUF,
+};
+
+struct thiskey {
+	short meta;
+	int key;
+	uint32_t cp;
+};
+extern struct thiskey thiskey;
+
+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;
+};
+extern struct ministate ministate;
+
+void		 save_excursion(struct excursion *, struct buffer *);
+void		 restore_excursion(struct excursion *, struct buffer *);
+void		 global_key_unbound(void);
+void		 minibuffer_taint_hist(void);
+void		 eecmd_self_insert(void);
+void		 eecmd_select(void);
+void		 ir_self_insert(void);
+void		 ir_select(void);
+void		 lu_self_insert(void);
+void		 lu_select(void);
+void		 bp_select(void);
+void		 vmessage(const char *, va_list);
+void		 message(const char *, ...) __attribute__((format(printf, 1, 2)));
+void		 start_loading_anim(struct tab *);
+void		 load_url_in_tab(struct tab *, const char *);
+void		 switch_to_tab(struct tab *);
+struct tab	*current_tab(void);
+struct buffer	*current_buffer(void);
+struct tab	*new_tab(const char *);
+unsigned int	 tab_new_id(void);
+int		 ui_init(void);
+void		 ui_on_tab_loaded(struct tab *);
+void		 ui_on_tab_refresh(struct tab *);
+const char	*ui_keyname(int);
+void		 ui_toggle_side_window(void);
+void		 ui_schedule_redraw(void);
+void		 ui_require_input(struct tab *, int);
+void		 ui_read(const char *, void (*)(const char *, unsigned int), unsigned int);
+void		 ui_yornp(const char *, void (*)(int, struct tab *), struct tab *);
+void		 ui_end(void);
+
+#endif