static boolean findusedblocksvisit (hdlhashnode hnode, ptrvoid refcon) { /* 5.1.5b16: check fldontsave flag to avoid diving into guest databases, etc. */ ptrstring bsparent = (ptrstring) refcon; tyvaluerecord val = (**hnode).val; bigstring bspath; // if ((**hnode).fldontsave) //never gets saved in the database // return (true); gethashkey (hnode, bspath); if (bsparent != nil) { insertchar ('.', bspath); insertstring (bsparent, bspath); } if (val.valuetype == externalvaluetype) return (langexternalfindusedblocks ((hdlexternalvariable) val.data.externalvalue, bspath)); if (val.fldiskval) return (statsblockinuse (val.data.diskvalue, bspath)); return (true); /*continue traversal*/ } /*findusedblocksvisit*/
void edit() { extern bool_t need_redraw; int c; register char *p, *q; Prenum = 0; /* position the display and the cursor at the top of the file. */ *Topchar = *Filemem; *Curschar = *Filemem; Cursrow = Curscol = 0; do_mlines(); /* check for mode lines before starting */ updatescreen(); for ( ;; ) { /* Figure out where the cursor is based on Curschar. */ cursupdate(); if (need_redraw && !anyinput()) { updatescreen(); need_redraw = FALSE; } if (!anyinput()) windgoto(Cursrow,Curscol); c = vgetc(); if (State == NORMAL) { /* We're in the normal (non-insert) mode. */ /* Pick up any leading digits and compute 'Prenum' */ if ( (Prenum>0 && isdigit(c)) || (isdigit(c) && c!='0') ){ Prenum = Prenum*10 + (c-'0'); continue; } /* execute the command */ normal(c); Prenum = 0; } else { /* * Insert or Replace mode. */ switch (c) { case ESC: /* an escape ends input mode */ /* * If we just did an auto-indent, truncate the * line, and put the cursor back. */ if (did_ai) { Curschar->linep->s[0] = NUL; Curschar->index = 0; did_ai = FALSE; } set_want_col = TRUE; /* Don't end up on a '\n' if you can help it. */ if (gchar(Curschar) == NUL && Curschar->index != 0) dec(Curschar); /* * The cursor should end up on the last inserted * character. This is an attempt to match the real * 'vi', but it may not be quite right yet. */ if (Curschar->index != 0 && !endofline(Curschar)) dec(Curschar); State = NORMAL; msg(""); /* construct the Redo buffer */ p=Redobuff; q=Insbuff; while ( q < Insptr ) *p++ = *q++; *p++ = ESC; *p = NUL; updatescreen(); break; case CTRL('D'): /* * Control-D is treated as a backspace in insert * mode to make auto-indent easier. This isn't * completely compatible with vi, but it's a lot * easier than doing it exactly right, and the * difference isn't very noticeable. */ case BS: /* can't backup past starting point */ if (Curschar->linep == Insstart->linep && Curschar->index <= Insstart->index) { beep(); break; } /* can't backup to a previous line */ if (Curschar->linep != Insstart->linep && Curschar->index <= 0) { beep(); break; } did_ai = FALSE; dec(Curschar); if (State == INSERT) delchar(TRUE); /* * It's a little strange to put backspaces into * the redo buffer, but it makes auto-indent a * lot easier to deal with. */ *Insptr++ = BS; Ninsert++; cursupdate(); updateline(); break; case CR: case NL: if (State == REPLACE) /* DMT added, 12/89 */ delchar(FALSE); *Insptr++ = NL; Ninsert++; opencmd(FORWARD, TRUE); /* open a new line */ break; default: did_ai = FALSE; insertchar(c); break; } } } }
void edit() { int c; char *p, *q; Prenum = 0; /* position the display and the cursor at the top of the file. */ *Topchar = *Filemem; *Curschar = *Filemem; Cursrow = Curscol = 0; for ( ;; ) { /* Figure out where the cursor is based on Curschar. */ cursupdate(); windgoto(Cursrow,Curscol); c = vgetc(); if (State == NORMAL) { /* We're in the normal (non-insert) mode. */ /* Pick up any leading digits and compute 'Prenum' */ if ( (Prenum>0 && isdigit(c)) || (isdigit(c) && c!='0') ){ Prenum = Prenum*10 + (c-'0'); continue; } /* execute the command */ normal(c); Prenum = 0; } else { switch (c) { /* We're in insert mode */ case ESC: /* an escape ends input mode */ set_want_col = TRUE; /* Don't end up on a '\n' if you can help it. */ if (gchar(Curschar) == NUL && Curschar->index != 0) dec(Curschar); /* * The cursor should end up on the last inserted * character. This is an attempt to match the real * 'vi', but it may not be quite right yet. */ if (Curschar->index != 0 && !endofline(Curschar)) dec(Curschar); State = NORMAL; msg(""); *Uncurschar = *Insstart; Undelchars = Ninsert; /* Undobuff[0] = '\0'; */ /* construct the Redo buffer */ p=Redobuff; q=Insbuff; while ( q < Insptr ) *p++ = *q++; *p++ = ESC; *p = NUL; updatescreen(); break; case CTRL('D'): /* * Control-D is treated as a backspace in insert * mode to make auto-indent easier. This isn't * completely compatible with vi, but it's a lot * easier than doing it exactly right, and the * difference isn't very noticeable. */ case BS: /* can't backup past starting point */ if (Curschar->linep == Insstart->linep && Curschar->index <= Insstart->index) { beep(); break; } /* can't backup to a previous line */ if (Curschar->linep != Insstart->linep && Curschar->index <= 0) { beep(); break; } did_ai = FALSE; dec(Curschar); delchar(TRUE); Insptr--; Ninsert--; cursupdate(); updateline(); break; case CR: case NL: *Insptr++ = NL; Ninsert++; opencmd(FORWARD, TRUE); /* open a new line */ cursupdate(); updatescreen(); break; default: did_ai = FALSE; insertchar(c); break; } } } }