intptr_t osEvent(ev * e) { intptr_t ret = 1; static int fullscreen = 0; switch (evType(e)) { case CVE_QUIT: g_done = 1; break; case CVE_SETCURSOR: setcursor((uint8_t*)evArg0(e), evArg1(e) >> 16, evArg1(e) & 0xffff); break; case CVE_DEFAULTCURSOR: defaultcursor(); break; case CVE_WINDOWED: if (fullscreen) { closewin(); openwin(g_nx, g_ny, g_nw, g_nh, 1); map(); fullscreen = 0; } break; case CVE_FULLSCREEN: if (!fullscreen) { savegeom(); closewin(); openwin(0, 0, DisplayWidth(g_dpy, scr()), DisplayHeight(g_dpy, scr()), 0); map(); fullscreen = 1; } break; default: ret = 0; } return ret; }
mloop() { while (!quit) { if (incmd) { docmd(); } else if (wwcurwin->ww_state != WWS_HASPROC) { if (!wwcurwin->ww_keepopen) closewin(wwcurwin); setcmd(1); if (wwpeekc() == escapec) (void) wwgetc(); error("Process died."); } else { register struct ww *w = wwcurwin; register char *p; register n; if (wwibp >= wwibq) wwiomux(); for (p = wwibp; p < wwibq && *p != escapec; p++) ; if ((n = p - wwibp) > 0) { if (!w->ww_ispty && w->ww_stopped) startwin(w); (void) write(w->ww_pty, wwibp, n); wwibp = p; } if (wwpeekc() == escapec) { (void) wwgetc(); setcmd(1); } } } }
void Seg::trim(Sequen *seq, int *leftend, int *rightend) { Sequen *win; double prob, minprob; int shift, len, i; int lend, rend; int minlen; /* fprintf(stderr, "%d %d\n", *leftend, *rightend); */ lend = 0; rend = seq->length - 1; minlen = 1; if ((seq->length-maxtrim)>minlen) minlen = seq->length-maxtrim; minprob = 1.; for (len=seq->length; len>minlen; len--) { win = openwin(seq, 0, len); i = 0; shift = TRUE; while (shift) { prob = getprob(win->state, len); if (prob<minprob) { minprob = prob; lend = i; rend = len + i - 1; } shift = shiftwin1(win); i++; } closewin(win); } /* fprintf(stderr, "%d-%d ", *leftend, *rightend); */ *leftend = *leftend + lend; *rightend = *rightend - (seq->length - rend - 1); /* fprintf(stderr, "%d-%d\n", *leftend, *rightend); */ closewin(seq); return; }
Frame::Frame(QWidget *parent) : QFrame(parent) { this->resize(Config::FrameWidth, Config::FrameHeight); this->setMinimumSize(Config::FrameWidth, Config::FrameHeight); this->setMaximumSize(Config::FrameWidth, Config::FrameHeight); this->setWindowFlags(Qt::FramelessWindowHint); this->setStyleSheet(Config::FrameStyleSheet); _titlebar = new TitleBar(this); _toolbar = new ToolBar(this); _panel = new PanelWin(this); _statebar = new StateBar(this); _layout = new QVBoxLayout(this); _layout->setSpacing(0); _layout->setMargin(0); _layout->addWidget(_titlebar); _layout->addWidget(_toolbar); _layout->addWidget(_panel); _layout->addWidget(_statebar); connect(_titlebar->_btnMin, SIGNAL(clicked()), this, SLOT(minwin())); connect(_titlebar->_btnClose, SIGNAL(clicked()), this, SLOT(closewin())); connect(_toolbar->_btnKey, SIGNAL(clicked()), _panel, SLOT(selectKey())); connect(_toolbar->_btnCust, SIGNAL(clicked()), _panel, SLOT(selectCust())); connect(_panel->_btnExtractStart, SIGNAL(clicked()), this, SLOT(extractStart())); connect(_panel->_btnExtractCancel, SIGNAL(clicked()), this, SLOT(extractCancel())); connect(_panel->_btnSearchBrowse, SIGNAL(clicked()), this, SLOT(openFolder())); connect(_panel->_btnSearchStart, SIGNAL(clicked()), this, SLOT(searchStart())); connect(_panel->_btnSearchCancel, SIGNAL(clicked()), this, SLOT(searchCancel())); connect(_panel->_btnClearLogs, SIGNAL(clicked()), this, SLOT(clearLogs())); connect(_panel->_btnBackupBrowse, SIGNAL(clicked()), this, SLOT(openFolder())); connect(_panel->_btnBackupStart, SIGNAL(clicked()), this, SLOT(backupStart())); connect(_panel->_btnBackupCancel, SIGNAL(clicked()), this, SLOT(backupCancel())); _panel->_btnSearchCancel->setEnabled(false); _panel->_btnBackupCancel->setEnabled(false); _panel->_btnClearLogs->setEnabled(false); }
/* * Open a user window. */ struct ww * openwin(int id, int row, int col, int nrow, int ncol, int nline, char *label, int type, int uflags, char *shf, char **sh) { struct ww *w; if (id < 0 && (id = findid()) < 0) return 0; if (row + nrow <= 0 || row > wwnrow - 1 || col + ncol <= 0 || col > wwncol - 1) { error("Illegal window position."); return 0; } w = wwopen(type, 0, nrow, ncol, row, col, nline); if (w == 0) { error("Can't open window: %s.", wwerror()); return 0; } w->ww_id = id; window[id] = w; CLR(w->ww_uflags, WWU_ALLFLAGS); SET(w->ww_uflags, uflags); w->ww_alt = w->ww_w; if (label != 0 && setlabel(w, label) < 0) error("No memory for label."); wwcursor(w, 1); /* * We have to do this little maneuver to make sure * addwin() puts w at the top, so we don't waste an * insert and delete operation. */ setselwin((struct ww *)0); addwin(w, 0); setselwin(w); if (wwspawn(w, shf, sh) < 0) { error("Can't execute %s: %s.", shf, wwerror()); closewin(w); return 0; } return w; }
double* Seg::seqent(Sequen *seq) { Sequen *win; double *H; int i, first, last; if (window>seq->length) { return((double *) NULL); } H = (double *) malloc(seq->length*sizeof(double)); for (i=0; i<seq->length; i++) { H[i] = -1.; } win = openwin(seq, 0, window); enton(win); first = downset; last = seq->length - upset; for (i=first; i<=last; i++) { if (seq->punctuation && hasdash(win)) { H[i] = -1; shiftwin1(win); continue; } H[i] = win->entropy; shiftwin1(win); } closewin(win); return(H); }
int cvrun(int argc, char ** argv) { int attr[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DEPTH_SIZE, 1, None}; XVisualInfo * vi; g_dpy = XOpenDisplay(0); g_xim = XOpenIM(g_dpy, 0, 0, 0); cvInject(CVE_INIT, 0, 0); openwin(cvInject(CVQ_XPOS, 0, 0), cvInject(CVQ_YPOS, 0, 0), cvInject(CVQ_WIDTH, 0, 0), cvInject(CVQ_HEIGHT, 0, 0), 1); vi = glXChooseVisual(g_dpy, scr(), attr); g_ctx = glXCreateContext(g_dpy, vi, 0, True); XFree(vi); map(); ((int(*)(int))glXGetProcAddress((GLubyte*)"glXSwapIntervalSGI"))(1); cvInject(CVE_GLINIT, 0, 0); while (!g_done) { XEvent e; if (XCheckWindowEvent(g_dpy, g_win, EVMASK, &e) || XCheckTypedWindowEvent(g_dpy, g_win, ClientMessage, &e)) handle(g_dpy, g_win, g_xic, &e); glXSwapBuffers(g_dpy, g_win); cvInject(CVE_UPDATE, 0, 0); } cvInject(CVE_GLTERM, 0, 0); closewin(); glXDestroyContext(g_dpy, g_ctx); XCloseIM(g_xim); XCloseDisplay(g_dpy); return cvInject(CVE_TERM, 0, 0); }
void Seg::segseq(Sequen *seq, Segment **segs, int offset) { Segment *seg, *leftsegs; Sequen *leftseq; int first, last, lowlim; int loi, hii, i; int leftend, rightend, lend, rend; double *H; H = seqent(seq); if (H==NULL) return; first = downset; last = seq->length - upset; lowlim = first; for (i=first; i<=last; i++) { if (H[i]<=locut && H[i]!=-1) { loi = findlo(i, lowlim, H); hii = findhi(i, last, H); leftend = loi - downset; rightend = hii + upset - 1; //rightend = hii + upset; trim(openwin(seq, leftend, rightend-leftend+1), &leftend, &rightend); if (i+upset-1<leftend) /* check for trigger window in left trim */ { lend = loi - downset; rend = leftend - 1; leftseq = openwin(seq, lend, rend-lend+1); leftsegs = (Segment *) NULL; segseq(leftseq, &leftsegs, offset+lend); if (leftsegs!=NULL) { if (*segs==NULL) *segs = leftsegs; else appendseg(*segs, leftsegs); } closewin(leftseq); } seg = (Segment *) malloc(sizeof(Segment)); seg->begin = leftend + offset; seg->end = rightend + offset; seg->next = (Segment *) NULL; if (*segs==NULL) *segs = seg; else appendseg(*segs, seg); i = min(hii, rightend+downset); lowlim = i + 1; } } free(H); return; }
void docmd(void) { int c; struct ww *w; char out = 0; while (!out && !quit) { if ((c = wwgetc()) < 0) { if (terse) wwsetcursor(0, 0); else { wwputs("Command: ", cmdwin); wwcurtowin(cmdwin); } do wwiomux(); while ((c = wwgetc()) < 0); } if (!terse) wwputc('\n', cmdwin); switch (c) { default: if (c != escapec) break; case 'h': case 'j': case 'k': case 'l': case 'y': case 'p': case ctrl('y'): case ctrl('e'): case ctrl('u'): case ctrl('d'): case ctrl('b'): case ctrl('f'): case ctrl('s'): case ctrl('q'): case ctrl('['): if (selwin == 0) { error("No window."); continue; } } switch (c) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if ((w = window[c - '1']) == 0) { error("%c: No such window.", c); break; } setselwin(w); if (checkproc(selwin) >= 0) out = 1; break; case '%': if ((w = getwin()) != 0) setselwin(w); break; case ctrl('^'): if (lastselwin != 0) { setselwin(lastselwin); if (checkproc(selwin) >= 0) out = 1; } else error("No previous window."); break; case 'c': if ((w = getwin()) != 0) closewin(w); break; case 'w': c_window(); break; case 'm': if ((w = getwin()) != 0) c_move(w); break; case 'M': if ((w = getwin()) != 0) movewin(w, w->ww_alt.t, w->ww_alt.l); break; case 's': if ((w = getwin()) != 0) c_size(w); break; case 'S': if ((w = getwin()) != 0) sizewin(w, w->ww_alt.nr, w->ww_alt.nc); break; case 'y': c_yank(); break; case 'p': c_put(); break; case ':': c_colon(); break; case 'h': (void) wwwrite(selwin, "\b", 1); break; case 'j': (void) wwwrite(selwin, "\n", 1); break; case 'k': (void) wwwrite(selwin, "\033A", 2); break; case 'l': (void) wwwrite(selwin, "\033C", 2); break; case ctrl('e'): wwscroll(selwin, 1); break; case ctrl('y'): wwscroll(selwin, -1); break; case ctrl('d'): wwscroll(selwin, selwin->ww_w.nr / 2); break; case ctrl('u'): wwscroll(selwin, - selwin->ww_w.nr / 2); break; case ctrl('f'): wwscroll(selwin, selwin->ww_w.nr); break; case ctrl('b'): wwscroll(selwin, - selwin->ww_w.nr); break; case ctrl('s'): stopwin(selwin); break; case ctrl('q'): startwin(selwin); break; case ctrl('l'): wwredraw(); break; case '?': c_help(); break; case ctrl('['): if (checkproc(selwin) >= 0) out = 1; break; case ctrl('z'): wwsuspend(); break; case 'q': c_quit(); break; /* debugging stuff */ case '&': if (debug) { c_debug(); break; } default: if (c == escapec) { if (checkproc(selwin) >= 0) { (void) write(selwin->ww_pty, &escapec, 1); out = 1; } } else { if (!terse) wwbell(); error("Type ? for help."); } } } if (!quit) setcmd(0); }
int checkformacs(){ short mcto=0; char temps[2048]; if(kreturn==11779){ if(wn[cwin].chan>-1)closchan(wn[cwin].chan); return 1; } if(kreturn==19200){ if(wn[cwin].cx>0){wn[cwin].cx--;return 1;} else{ if(wn[cwin].cvof==0)return 1; if(wn[cwin].cvof!=0){wn[cwin].cvof--;wn[cwin].cx=wn[cwin].ihc[wn[cwin].cvof];ipbredraw(cwin);return 1;} } return 1; } if(kreturn==19712){ if(wn[cwin].cx<wn[cwin].ihc[wn[cwin].cvof]){wn[cwin].cx++;return 1;} else{ if(wn[cwin].cx==wn[cwin].ihc[wn[cwin].cvof]){ if(wn[cwin].ihc[wn[cwin].cvof+1]){wn[cwin].cvof++;wn[cwin].cx=0;ipbredraw(cwin);return 1;} else{ return 1; } } } return 1; } if(kreturn==283){ clearipb(cwin); return 1; } if(kreturn==3849){ clearipb(cwin); strcpy(temps,"/msg "); if(lastnt){ mcto=0; lastnc++; while(!strlen(lastn[lastnc]) && mcto!=50){ lastnc++; if(lastnc==20)lastnc=0; mcto++; if(mcto==21)mcto=50; } } if(strlen(lastn[lastnc])){strcat(temps,lastn[lastnc]);strcat(temps," ");wtib(temps,1);} lastnt=20; return 1; } if(kreturn==15104){doms(0);return 1;} if(kreturn==15360){doms(1);return 1;} if(kreturn==15616){doms(2);return 1;} if(kreturn==15872){doms(3);return 1;} if(kreturn==16128){doms(4);return 1;} if(kreturn==16384){doms(5);return 1;} if(kreturn==16640){doms(6);return 1;} if(kreturn==16896){doms(7);return 1;} if(kreturn==17152){doms(8);return 1;} if(kreturn==17408){doms(9);return 1;} if(kreturn==30720 && wn[0].hand>-1){topwindow(0);return 1;} if(kreturn==30976 && wn[1].hand>-1){topwindow(1);return 1;} if(kreturn==31232 && wn[2].hand>-1){topwindow(2);return 1;} if(kreturn==31488 && wn[3].hand>-1){topwindow(3);return 1;} if(kreturn==31744 && wn[4].hand>-1){topwindow(4);return 1;} if(kreturn==32000 && wn[5].hand>-1){topwindow(5);return 1;} if(kreturn==3103){ wtib("",0); return 1; } if(kreturn==3357){ wtib("",0); return 1; } if(kreturn==10496){ wtib("",0); return 1; } if(kreturn==2832){ wtib("",0); return 1; } if(kreturn==4096){ mcto=0; while(mcto<NOFWIN) { if(cn[mcto].cn>-1){ if(form_alert(2,"[1][Still connected!|Are you sure?][No!][Yes!]")==1)return 1; mcto=NOFWIN; } mcto++; } mcto=0; while(mcto<10) { if(dcc[mcto].stat){ if(form_alert(2,"[1][DCC transfer open!|Are you sure?][No!][Yes!]")==1)return 1; mcto=10; } mcto++; } qt(); } if(kreturn==19252){ cycchan(BACKWARDS); return 1; } if(kreturn==19766){ cycchan(FORWARDS); return 1; } if(kreturn==29440){ cycwin(BACKWARDS); return 1; } if(kreturn==29696){ cycwin(FORWARDS); return 1; } if(kreturn==4375){ openwin(0,0,0,0,2); return 1; } if(kreturn==5653){ dodccsend(); return 1; } if(kreturn==4113){ disnnect(wn[cwin].cnn); return 1; } if(kreturn==12813 && cwin>-1){ closewin(cwin); return 1; } if(kreturn==6159){ sortconnection(); return 1; } return 0; }