From b87c56799ab6f6d651e1dc6c712a625545a4ad5f Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 2 Feb 2025 13:17:51 +0300 Subject: implemented mouse support via special ^KMOUSE and with negative keys * You need to set 0,64ED to enable mouse processing in Curses. It is always enabled in Gtk as it should never make the experience worse. sample.teco_ini enables mouse support, since this should be the new default. `sciteco --no-profile` won't have it enabled, though. * On curses, it requires the ncurses mouse protocol version 2, which will also be supported by PDCurses. * Similar to the Curses API, a special key macro ^KMOUSE is inserted if any of the supported mouse events has been detected. * You can then use -EJ to get the type of mouse event, which can be used with a computed goto in the command-line editing macro. Alternatively, this could have been solved with separate ^KMOUSE:PRESSED, ^KMOUSE:RELEASED etc. pseudo-key macros. * The default ^KMOUSE implementation in fnkeys.tes supports the following: * Left click: Edit command line to jump to position. * Ctrl+left click: Jump to beginning of line. * Right click: Insert position or position range (when dragging). * Double right click: insert range for word under cursor * Ctrl+right click: Insert beginning of line * Scroll wheel: scrolls (faster with shift) * Ctrl+scroll wheel: zoom (GTK-only) * Currently, there is no visual feedback when "selecting" ranges via right-click+drag. This would be tricky to do and most terminal emulators do not appear to support continuous mouse updates. --- src/interface.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/interface.h') diff --git a/src/interface.h b/src/interface.h index 12e76fb..967f14d 100644 --- a/src/interface.h +++ b/src/interface.h @@ -141,6 +141,28 @@ void teco_interface_popup_clear(void); /** @pure */ gboolean teco_interface_is_interrupted(void); +typedef struct { + enum { + TECO_MOUSE_PRESSED = 1, + TECO_MOUSE_RELEASED, + TECO_MOUSE_SCROLLUP, + TECO_MOUSE_SCROLLDOWN + } type; + + guint x; /*< X-coordinate relative to view */ + guint y; /*< Y-coordinate relative to view */ + + gint button; /*< number of pressed mouse button or -1 */ + + enum { + TECO_MOUSE_SHIFT = (1 << 0), + TECO_MOUSE_CTRL = (1 << 1), + TECO_MOUSE_ALT = (1 << 2) + } mods; +} teco_mouse_t; + +extern teco_mouse_t teco_mouse; + /** @pure main entry point */ gboolean teco_interface_event_loop(GError **error); -- cgit v1.2.3