This commit is contained in:
root
2024-07-29 17:28:02 -07:00
parent a351665606
commit 2f498e49c7
3 changed files with 1 additions and 132 deletions

View File

@@ -1,6 +1,6 @@
{ lib, pkgs, config, inputs, utils, ... }:
{
imports = [ ./module.nix ./commands.nix ./overlays.nix ];
imports = [ ./module.nix ./commands.nix ];
options.vacu.underTest = lib.mkOption {
default = false;
type = lib.types.bool;

View File

@@ -1,7 +0,0 @@
{ pkgs, ... }: {
nixpkgs.overlays = [
(final: prev: {
screen = prev.screen.overrideAttrs { patches = (prev.screen.patches or []) ++ [ ../screen-esc-fix.patch ]; };
})
];
}

View File

@@ -1,124 +0,0 @@
diff --git a/src/display.c b/src/display.c
index 4a1679a..8a940c1 100644
--- a/src/display.c
+++ b/src/display.c
@@ -71,6 +71,7 @@ static void disp_blocked_fn(Event *, void *);
static void disp_map_fn(Event *, void *);
static void disp_idle_fn(Event *, void *);
static void disp_blanker_fn(Event *, void *);
+static void disp_mousetimeout_fn(Event *, void *);
static void disp_processinput (Display *, unsigned char *, size_t);
static void WriteLP(int, int);
static void INSERTCHAR(uint32_t);
@@ -213,6 +214,9 @@ Display *MakeDisplay(char *uname, char *utty, char *term, int fd, pid_t pid, str
D_blankerev.data = (char *)display;
D_blankerev.handler = disp_blanker_fn;
D_blankerev.fd = -1;
+ D_mousetimeoutev.type = EV_TIMEOUT;
+ D_mousetimeoutev.data = (char *)display;
+ D_mousetimeoutev.handler = disp_mousetimeout_fn;
D_OldMode = *Mode;
D_status_obuffree = -1;
Resize_obuf(); /* Allocate memory for buffer */
@@ -2626,16 +2630,22 @@ static void disp_readev_fn(Event *event, void *data)
/* potential escape sequence */
mark = bp - 1;
D_mouse_parse.state = CSI_ESC_SEEN;
+ SetTimeout(&D_mousetimeoutev, maptimeout);
+ evenq(&D_mousetimeoutev);
}
break;
case CSI_ESC_SEEN:
if (c == '[') {
/* continue buffering an escape sequence */
D_mouse_parse.state = CSI_BEGIN;
+ evdeq(&D_mousetimeoutev);
+ SetTimeout(&D_mousetimeoutev, maptimeout);
+ evenq(&D_mousetimeoutev);
} else
D_mouse_parse.state = CSI_INACTIVE;
break;
case CSI_BEGIN:
+ evdeq(&D_mousetimeoutev);
if (c == 'M') {
/* VT200 mouse sequence */
D_mouse_parse.state = CSI_PB;
@@ -2789,6 +2799,34 @@ static void disp_processinput(Display * display, unsigned char *buf, size_t size
(*D_processinput) ((char *)buf, size);
}
+static void disp_mousetimeout_fn(Event *event, void *data)
+{
+ unsigned char buf[2] = {'\033', '['};
+ int size = 0;
+
+ (void)event; /* unused */
+
+ display = (Display *)data;
+
+ switch (D_mouse_parse.state) {
+ case CSI_PY:
+ case CSI_PX:
+ case CSI_PB:
+ /* Do not restore */
+ break;
+ case CSI_BEGIN:
+ ++size;
+ /* fall through */
+ case CSI_ESC_SEEN:
+ ++size;
+ disp_processinput(display, buf, size);
+ break;
+ default:
+ break;
+ };
+ D_mouse_parse.state = CSI_INACTIVE;
+}
+
static void disp_status_fn(Event *event, void *data)
{
(void)event; /* unused */
diff --git a/src/display.h b/src/display.h
index 531b9c8..a6ea092 100644
--- a/src/display.h
+++ b/src/display.h
@@ -186,6 +186,7 @@ struct Display {
Event d_idleev; /* screen blanker */
pid_t d_blankerpid;
Event d_blankerev;
+ Event d_mousetimeoutev; /* mouse sequence timeout event */
};
#define DISPLAY(x) display->x
@@ -301,6 +302,7 @@ struct Display {
#define D_idleev DISPLAY(d_idleev)
#define D_blankerev DISPLAY(d_blankerev)
#define D_blankerpid DISPLAY(d_blankerpid)
+#define D_mousetimeoutev DISPLAY(d_mousetimeoutev)
#define GRAIN 4096 /* Allocation grain size for output buffer */
diff --git a/src/process.c b/src/process.c
index c3dcdfc..129e2dc 100644
--- a/src/process.c
+++ b/src/process.c
@@ -145,7 +145,7 @@ struct action dmtab[KMAP_KEYS + KMAP_AKEYS];
struct action mmtab[KMAP_KEYS + KMAP_AKEYS];
struct kmap_ext *kmap_exts;
int kmap_extn;
-static int maptimeout = 300;
+int maptimeout = 300;
#ifndef MAX_DIGRAPH
#define MAX_DIGRAPH 512
diff --git a/src/process.h b/src/process.h
index 873580c..d3cd77b 100644
--- a/src/process.h
+++ b/src/process.h
@@ -52,4 +52,6 @@ extern struct action umtab[];
extern struct kmap_ext *kmap_exts;
+extern int maptimeout;
+
#endif /* SCREEN_PROCESS_H */