diff options
Diffstat (limited to 'src/interface.h')
| -rw-r--r-- | src/interface.h | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/src/interface.h b/src/interface.h index 33b094b..f196a83 100644 --- a/src/interface.h +++ b/src/interface.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2025 Robin Haberkorn + * Copyright (C) 2012-2026 Robin Haberkorn * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ */ #pragma once -#include <stdarg.h> #include <signal.h> #include <glib.h> @@ -42,6 +41,12 @@ * feature. */ +/** + * Interval between polling for keypresses (if necessary). + * In other words, this is the maximum latency to detect CTRL+C interruptions. + */ +#define TECO_POLL_INTERVAL 100000 /* microseconds */ + /** @protected */ extern teco_view_t *teco_interface_current_view; @@ -61,18 +66,15 @@ typedef enum { TECO_MSG_ERROR } teco_msg_t; +extern teco_msg_t teco_interface_msg_level; + /** @pure */ -void teco_interface_vmsg(teco_msg_t type, const gchar *fmt, va_list ap); +void teco_interface_msg_literal(teco_msg_t type, const gchar *str, gsize len); -static inline void G_GNUC_PRINTF(2, 3) -teco_interface_msg(teco_msg_t type, const gchar *fmt, ...) -{ - va_list ap; +void teco_interface_msg(teco_msg_t type, const gchar *fmt, ...) G_GNUC_PRINTF(2, 3); - va_start(ap, fmt); - teco_interface_vmsg(type, fmt, ap); - va_end(ap); -} +/** @pure */ +teco_int_t teco_interface_getch(gboolean widechar); /** @pure */ void teco_interface_msg_clear(void); @@ -93,6 +95,14 @@ teco_interface_ssm(unsigned int iMessage, uptr_t wParam, sptr_t lParam) */ void undo__teco_interface_ssm(unsigned int, uptr_t, sptr_t); +/** Expand folds, so that dot is always visible. */ +static inline void +teco_interface_unfold(void) +{ + sptr_t dot = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0); + teco_interface_ssm(SCI_ENSUREVISIBLE, teco_interface_ssm(SCI_LINEFROMPOSITION, dot, 0), 0); +} + /** @pure */ void teco_interface_info_update_qreg(const teco_qreg_t *reg); /** @pure */ @@ -108,9 +118,6 @@ void undo__teco_interface_info_update_qreg(const teco_qreg_t *); void undo__teco_interface_info_update_buffer(const teco_buffer_t *); /** @pure */ -void teco_interface_cmdline_update(const teco_cmdline_t *cmdline); - -/** @pure */ gboolean teco_interface_set_clipboard(const gchar *name, const gchar *str, gsize str_len, GError **error); void teco_interface_undo_set_clipboard(const gchar *name, gchar *str, gsize len); @@ -128,7 +135,17 @@ typedef enum { TECO_POPUP_DIRECTORY } teco_popup_entry_type_t; -/** @pure */ +/** + * Add entry to popup. + * + * @param type Entry type + * @param name + * Name string of the entry or NULL for "(Unnamed)". + * It is not necessarily null-terminated. + * @param name_len Length of string in name + * @param highlight Whether to highlight the entry + * @pure + */ void teco_interface_popup_add(teco_popup_entry_type_t type, const gchar *name, gsize name_len, gboolean highlight); /** @pure */ @@ -145,7 +162,7 @@ gboolean teco_interface_is_interrupted(void); typedef struct { enum { - TECO_MOUSE_PRESSED = 1, + TECO_MOUSE_PRESSED = 0, TECO_MOUSE_RELEASED, TECO_MOUSE_SCROLLUP, TECO_MOUSE_SCROLLDOWN @@ -172,7 +189,13 @@ gboolean teco_interface_event_loop(GError **error); * Interfacing to the external SciTECO world */ /** @protected */ -void teco_interface_stdio_vmsg(teco_msg_t type, const gchar *fmt, va_list ap); +void teco_interface_stdio_msg(teco_msg_t type, const gchar *str, gsize len); + +/** @protected */ +teco_int_t teco_interface_stdio_getch(gboolean widechar); + +/** @protected */ +void teco_interface_refresh(gboolean force); /** @pure */ void teco_interface_cleanup(void); |
