/* Look (builtin) for 'arg' in the context of 'v' */ void view_look (View *v, char *arg) { Bool found = false; ulong p; Range r; assert(ISBODY(v)); if( ! text_length(v->t)) return ; p = (v->sel.p0 + 1) % text_length(v->t); r = range(p, p); if(arg) { found = text_findliteralutf(v->t, &r, arg); } else if (RLEN(v->sel) ){ found = text_look(v->t, &r, v->sel); } else { found = false; } if(found){ view_show(v,r); view_select(v, r); view_setlastselection(v); } }
/* We've clicked the 'goto' button, selecting 'r' in 'v' * If this window is under external control, just send the event, * otherwise expand the selection, and 'goto' it, in the context of 'v'. */ void b3(View *v, Range r) { char *s; View *oldv; Range expanded; Data *d; View*found; /* Try to send simply expanded version to remote process */ expanded = view_expand(v, r, notaddress); if (!RLEN(expanded)) return; /* empty click nowhere -- ignore */ s = text_duputf(v->t, expanded); d = view_data(v); oldv = v; /* Send to remote process? */ if(data_sendgoto(d,expanded, s)) goto cleanup; if (view_gotofile(&v, &expanded, s)) { /* Simple file? */ r = expanded; } else if ( (found = openinclude(v,r)) ) { v = found; r = found->sel; } else if (view_literal(&v, &expanded, s)) { /* Literal? */ r = expanded; } else { /* found nothing */ goto cleanup; } view_show(v,r); view_select(v,r); view_setlastselection(v); /* warp unless b3 in the tag jumps to the body. */ if (oldv != tile_tag(view_win(v))) view_warp(v,r); cleanup: free(s); }
int main(int argc, char *argv[]) { IxpMsg m; char **oargv; char *wmiirc, *s; int i; quotefmtinstall(); fmtinstall('r', errfmt); fmtinstall('a', afmt); fmtinstall('C', Cfmt); extern int fmtevent(Fmt*); fmtinstall('E', fmtevent); wmiirc = "wmiirc"; oargv = argv; ARGBEGIN{ case 'a': address = EARGF(usage()); break; case 'r': wmiirc = EARGF(usage()); break; case 'v': print("%s", version); exit(0); case 'D': s = EARGF(usage()); m = ixp_message(s, strlen(s), 0); msg_debug(&m); break; default: usage(); break; }ARGEND; if(argc) usage(); setlocale(LC_CTYPE, ""); starting = true; initdisplay(); traperrors(true); selectinput(&scr.root, EnterWindowMask | SubstructureRedirectMask); if(traperrors(false)) fatal("another window manager is already running"); passwd = getpwuid(getuid()); user = estrdup(passwd->pw_name); init_environment(); fmtinstall('F', Ffmt); ixp_printfcall = printfcall; sock = ixp_announce(address); if(sock < 0) fatal("Can't create socket '%s': %r", address); closeexec(ConnectionNumber(display)); closeexec(sock); if(wmiirc[0]) spawn_command(wmiirc); init_traps(); init_cursors(); init_lock_keys(); ewmh_init(); xext_init(); srv.preselect = check_preselect; ixp_listen(&srv, sock, &p9srv, serve_9pcon, nil); ixp_listen(&srv, ConnectionNumber(display), nil, check_x_event, closedisplay); def.border = 1; def.colmode = Colstack; def.font = loadfont(FONT); def.incmode = ISqueeze; def.mod = Mod1Mask; strcpy(def.grabmod, "Mod1"); loadcolor(&def.focuscolor, FOCUSCOLORS); loadcolor(&def.normcolor, NORMCOLORS); disp.sel = pointerscreen(); init_screens(); root_init(); disp.focus = nil; setfocus(screen->barwin, RevertToParent); view_select("1"); scan_wins(); starting = false; view_update_all(); ewmh_updateviews(); event("FocusTag %s\n", selview->name); i = ixp_serverloop(&srv); if(i) fprint(2, "%s: error: %r\n", argv0); else event("Quit"); cleanup(); if(exitsignal) raise(exitsignal); if(execstr) { char *toks[32]; int n; n = unquote(strdup(execstr), toks, nelem(toks)-1); toks[n] = nil; execvp(toks[0], toks); fprint(2, "%s: failed to exec %q: %r\n", argv0, execstr); execvp(argv0, oargv); fatal("failed to exec myself"); } return i; }