static el_status_t h_search(void) { static int Searching; const char *old_prompt; const char *(*move)(void); const char *p; if (Searching) return el_ring_bell(); Searching = 1; clear_line(); old_prompt = rl_prompt; rl_prompt = "Search: "; tty_puts(rl_prompt); move = Repeat == NO_ARG ? prev_hist : next_hist; p = editinput(); rl_prompt = old_prompt; Searching = 0; tty_puts(rl_prompt); if (p == NULL && el_intr_pending > 0) { el_intr_pending = 0; clear_line(); return redisplay(); } p = search_hist(p, move); clear_line(); if (p == NULL) { el_ring_bell(); return redisplay(); } return do_insert_hist(p); }
mod_export void zle_resetprompt(void) { reexpandprompt(); if (zleactive) redisplay(NULL); }
/** * mouse motion handler determines the parameters of the action */ void alignMouseMotion(vector mousePos) { double lastAngle, curAngle; vector rc; /* world coordinates of rotation center */ if(moving) { /* translate by the amount the mouse was moved */ /* update the current translation */ curTransAction.x += curSensitivity*(mousePos.x-lastPos.x); curTransAction.y += curSensitivity*(mousePos.y-lastPos.y); } if(rotating) { /* rotate based on mouse motion wrt center of rotation */ /* get world coords */ rc = curRotCenter; /* get the angles in question */ lastAngle = atan2(lastPos.y-rc.y, lastPos.x-rc.x); curAngle = atan2(mousePos.y-rc.y, mousePos.x-rc.x); /* store the current rotation */ if(fabs(lastAngle-curAngle) < PI) { curRotAngle -= 180/PI * curSensitivity*(lastAngle-curAngle); } else { curRotAngle -= 180/PI * curSensitivity*(lastAngle+curAngle); } curRotAngle = fmod(curRotAngle,360.0); } lastPos = mousePos; redisplay(); }
void init_display() { int i; pcb.scale = 1.0; for (i = 0; i < pcb.layers; i++) { pcb.layer[i].canvas = GOO_CANVAS(goo_canvas_new()); gtk_object_ref(GTK_OBJECT(pcb.layer[i].canvas)); goo_canvas_set_bounds(pcb.layer[i].canvas, 0, 0, pcb.width, pcb.height); pcb.layer[i].root = goo_canvas_get_root_item(pcb.layer[i].canvas); goo_canvas_image_new(pcb.layer[i].root, pcb.layer[i].img, 0, 0, NULL); init_layer_events(pcb.layer[i].root); show_overlays(i); } pcb.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(pcb.window), 800, 600); gtk_window_set_title(GTK_WINDOW(pcb.window), pcb.filename); init_window_events(pcb.window); pcb.scrolled = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(pcb.scrolled); gtk_container_add(GTK_CONTAINER(pcb.window), pcb.scrolled); redisplay(); }
PROC scroll(bool down) { int i; if (count <= 0) count = dofscroll; strput(CURoff); if (down) { curr = min(bufmax-1, nextline(TRUE, curr, count)); i = min(bufmax-1, nextline(TRUE, pend, count)); if (i > pend) scrollforward(i); } else { curr = bseekeol(max(0,nextline(FALSE, curr, count))); i = bseekeol(max(0,nextline(FALSE, ptop, count))); if (i < ptop) if (canUPSCROLL) scrollback(i); else { ptop = i; setend(); redisplay(TRUE); } } strput(CURon); setpos(skipws(curr)); /* initialize new position - first nonwhite */ yp = setY(curr); mvcur(yp, xp); /* go there */ }
void SBookWidget::menuImport(void) { QFileDialog fd(QString::null,0,this,"Import",true); fd.setMode(QFileDialog::ExistingFile); fd.setCaption("Import"); fd.setSelection(QDir::currentDirPath()); fd.setFilters((const char **)ifilters); if(fd.exec()==QDialog::Accepted){ QString filter = fd.selectedFilter(); QString fn = fd.selectedFile(); if(access(fn.latin1(),04)){ if(QMessageBox::warning(0,"Cannot Read", "The file " + fn + " cannot be opened for reading:" + sys_errlist[errno], "OK",QString::null,QString::null)==1){ } return; // aborted } int count=0; if(filter.compare(ifilters[FILTER_XML])==0){ XML xml; statusStack->raiseWidget(progressBar); count = xml.readFile(fn,&data,0,progressBar); statusStack->raiseWidget(statusBar); if(count == -1){ QMessageBox::warning(0,"Cannot Read", "The file " + fn + " appears to be corrupt. Sorry!", "OK"); return; } } if(filter.compare(ifilters[FILTER_SBOOK_ASCII])==0){ count = data.ImportSBookASCII(fn); } if(filter.compare(ifilters[FILTER_TAB])==0){ count = data.ImportDelimited(fn,TAB_DELIM); } if(filter.compare(ifilters[FILTER_CSV])==0){ count = data.ImportDelimited(fn,CSV_DELIM); } if(filter.compare(ifilters[FILTER_IG])==0){ count = data.ImportIG(fn); } redisplay(); char buf[1024]; sprintf(buf,"Imported %d %s",count,count==1 ? "entry" : "entries"); emit alert(buf); } }
void Notification::create(const Notification::Seed& seed) { icon = seed.icon; tip = seed.tip; // TODO Allow more than one icon per window parent->setCallback(Message(message), [this](const MSG& msg, LRESULT&) { return trayHandler(msg); }); parent->setCallback(Message(taskbarMsg), [this](const MSG&, LRESULT&) { return redisplay(); }); }
//------------------------------------------------------------------------------ // reformat() -- convert the numerical value into an ascii character string //------------------------------------------------------------------------------ void NumericReadout::reformat(const char* const example) { if (reformatter->convertNumber(example) != ReformatScanner::DataType::invalid) { setExample(example); base::utStrcpy(format,FORMAT_LENGTH,reformatter->getFormat()); postSign = reformatter->isPostSign(); redisplay(); } }
//------------------------------------------------------------------------------ // reformat() -- convert the numerical value into an ascii character string //------------------------------------------------------------------------------ void OctalReadout::reformat(const char* const example) { if (reformatter->convertOctal(example) != Reformat::invalid) { setExample(example); lcStrcpy(format,FORMAT_LENGTH,reformatter->getFormat()); postSign = reformatter->isPostSign(); redisplay(); } }
// react to mouse button presses void mouse(int button, int state, int x, int y) { if (state) mgr->mouseButtonRelease(button, x, y); else mgr->mouseButtonPress(button, x, y); redisplay(); }
/** * mouse handler determines what kind of actions are being performed */ void alignMouse(int button, int state, vector mousePos) { /* set the sensitivity */ curSensitivity = GLUT_ACTIVE_CTRL == glutGetModifiers() ? fineSensitivity : coarseSensitivity; /* choose action based on button */ switch(button) { case GLUT_LEFT_BUTTON: /* if we are setting the rotation center, set it and break */ if(settingRotCenter == TRUE) { setRotationCenterV(mousePos); if(DEBUG) fprintf(stdout,"current rotation center is (%g,%g)\n", curRotCenter.x, curRotCenter.y); settingRotCenter = FALSE; break; } /* left button: translation */ switch(state) { case GLUT_DOWN: /* translation start */ moving = TRUE; break; case GLUT_UP: /* translation end, apply it */ moving = FALSE; applyTranslation(curTransAction); curTransAction.x = curTransAction.y = 0; break; } break; case GLUT_MIDDLE_BUTTON: /* rotation */ switch(state) { case GLUT_DOWN: /* rotation start */ rotating = TRUE; break; case GLUT_UP: /* rotation end, apply rotation */ rotating = FALSE; applyRotation(curRotCenter, curRotAngle); /* reset the rot angle */ curRotAngle = 0; break; } break; } /* store the last positions for the up */ if(state == GLUT_DOWN) { lastPos = mousePos; } redisplay(); }
void Zredisplay(void) { zbuff_t *buff; wsize(); redisplay(); foreachbuff(buff) uncomment(buff); }
//------------------------------------------------------------------------------ // reformat() -- convert the numerical value into an ascii character string //------------------------------------------------------------------------------ void DirectionReadout::reformat(const char* const example) { DirMode results = reformatter->convertDirection(example); if (results != invalid) { setExample(example); lcStrcpy(format,FORMAT_LENGTH,reformatter->getFormat()); tmode = results; postSign = reformatter->isPostSign(); redisplay(); } }
/** * handles timer events */ void alignTimerEvent(int value) { /* repaint if necessary */ if(alignRepaintNeeded(glutGet(GLUT_ELAPSED_TIME))) { redisplay(); } /* draw again in the future */ if(animate) { glutTimerFunc(framePeriod, alignTimerEvent, 0); } }
static void setavar(const char *vin, bool display) { char msg[STRMAX + 1]; int i = 0; strlcpy(msg, vin, sizeof(msg)); strtok(msg, " \t"); for (i = 0; i < NUMVARS; ++i) if (strcasecmp(msg, Vars[i].vname) == 0) { do_var_match(i, vin); if (display) { if (i == VTABS || i == VCTABS || i == VSHTABS) { settabsize(Curbuff->bmode); redisplay(); } if (Vars[i].vtype == V_STRING) { if (VARSTR(i)) putpaw("%s = %s", Vars[i].vname, VARSTR(i)); else putpaw("%s = NONE", Vars[i].vname); } else putpaw("%s = %d", Vars[i].vname, VAR(i)); if (i == VCOMMENTS) redisplay(); } break; } if (i == NUMVARS) { if (display) putpaw("Variable '%s' Not Found", vin); } Arg = 0; }
// setSlotOverflowChar() --overflow character bool NumericReadout::setSlotOverflowChar(const base::String* const socobj) { bool ok = true; if (socobj != nullptr) { const char* str = *socobj; overflowChar = str[0]; redisplay(); } else { if (isMessageEnabled(MSG_ERROR)) { std::cerr << "NumericReadout::setOverflowChar \"overflowChar\" must be a character!" << std::endl; } ok = false; } return ok; }
// setSlotUndefinedChar() -- undefined value character bool NumericReadout::setSlotUndefinedChar(const Basic::String* const sucobj) { bool ok = true; if (sucobj != 0) { const char* str = *sucobj; undefinedChar = str[0]; redisplay(); } else { if (isMessageEnabled(MSG_ERROR)) { std::cerr << "NumericReadout::setUndefinedChar \"undefinedChar\" must be a character!" << std::endl; } ok = false; } return ok; }
bool EditorHandler::mouseMotion(int x, int y) { if (editors.empty()) { return false; } lastPos = vec2i(x, y); if (paint) { vec4d l = strokes[strokes.size() - 1]; vec3d p = getPosition(x, y); if ((p - vec3d(l.x, l.y, l.z)).length() > radius * 0.2) { strokes.push_back(vec4d(p.x, p.y, p.z, radius)); newStrokes++; } return true; } else { redisplay(0.0, 0.0); } return false; }
PROC zdraw(char code) { int nl = ERR, np = (count>0)?to_index(count):curr; if (movemap[code] == CR_FWD) nl = 0; else if (movemap[code] == CR_BACK) nl = LINES-1; else if (code == '.') nl = LINES / 2; if (nl >= 0) { curr = np; yp = settop(nl); redisplay(TRUE); mvcur(yp,xp); } else error(); }
void finish(code) { if (code == SIGINT) { char c; ignorf(signal(code, finish)); message("Quit? "); UpdateMesg(); ignore(read(0, &c, 1)); message(""); if ((c & 0377) != 'y') { redisplay(); return; } } if (code) { if (code == SIGHUP) ignorf(signal(code, SIG_IGN)); /* A little privacy */ if (!Crashing) { putstr("Writing modified JOVE buffers..."); Crashing++; jove_exp_p = 0; WtModBuf(); } else putstr("Complete lossage!"); } ttyset(0); Placur(LI - 1, 0); putpad(CE, 1); if (KE) putpad(KE, 1); if (VE) putpad(VE, 1); if (TE) putpad(TE, 1); flusho(); byebye(code); }
void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: case 'q': case 'Q': /* quit the program */ exit(0); break; case ' ': /* toggle between opengl and sofware rendering */ opengl_test = !opengl_test; redisplay(); break; case 'w': moveForward(); redisplay(); break; case 'a': moveLeft(); redisplay(); break; case 'd': moveRight(); redisplay(); break; case 's': moveBack(); redisplay(); break; case 'b': /* toggle bilinear interpolation of the textures */ bilerp_flag = !bilerp_flag; switchTextureFiltering(); redisplay(); default: break; } return; }
void Notification::setIcon(const IconPtr& icon_) { icon = icon_; redisplay(); }
void doisearch(int dir) { char *s, *ibuf = halloc(80), *sbuf = ibuf + FIRST_SEARCH_CHAR; int sbptr = 0, top_spot = 0, pos, sibuf = 80; int nomatch = 0, skip_line = 0, skip_pos = 0; int odir = dir, sens = zmult == 1 ? 3 : 1; int hl = histline; int cmd; int *obindtab = bindtab; static char *previous_search = NULL; static int previous_search_len = 0; clearlist = 1; strcpy(ibuf, ISEARCH_PROMPT); memcpy(ibuf + NORM_PROMPT_POS, (dir == 1) ? "fwd" : "bck", 3); remember_edits(); s = zle_get_event(hl); bindtab = mainbindtab; pos = metalen(s, cs); for (;;) { /* Remember the current values in case search fails (doesn't push). */ set_isrch_spot(top_spot, hl, pos, cs, sbptr, dir, nomatch); if (sbptr == 1 && sbuf[0] == '^') { cs = 0; nomatch = 0; statusline = ibuf + NORM_PROMPT_POS; } else if (sbptr > 0) { char *last_line = s; for (;;) { char *t; if (skip_pos) { if (dir < 0) { if (pos == 0) skip_line = 1; else pos -= 1 + (pos != 1 && s[pos-2] == Meta); } else if (sbuf[0] != '^') { if (pos >= strlen(s+1)) skip_line = 1; else pos += 1 + (s[pos] == Meta); } else skip_line = 1; skip_pos = 0; } if (!skip_line && ((sbuf[0] == '^') ? (t = metadiffer(s, sbuf + 1, sbptr - 1) < sens ? s : NULL) : (t = hstrnstr(s, pos, sbuf, sbptr, dir, sens)))) { zle_goto_hist(hl); pos = t - s; cs = ztrsub(t, s) + (dir == 1? sbptr - (sbuf[0]=='^') : 0); nomatch = 0; statusline = ibuf + NORM_PROMPT_POS; break; } hl += dir; if (!(s = zle_get_event(hl))) { if (sbptr == (int)isrch_spots[top_spot-1].len && (isrch_spots[top_spot-1].flags & ISS_FAILING)) top_spot--; get_isrch_spot(top_spot, &hl, &pos, &cs, &sbptr, &dir, &nomatch); if (!nomatch) { feep(); nomatch = 1; } s = last_line; skip_line = 0; statusline = ibuf; break; } pos = dir == 1? 0 : strlen(s); skip_line = !strcmp(last_line, s); } } else { top_spot = 0; nomatch = 0; statusline = ibuf + NORM_PROMPT_POS; } sbuf[sbptr] = '_'; statusll = sbuf - statusline + sbptr + 1; ref: refresh(); if ((cmd = getkeycmd()) < 0 || cmd == z_sendbreak) { int i; get_isrch_spot(0, &hl, &pos, &i, &sbptr, &dir, &nomatch); s = zle_get_event(hl); zle_goto_hist(hl); cs = i; break; } switch (cmd) { case z_clearscreen: clearscreen(); goto ref; case z_redisplay: redisplay(); goto ref; case z_vicmdmode: bindtab = (bindtab == mainbindtab) ? altbindtab : mainbindtab; goto ref; case z_vibackwarddeletechar: case z_backwarddeletechar: if (top_spot) get_isrch_spot(--top_spot, &hl, &pos, &cs, &sbptr, &dir, &nomatch); else feep(); if (nomatch) { statusline = ibuf; skip_pos = 1; } s = zle_get_event(hl); if (nomatch || !sbptr || (sbptr == 1 && sbuf[0] == '^')) { int i = cs; zle_goto_hist(hl); cs = i; } memcpy(ibuf + NORM_PROMPT_POS, (dir == 1) ? "fwd" : "bck", 3); continue; case z_acceptandhold: acceptandhold(); goto brk; case z_acceptandinfernexthistory: acceptandinfernexthistory(); goto brk; case z_acceptlineanddownhistory: acceptlineanddownhistory(); goto brk; case z_acceptline: acceptline(); goto brk; case z_historyincrementalsearchbackward: set_isrch_spot(top_spot++, hl, pos, cs, sbptr, dir, nomatch); if (dir != -1) dir = -1; else skip_pos = 1; goto rpt; case z_historyincrementalsearchforward: set_isrch_spot(top_spot++, hl, pos, cs, sbptr, dir, nomatch); if (dir != 1) dir = 1; else skip_pos = 1; goto rpt; case z_virevrepeatsearch: set_isrch_spot(top_spot++, hl, pos, cs, sbptr, dir, nomatch); dir = -odir; skip_pos = 1; goto rpt; case z_virepeatsearch: set_isrch_spot(top_spot++, hl, pos, cs, sbptr, dir, nomatch); dir = odir; skip_pos = 1; rpt: if (!sbptr && previous_search_len) { if (previous_search_len > sibuf - FIRST_SEARCH_CHAR - 2) { ibuf = hrealloc(ibuf, sibuf, sibuf + previous_search_len); sbuf = ibuf + FIRST_SEARCH_CHAR; sibuf += previous_search_len; } memcpy(sbuf, previous_search, sbptr = previous_search_len); } memcpy(ibuf + NORM_PROMPT_POS, (dir == 1) ? "fwd" : "bck", 3); continue; case z_sendstring: sendstring(); goto ref; case z_viquotedinsert: sbuf[sbptr] = '^'; refresh(); case z_quotedinsert: if ((c = getkey(0)) == EOF) { feep(); continue; } goto ins; default: if(cmd == z_selfinsertunmeta) { c &= 0x7f; if(c == '\r') c = '\n'; } else if (cmd == z_magicspace) c = ' '; else if (cmd != z_selfinsert) { ungetkeycmd(); if (cmd == z_sendbreak) sbptr = 0; goto brk; } ins: if (sbptr == PATH_MAX) { feep(); break; } set_isrch_spot(top_spot++, hl, pos, cs, sbptr, dir, nomatch); if (sbptr == sibuf - FIRST_SEARCH_CHAR - 2) { ibuf = hrealloc(ibuf, sibuf, sibuf * 2); sbuf = ibuf + FIRST_SEARCH_CHAR; sibuf *= 2; } sbuf[sbptr++] = c; } } brk: if (sbptr) { zfree(previous_search, previous_search_len); previous_search = zalloc(sbptr); memcpy(previous_search, sbuf, previous_search_len = sbptr); } statusline = NULL; bindtab = obindtab; }
int resetprompt(UNUSED(char **args)) { reexpandprompt(); return redisplay(NULL); }
Thingy executenamedcommand(char *prmt) { Thingy cmd, retval = NULL; int l, len, feep = 0, listed = 0, curlist = 0; int ols = (listshown && validlist), olll = lastlistlen; char *cmdbuf, *ptr; char *okeymap = ztrdup(curkeymapname); clearlist = 1; /* prmt may be constant */ prmt = ztrdup(prmt); l = strlen(prmt); cmdbuf = (char *)zhalloc(l + NAMLEN + 2 #ifdef MULTIBYTE_SUPPORT + 2 * MB_CUR_MAX #endif ); strcpy(cmdbuf, prmt); zsfree(prmt); statusline = cmdbuf; selectlocalmap(command_keymap); selectkeymap("main", 1); ptr = cmdbuf += l; len = 0; for (;;) { *ptr = '_'; ptr[1] = '\0'; zrefresh(); if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) { statusline = NULL; selectkeymap(okeymap, 1); zsfree(okeymap); if ((listshown = ols)) { showinglist = -2; lastlistlen = olll; } else if (listed) clearlist = listshown = 1; retval = NULL; goto done; } if(cmd == Th(z_clearscreen)) { clearscreen(zlenoargs); if (curlist) { int zmultsav = zmult; zmult = 1; listlist(namedcmdll); showinglist = 0; zmult = zmultsav; } } else if(cmd == Th(z_redisplay)) { redisplay(zlenoargs); if (curlist) { int zmultsav = zmult; zmult = 1; listlist(namedcmdll); showinglist = 0; zmult = zmultsav; } } else if(cmd == Th(z_viquotedinsert)) { *ptr = '^'; zrefresh(); getfullchar(0); if(LASTFULLCHAR == ZLEEOF || !LASTFULLCHAR || len >= NAMLEN) feep = 1; else { int ret = zlecharasstring(LASTFULLCHAR, ptr); len += ret; ptr += ret; curlist = 0; } } else if(cmd == Th(z_quotedinsert)) { if(getfullchar(0) == ZLEEOF || !LASTFULLCHAR || len == NAMLEN) feep = 1; else { int ret = zlecharasstring(LASTFULLCHAR, ptr); len += ret; ptr += ret; curlist = 0; } } else if(cmd == Th(z_backwarddeletechar) || cmd == Th(z_vibackwarddeletechar)) { if (len) { ptr = backwardmetafiedchar(cmdbuf, ptr, NULL); len = ptr - cmdbuf; curlist = 0; } } else if(cmd == Th(z_killregion) || cmd == Th(z_backwardkillword) || cmd == Th(z_vibackwardkillword)) { if (len) curlist = 0; while (len) { convchar_t cc; ptr = backwardmetafiedchar(cmdbuf, ptr, &cc); len = ptr - cmdbuf; if (cc == ZWC('-')) break; } } else if(cmd == Th(z_killwholeline) || cmd == Th(z_vikillline) || cmd == Th(z_backwardkillline)) { len = 0; ptr = cmdbuf; if (listed) clearlist = listshown = 1; curlist = 0; } else if (cmd == Th(z_bracketedpaste)) { char *insert = bracketedstring(); size_t inslen = strlen(insert); if (len + inslen > NAMLEN) feep = 1; else { strcpy(ptr, insert); len += inslen; ptr += inslen; if (listed) { clearlist = listshown = 1; listed = 0; } else curlist = 0; } free(insert); } else { if(cmd == Th(z_acceptline) || cmd == Th(z_vicmdmode)) { Thingy r; unambiguous: *ptr = 0; r = rthingy(cmdbuf); if (!(r->flags & DISABLED)) { unrefthingy(r); statusline = NULL; selectkeymap(okeymap, 1); zsfree(okeymap); if ((listshown = ols)) { showinglist = -2; lastlistlen = olll; } else if (listed) clearlist = listshown = 1; retval = r; goto done; } unrefthingy(r); } if(cmd == Th(z_selfinsertunmeta)) { fixunmeta(); cmd = Th(z_selfinsert); } if (cmd == Th(z_listchoices) || cmd == Th(z_deletecharorlist) || cmd == Th(z_expandorcomplete) || cmd == Th(z_completeword) || cmd == Th(z_expandorcompleteprefix) || cmd == Th(z_vicmdmode) || cmd == Th(z_acceptline) || lastchar == ' ' || lastchar == '\t') { namedcmdambig = 100; namedcmdll = newlinklist(); *ptr = '\0'; namedcmdstr = cmdbuf; scanhashtable(thingytab, 1, 0, DISABLED, scancompcmd, 0); namedcmdstr = NULL; if (empty(namedcmdll)) { feep = 1; if (listed) clearlist = listshown = 1; curlist = 0; } else if (cmd == Th(z_listchoices) || cmd == Th(z_deletecharorlist)) { int zmultsav = zmult; *ptr = '_'; ptr[1] = '\0'; zmult = 1; listlist(namedcmdll); listed = curlist = 1; showinglist = 0; zmult = zmultsav; } else if (!nextnode(firstnode(namedcmdll))) { strcpy(ptr = cmdbuf, peekfirst(namedcmdll)); len = strlen(ptr); ptr += len; if (cmd == Th(z_acceptline) || cmd == Th(z_vicmdmode)) goto unambiguous; } else { strcpy(cmdbuf, peekfirst(namedcmdll)); ptr = cmdbuf + namedcmdambig; *ptr = '_'; ptr[1] = '\0'; if (isset(AUTOLIST) && !(isset(LISTAMBIGUOUS) && namedcmdambig > len)) { int zmultsav = zmult; if (isset(LISTBEEP)) feep = 1; zmult = 1; listlist(namedcmdll); listed = curlist = 1; showinglist = 0; zmult = zmultsav; } len = namedcmdambig; } } else { if (len == NAMLEN || cmd != Th(z_selfinsert)) feep = 1; else { #ifdef MULTIBYTE_SUPPORT if (!lastchar_wide_valid) getrestchar(lastchar, NULL, NULL); if (lastchar_wide == WEOF) feep = 1; else #endif if (ZC_icntrl(LASTFULLCHAR)) feep = 1; else { int ret = zlecharasstring(LASTFULLCHAR, ptr); len += ret; ptr += ret; if (listed) { clearlist = listshown = 1; listed = 0; } else curlist = 0; } } } } if (feep) handlefeep(zlenoargs); feep = 0; } done: selectlocalmap(NULL); return retval; }
/** * align actions */ void alignAction(int action) { vector actionVector; switch(action) { case 'a': /* turn animation on or off */ if(TRUE == (animate = !animate)) { glutTimerFunc(framePeriod, alignTimerEvent, 0); } else { displayImg = 1; } redisplay(); break; case 'c': /* set the rotation center */ settingRotCenter = TRUE; break; case 'y': /* speed up the flickering */ switchPeriod -= switchPerIncrement; if(switchPeriod < 0) switchPeriod = 0; break; case 't': /* slow down the flickering */ switchPeriod += switchPerIncrement; if(switchPeriod > MAX_SWITCH_PERIOD) switchPeriod = MAX_SWITCH_PERIOD; break; case 'e': /* toggle previous slice tack display */ showPrevTacks = !showPrevTacks; redisplay(); break; case 'w': /* toggle curent slice tack display */ showCurTacks = !showCurTacks; redisplay(); break; case 'Q': displayImg = !displayImg; redisplay(); break; case 'p': /* print the action list */ case 'P': fprintf(stdout,"---------------------------------------\n"); dumpActionList(actions); fprintf(stdout,"---------------------------------------\n"); break; /* case 'r': /\* reset the position of the reference image to unmoved *\/ */ /* resetImage(); */ /* break; */ /* case 'u': /\* undo the last action *\/ */ /* case 'U': */ /* undoLastAction(); */ /* break; */ /* fine direction stuff using numeric keypad */ case '1': /* down and left */ actionVector.x = -transIncrX; actionVector.y = -transIncrY; applyTranslation(actionVector); break; case '2': /* down */ actionVector.x = 0; actionVector.y = -transIncrY; applyTranslation(actionVector); break; case '3': /* down and right */ actionVector.x = transIncrX; actionVector.y = -transIncrY; applyTranslation(actionVector); break; case '4': /* left */ actionVector.x = -transIncrX; actionVector.y = 0; applyTranslation(actionVector); break; case '6': /* right */ actionVector.x = transIncrX; actionVector.y = 0; applyTranslation(actionVector); break; case '7': /* up and left */ actionVector.x = -transIncrX; actionVector.y = transIncrY; applyTranslation(actionVector); break; case '8': /* up */ actionVector.x = 0; actionVector.y = transIncrY; applyTranslation(actionVector); break; case '9': /* up and right */ actionVector.x = transIncrX; actionVector.y = transIncrY; applyTranslation(actionVector); break; case '=': /* grow the slice */ case '+': actionVector.x = scaleIncrX; actionVector.y = scaleIncrY; applyScale(actionVector); break; case '-': /* shrink the slice */ case '_': actionVector.x = -scaleIncrX; actionVector.y = -scaleIncrY; applyScale(actionVector); break; default: break; } }
int getvisrchstr(void) { char *sbuf = halloc(80); int sptr = 1, ret = 0, ssbuf = 80; int cmd; int *obindtab = bindtab; if (visrchstr) { zsfree(visrchstr); visrchstr = NULL; } clearlist = 1; statusline = sbuf; sbuf[0] = (visrchsense == -1) ? '?' : '/'; bindtab = mainbindtab; while (sptr) { sbuf[sptr] = '_'; statusll = sptr + 1; refresh(); if ((cmd = getkeycmd()) < 0 || cmd == z_sendbreak) { ret = 0; break; } if(cmd == z_magicspace) { c = ' '; cmd = z_selfinsert; } switch(cmd) { case z_redisplay: redisplay(); break; case z_clearscreen: clearscreen(); break; case z_acceptline: case z_vicmdmode: sbuf[sptr] = 0; visrchstr = metafy(sbuf + 1, sptr - 1, META_DUP); ret = 1; sptr = 0; break; case z_backwarddeletechar: case z_vibackwarddeletechar: sptr--; break; case z_backwardkillword: case z_vibackwardkillword: while(sptr != 1 && iblank(sbuf[sptr - 1])) sptr--; if(iident(sbuf[sptr - 1])) while(sptr != 1 && iident(sbuf[sptr - 1])) sptr--; else while(sptr != 1 && !iident(sbuf[sptr - 1]) && !iblank(sbuf[sptr - 1])) sptr--; break; case z_sendstring: sendstring(); break; case z_viquotedinsert: sbuf[sptr] = '^'; refresh(); /* fall through */ case z_quotedinsert: if ((c = getkey(0)) == EOF) { feep(); break; } goto ins; case z_selfinsertunmeta: c &= 0x7f; if(c == '\r') c = '\n'; case z_selfinsert: ins: if(sptr == ssbuf - 1) { char *newbuf = halloc(ssbuf *= 2); strcpy(newbuf, sbuf); statusline = sbuf = newbuf; } sbuf[sptr++] = c; break; default: feep(); } } statusline = NULL; bindtab = obindtab; return ret; }
void idle(void) { redisplay(); }
// react to mouse motions with pressed buttons void motion(int x, int y) { mgr->mouseMove(x, y); redisplay(); }
// react to keys void keyboard(unsigned char k, int, int) { switch(k) { case 27: { #ifdef OSG_WITH_NVPERFSDK NVPMShutdown(); #endif mgr = NULL; tact = NULL; debugact = NULL; scene = NULL; mainwin = NULL; debugwin = NULL; statfg = NULL; OSG::osgExit(); exit(0); } #ifdef OSG_OLD_RENDER_ACTION case 'v': { mgr->getAction()->setVolumeDrawing( !mgr->getAction()->getVolumeDrawing()); std::cerr << "Volume Drawing: " << (mgr->getAction()->getVolumeDrawing()?"on":"off") << std::endl; } case 'z': { OSG::RenderAction *ract = dynamic_cast<OSG::RenderAction *>(mgr->getAction()); ract->setZWriteTrans(!ract->getZWriteTrans()); std::cerr << "Switch TransZWrite to " << (ract->getZWriteTrans()?"on":"off") << std::endl; } break; #endif case 'r': { initElements(); bool buseTrav = mgr->getUseTraversalAction(); buseTrav = !buseTrav; mgr->setUseTraversalAction(buseTrav); } break; #ifdef OSG_OLD_RENDER_ACTION case 'n': fprintf(stderr, "1) set s sorting to %d\n", act->getStateSorting()); act->setStateSorting(!act->getStateSorting()); fprintf(stderr, "2) set s sorting to %d\n", act->getStateSorting()); break; #endif case 'k': tact->setKeyGen(0); break; case 's': { OSG::UInt32 uiSId = OSG::SimpleSHLChunk ::getStaticClassId() & 0x000003FF; OSG::UInt32 uiTId = OSG::TextureBaseChunk::getStaticClassId() & 0x000003FF; OSG::UInt32 uiMId = OSG::MaterialChunk ::getStaticClassId() & 0x000003FF; OSG::UInt32 uiKeyGen = (uiSId) | (uiTId << 10) | (uiMId << 20); tact->setKeyGen(uiKeyGen); } break; case 'g': bGLFinish = !bGLFinish; tact->setUseGLFinish(bGLFinish); #ifdef OSG_OLD_RENDER_ACTION act->setUseGLFinish(bGLFinish); #endif break; case 'C': { OSG::Real32 cov = tact->getOcclusionCullingCoveredThreshold(); cov+=0.1f; tact->setOcclusionCullingCoveredThreshold(cov); std::cout << "Covered Threshold now: " << cov << std::endl; } break; case 'c': { OSG::Real32 cov1 = tact->getOcclusionCullingCoveredThreshold(); cov1-=0.1f; tact->setOcclusionCullingCoveredThreshold(cov1); std::cout << "Covered Threshold now: " << cov1 << std::endl; } break; case 'M': { OSG::UInt32 minFSize = tact->getOcclusionCullingMinimumFeatureSize(); minFSize+=1; tact->setOcclusionCullingMinimumFeatureSize(minFSize); std::cout << "Minimum Feature Size now: " << minFSize << std::endl; } break; case 'm': { OSG::UInt32 small1 = tact->getOcclusionCullingMinimumFeatureSize(); small1-=1; tact->setOcclusionCullingMinimumFeatureSize(small1); std::cout << "Minimum Feature Size now: " << small1 << std::endl; } break; case 'I': { OSG::UInt32 visT = tact->getOcclusionCullingVisibilityThreshold(); visT+=1; tact->setOcclusionCullingVisibilityThreshold(visT); std::cout << "Visibility Threshold now: " << visT << std::endl; } break; case 'i': { OSG::UInt32 visTa = tact->getOcclusionCullingVisibilityThreshold(); visTa-=1; tact->setOcclusionCullingVisibilityThreshold(visTa); std::cout << "Visibility Threshold now: " << visTa << std::endl; } break; case 'l': { OSG::UInt32 numLev = tact->getScreenLODNumLevels(); numLev-=1; tact->setScreenLODNumLevels(numLev); std::cout << "LOD's in use now: " << numLev << std::endl; } break; case 'L': { OSG::UInt32 numLeva = tact->getScreenLODNumLevels(); numLeva+=1; tact->setScreenLODNumLevels(numLeva); std::cout << "LOD's in use now: " << numLeva << std::endl; } break; case 'B': { OSG::UInt32 bfsz = tact->getOcclusionCullingQueryBufferSize(); bfsz+=200; tact->setOcclusionCullingQueryBufferSize(bfsz); std::cout << "Query Buffer Size now: " << bfsz << std::endl; } break; case 'b': { OSG::UInt32 bfsza = tact->getOcclusionCullingQueryBufferSize(); bfsza-=200; tact->setOcclusionCullingQueryBufferSize(bfsza); std::cout << "Query Buffer Size now: " << bfsza << std::endl; } break; case 't': { OSG::UInt32 tcount = tact->getOcclusionCullingMinimumTriangleCount(); tcount-=50; tact->setOcclusionCullingMinimumTriangleCount(tcount); std::cout << "Minimum Triangle Count now: " << tcount << std::endl; } break; case 'T': { OSG::UInt32 tcounta = tact->getOcclusionCullingMinimumTriangleCount(); tcounta+=50; tact->setOcclusionCullingMinimumTriangleCount(tcounta); std::cout << "Minimum Triangle Count now: " << tcounta << std::endl; } break; case 'H': { OSG::UInt32 mfsa = 0; OSG::Real32 sfta = 0.0f; tact->setOcclusionCullingMinimumFeatureSize(mfsa); tact->setOcclusionCullingVisibilityThreshold(mfsa); tact->setScreenLODCoverageThreshold(sfta); std::cout << "High Resolution Mode" << std::endl; } break; case 'h': { OSG::UInt32 mfs = 1000; OSG::Real32 sft = 0.15f; tact->setOcclusionCullingMinimumFeatureSize(mfs); tact->setOcclusionCullingVisibilityThreshold(mfs); tact->setScreenLODCoverageThreshold(sft); std::cout << "Low Resolution Mode" << std::endl; } break; case 'P': { OSG::Real32 cover = tact->getScreenLODCoverageThreshold(); cover+=0.001f; tact->setScreenLODCoverageThreshold(cover); std::cout << "ScreenLOD Coverage Threshold now: " << cover << std::endl; } break; case 'p': { OSG::Real32 covera = tact->getScreenLODCoverageThreshold(); covera-=0.001f; tact->setScreenLODCoverageThreshold(covera); std::cout << "ScreenLOD Coverage Threshold now: " << covera << std::endl; } break; case 'D': { OSG::Real32 user_dega = tact->getScreenLODDegradationFactor(); user_dega+=0.01f; tact->setScreenLODDegradationFactor(user_dega); std::cout << "ScreenLOD User Degradation Factor now: " << user_dega << std::endl; } break; case 'd': { OSG::Real32 user_deg = tact->getScreenLODDegradationFactor(); user_deg-=0.01f; tact->setScreenLODDegradationFactor(user_deg); std::cout << "ScreenLOD User Degradation Factor now: " << user_deg << std::endl; } break; case 'N': { OSG::Real32 coverb = tact->getScreenLODCoverageThreshold(); coverb=0.0; tact->setScreenLODCoverageThreshold(coverb); std::cout << "ScreenLOD Coverage Threshold now: " << coverb << std::endl; } break; case 'o': { tact->setOcclusionCulling(false); std::cout << "OCC Off" << std::endl; } break; case 'O': { tact->setOcclusionCulling(true); std::cout << "OCC On" << std::endl; } break; case 'f': { std::cout << "Freeze Occlusion result" << std::endl; //initElements(); mgr->setUseTraversalAction(false); // Render stuff that is visible and tested mgr->getWindow()->getPort(0)->setTravMask(0x5); } break; case 'F': { std::cout << "Unfreeze Occlusion result" << std::endl; //initElements(); mgr->setUseTraversalAction(true); mgr->getWindow()->getPort(0)->setTravMask(0xffffffff); } break; case 'W': { std::string sss = "out.osb"; OSG::SceneFileHandler::the()->write(scene, sss.c_str()); } break; #ifdef OSG_WITH_NVPERFSDK case 'e': runExperiment = true; break; #endif } redisplay(); }