diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-12-06 20:55:27 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-12-06 20:55:27 +0100 |
commit | d928a6f23979bd0c91a5a192f23911f958c91a09 (patch) | |
tree | 083d6dd897455a659043c2c018ab1bf0f319a943 | |
parent | 01afe9328b3ddf51c1ab2725684fc542bc81f76c (diff) | |
parent | eccb144a715d348076904da1a1890ec71f8d6d7f (diff) | |
download | plan9front-d928a6f23979bd0c91a5a192f23911f958c91a09.tar.xz |
merge
-rw-r--r-- | sys/man/1/winwatch | 3 | ||||
-rw-r--r-- | sys/src/cmd/winwatch.c | 50 |
2 files changed, 53 insertions, 0 deletions
diff --git a/sys/man/1/winwatch b/sys/man/1/winwatch index 46183dcc3..013439678 100644 --- a/sys/man/1/winwatch +++ b/sys/man/1/winwatch @@ -22,6 +22,9 @@ or DEL quits .IR winwatch . +Typing +.B l +and selecting a window by left click prompts for a new label. .PP If the .B -e diff --git a/sys/src/cmd/winwatch.c b/sys/src/cmd/winwatch.c index 8a68f1d58..21922f386 100644 --- 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,6 +268,53 @@ click(Mouse m) 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) { @@ -321,6 +369,8 @@ main(int argc, char **argv) case Ekeyboard: if(e.kbdc==Kdel || e.kbdc=='q') exits(0); + if(e.kbdc == 'l') + chlabel(); break; case Emouse: if(click(e.mouse) == 0) |