ref: 7c503e6f49b140a99535c317092cc2f32d2a7140
parent: 784e6ff8cd431e80800e0d7b0a4c5f3b385d8d89
author: cinap_lenrek <[email protected]>
date: Sat Jan 11 05:14:35 EST 2014
rio: implement "look" (thanks lf94)
--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -210,6 +210,7 @@
void wmovemouse(Window*, Point);
void wpaste(Window*);
void wplumb(Window*);
+void wlook(Window*);
void wrefresh(Window*, Rectangle);
void wrepaint(Window*);
void wresize(Window*, Image*, int);
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -62,6 +62,7 @@
Paste,
Snarf,
Plumb,
+ Look,
Send,
Scroll,
};
@@ -71,6 +72,7 @@
[Paste] "paste",
[Snarf] "snarf",
[Plumb] "plumb",
+ [Look] "look",
[Send] "send",
[Scroll] "scroll",
nil
@@ -814,6 +816,10 @@
case Plumb:
wplumb(w);
+ break;
+
+ case Look:
+ wlook(w);
break;
case Send:
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -889,6 +889,28 @@
plumbfree(m);
}
+void
+wlook(Window *w)
+{
+ int i, n, e;
+
+ i = w->q1;
+ n = i - w->q0;
+ e = w->nr - n;
+ if(n <= 0 || e < n)
+ return;
+
+ while(runestrncmp(w->r+w->q0, w->r+i, n) != 0){
+ if(i < e)
+ i++;
+ else
+ i = 0;
+ }
+
+ wsetselect(w, i, i+n);
+ wshow(w, i);
+}
+
int
winborder(Window *w, Point xy)
{