ref: d928a6f23979bd0c91a5a192f23911f958c91a09
parent: 01afe9328b3ddf51c1ab2725684fc542bc81f76c
parent: eccb144a715d348076904da1a1890ec71f8d6d7f
author: cinap_lenrek <[email protected]>
date: Sun Dec 6 15:55:27 EST 2015
merge
--- a/sys/man/1/winwatch
+++ b/sys/man/1/winwatch
@@ -22,6 +22,9 @@
DEL
quits
.IR winwatch .
+Typing
+.B l
+and selecting a window by left click prompts for a new label.
.PP
If the
.B -e
--- a/sys/src/cmd/winwatch.c
+++ b/sys/src/cmd/winwatch.c
@@ -1,6 +1,7 @@
#include <u.h>
#include <libc.h>
#include <draw.h>
+#include <cursor.h>
#include <event.h>
#include <regexp.h>
#include <keyboard.h>
@@ -267,7 +268,54 @@
return 1;
}
+Cursor crosscursor = {
+ {-7, -7},
+ {0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0,
+ 0x03, 0xC0, 0x03, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0xC0, 0x03, 0xC0,
+ 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, },
+ {0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80,
+ 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x7F, 0xFE,
+ 0x7F, 0xFE, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80,
+ 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, }
+};
+
void
+chlabel(void)
+{
+ Mouse m;
+ char buf[512], fname[128];
+ int i, n, fd;
+
+ esetcursor(&crosscursor);
+ do
+ m = emouse();
+ while((m.buttons & 7) == 0);
+ do
+ m = emouse();
+ while((m.buttons & 7) == 1);
+ esetcursor(nil);
+ if((m.buttons & 7) != 0)
+ return;
+ for(i=0; i<nwin; i++)
+ if(ptinrect(m.xy, win[i].r))
+ break;
+ if(i == nwin)
+ return;
+ buf[0] = 0;
+ n = eenter("label?", buf, sizeof(buf), &m);
+ if(n <= 0)
+ return;
+ sprint(fname, "/dev/wsys/%d/label", win[i].n);
+ if((fd = open(fname, OWRITE)) < 0)
+ return;
+ write(fd, buf, n);
+ close(fd);
+ refreshwin();
+ redraw(screen, 1);
+}
+
+void
usage(void)
{
fprint(2, "usage: winwatch [-e exclude] [-f font]\n");
@@ -321,6 +369,8 @@
case Ekeyboard:
if(e.kbdc==Kdel || e.kbdc=='q')
exits(0);
+ if(e.kbdc == 'l')
+ chlabel();
break;
case Emouse:
if(click(e.mouse) == 0)