9term: add a "look" menu item (#299)
Add a menu item which functions similar to acme's `Look` command. This is copied from 9front. See: https://code.9front.org/hg/plan9front/rev/1f1596dbca51 https://code.9front.org/hg/plan9front/rev/d2de1d2f7b48
This commit is contained in:
parent
cf6b778799
commit
a4e59b3702
4 changed files with 39 additions and 0 deletions
|
|
@ -285,6 +285,13 @@ containing the selection (typing cursor).
|
||||||
A typical use of this feature is to tell the editor to find the source of an error
|
A typical use of this feature is to tell the editor to find the source of an error
|
||||||
by plumbing the file and line information in a compiler's diagnostic.
|
by plumbing the file and line information in a compiler's diagnostic.
|
||||||
.PP
|
.PP
|
||||||
|
The
|
||||||
|
.B look
|
||||||
|
menu item searches forward for the contents of the selection within
|
||||||
|
the window. If a match is found, it becomes the new selection and the
|
||||||
|
window scrolls to display it. The search wraps around to the beginning
|
||||||
|
of the windows if the end of the window is reached.
|
||||||
|
.PP
|
||||||
For systems without a three-button mouse, the keyboard modifier
|
For systems without a three-button mouse, the keyboard modifier
|
||||||
keys can be used to modify the effect of the main mouse button.
|
keys can be used to modify the effect of the main mouse button.
|
||||||
On Unix systems, the Control key changes the main button to button 2,
|
On Unix systems, the Control key changes the main button to button 2,
|
||||||
|
|
|
||||||
|
|
@ -288,6 +288,7 @@ enum
|
||||||
Paste,
|
Paste,
|
||||||
Snarf,
|
Snarf,
|
||||||
Plumb,
|
Plumb,
|
||||||
|
Look,
|
||||||
Send,
|
Send,
|
||||||
Scroll,
|
Scroll,
|
||||||
Cook
|
Cook
|
||||||
|
|
@ -298,6 +299,7 @@ char *menu2str[] = {
|
||||||
"paste",
|
"paste",
|
||||||
"snarf",
|
"snarf",
|
||||||
"plumb",
|
"plumb",
|
||||||
|
"look",
|
||||||
"send",
|
"send",
|
||||||
"cook",
|
"cook",
|
||||||
"scroll",
|
"scroll",
|
||||||
|
|
@ -348,6 +350,10 @@ button2menu(Window *w)
|
||||||
wplumb(w);
|
wplumb(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Look:
|
||||||
|
wlook(w);
|
||||||
|
break;
|
||||||
|
|
||||||
case Send:
|
case Send:
|
||||||
riogetsnarf();
|
riogetsnarf();
|
||||||
wsnarf(w);
|
wsnarf(w);
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ void wmousectl(Window*);
|
||||||
void wmovemouse(Window*, Point);
|
void wmovemouse(Window*, Point);
|
||||||
void wpaste(Window*);
|
void wpaste(Window*);
|
||||||
void wplumb(Window*);
|
void wplumb(Window*);
|
||||||
|
void wlook(Window*);
|
||||||
void wrefresh(Window*, Rectangle);
|
void wrefresh(Window*, Rectangle);
|
||||||
void wrepaint(Window*);
|
void wrepaint(Window*);
|
||||||
void wresize(Window*, Image*, int);
|
void wresize(Window*, Image*, int);
|
||||||
|
|
|
||||||
|
|
@ -906,6 +906,31 @@ winborder(Window *w, Point xy)
|
||||||
return ptinrect(xy, w->screenr) && !ptinrect(xy, insetrect(w->screenr, wscale(w, Selborder)));
|
return ptinrect(xy, w->screenr) && !ptinrect(xy, insetrect(w->screenr, wscale(w, Selborder)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
if(i > e)
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wmousectl(Window *w)
|
wmousectl(Window *w)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue