ref: bfe30304a0a86efbb8dd42a0d16ab31819fd00c4
parent: 0a7518ec993f6d98d10df849cf160434f7a56b8f
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Jan 2 08:56:10 EST 2020
enable snarf as text input
--- a/demo/plan9.c
+++ b/demo/plan9.c
@@ -4,6 +4,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <thread.h>
+#include <bio.h>
#include "common.h"
static Mousectl *mctl;
@@ -21,9 +22,10 @@
{ nil, nil, CHANNOBLK},
};
int oldbuttons, b, nkey;
- char text[5];
+ char text[5], *s;
mu_Command *cmd;
mu_Context *ctx;
+ Biobuf *snarf;
USED(argc); USED(argv);
@@ -79,6 +81,13 @@
(b ? mu_input_mousedown : mu_input_mouseup)(ctx, m.xy.x, m.xy.y, MU_MOUSE_MIDDLE);
else if ((b = (m.buttons & 4)) != (oldbuttons & 4))
(b ? mu_input_mousedown : mu_input_mouseup)(ctx, m.xy.x, m.xy.y, MU_MOUSE_RIGHT);
+ if (m.buttons == 5 && (snarf = Bopen("/dev/snarf", OREAD)) != nil) {
+ if ((s = Brdstr(snarf, 0, 1)) != nil) {
+ mu_input_text(ctx, s);
+ free(s);
+ }
+ Bterm(snarf);
+ }
oldbuttons = m.buttons;
break;
--
⑨