mirror of
https://github.com/0intro/wmii
synced 2025-02-10 11:24:35 +03:00
Update event.b.
This commit is contained in:
parent
9647f7fd25
commit
c056757c7c
54
test/event.b
54
test/event.b
@ -12,9 +12,10 @@ include "bufio.m";
|
|||||||
Iobuf: import bufio;
|
Iobuf: import bufio;
|
||||||
include "lists.m";
|
include "lists.m";
|
||||||
lists: Lists;
|
lists: Lists;
|
||||||
append: import lists;
|
append, reverse: import lists;
|
||||||
include "regex.m";
|
include "regex.m";
|
||||||
regex: Regex;
|
regex: Regex;
|
||||||
|
Re: import regex;
|
||||||
include "sh.m";
|
include "sh.m";
|
||||||
sh: Sh;
|
sh: Sh;
|
||||||
|
|
||||||
@ -98,22 +99,24 @@ init(draw: ref Draw->Context, argv: list of string)
|
|||||||
line = chan of string;
|
line = chan of string;
|
||||||
spawn readlines(line, sys->fildes(0));
|
spawn readlines(line, sys->fildes(0));
|
||||||
|
|
||||||
regx := ".?";
|
relist: list of ref (Re, int);
|
||||||
vflag := 0;
|
|
||||||
|
|
||||||
argv = tl argv;
|
argv = tl argv;
|
||||||
if(hd argv == "-v") {
|
for(; argv != nil; argv = tl argv) {
|
||||||
vflag++;
|
vflag := 0;
|
||||||
argv = tl argv;
|
if(hd argv == "-v") {
|
||||||
|
argv = tl argv;
|
||||||
|
vflag = 1;
|
||||||
|
}
|
||||||
|
(re, err) := regex->compile(hd argv, 0);
|
||||||
|
if(err != nil)
|
||||||
|
raise sprint("bad regex %q: %s", hd argv, err);
|
||||||
|
relist = ref (re, vflag) :: relist;
|
||||||
}
|
}
|
||||||
if(argv != nil)
|
|
||||||
regx = hd argv;
|
relist = reverse(relist);
|
||||||
|
|
||||||
(re, err) := regex->compile(regx, 0);
|
line: for(;;) {
|
||||||
if(err != nil)
|
|
||||||
raise sprint("bad regex: %s", err);
|
|
||||||
|
|
||||||
for(;;) {
|
|
||||||
lin := <-line;
|
lin := <-line;
|
||||||
if(lin == nil)
|
if(lin == nil)
|
||||||
break;
|
break;
|
||||||
@ -121,18 +124,21 @@ init(draw: ref Draw->Context, argv: list of string)
|
|||||||
if(l == nil)
|
if(l == nil)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
(ev, end) := str->toint(hd l, 10);
|
(evn, end) := str->toint(hd l, 10);
|
||||||
if(end == nil) {
|
if(end == nil) {
|
||||||
match := regex->execute(re, lin);
|
for(rel := relist; rel != nil; rel = tl relist) {
|
||||||
if(match != nil || (match == nil && vflag)) {
|
(re, vflag) := *(hd rel);
|
||||||
print("%s", lin);
|
match := regex->execute(re, lin);
|
||||||
for(; l != nil; l = tl l) {
|
if((match == nil) != vflag)
|
||||||
(k, v) := str->splitstrr(hd l, "=");
|
continue line;
|
||||||
if(ishex(v)) {
|
}
|
||||||
(name, ok) := readfile(sprint("/mnt/wmii/client/%s/props", v));
|
print("%s", lin);
|
||||||
if(ok)
|
for(; l != nil; l = tl l) {
|
||||||
print("%d %s%s\n", ev, k, name);
|
(k, v) := str->splitstrr(hd l, "=");
|
||||||
}
|
if(ishex(v)) {
|
||||||
|
(name, ok) := readfile(sprint("/mnt/wmii/client/%s/props", v));
|
||||||
|
if(ok)
|
||||||
|
print("%d %s%s\n", evn, k, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user