commit a4e59b37021326e304c311825ba52a52b02bd9c0 from: Fazlul Shahriar via: Dan Cross date: Tue Jan 07 20:02:01 2020 UTC 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 commit - cf6b778799edf4ebc2331d12707e66e7d38331ea commit + a4e59b37021326e304c311825ba52a52b02bd9c0 blob - e0e5aad7172a5352b12c80a18712793875156984 blob + b070613984a80941866a152ce677e6a920ee679d --- man/man1/9term.1 +++ man/man1/9term.1 @@ -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 by plumbing the file and line information in a compiler's diagnostic. .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 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, blob - 107afed3f4ce1af5b4f0fb7c3fe653e49b2aa3a6 blob + 81c39a6354f18e713972037b850d8ac5c4dceda3 --- src/cmd/9term/9term.c +++ src/cmd/9term/9term.c @@ -288,6 +288,7 @@ enum Paste, Snarf, Plumb, + Look, Send, Scroll, Cook @@ -298,6 +299,7 @@ char *menu2str[] = { "paste", "snarf", "plumb", + "look", "send", "cook", "scroll", @@ -346,6 +348,10 @@ button2menu(Window *w) case Plumb: wplumb(w); + break; + + case Look: + wlook(w); break; case Send: blob - c1af6592aba1f4a36e97beecb741ef30d9935939 blob + 25270a0e38f32451a80d32f93e6cc149c3986c14 --- src/cmd/9term/dat.h +++ src/cmd/9term/dat.h @@ -177,6 +177,7 @@ void wmousectl(Window*); 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); blob - 7dc204435f2bc98247b9c85c4507f3badeae49e6 blob + d47e84674c6e3b28ac53d6cbd0cf66ccc596e365 --- src/cmd/9term/wind.c +++ src/cmd/9term/wind.c @@ -907,6 +907,31 @@ winborder(Window *w, Point xy) } 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 wmousectl(Window *w) { int but;