void gr_iplot(struct plot *plot) { struct dbcomm *db; int dontpop; /* So we don't pop w/o push. */ char buf[30]; hit = 0; for (db = dbs; db; db = db->db_next) { if (db->db_type == DB_IPLOT || db->db_type == DB_IPLOTALL) { if (db->db_graphid) PushGraphContext(FindGraph(db->db_graphid)); set(plot, db, FALSE, VF_PLOT); dontpop = 0; if (iplot(plot, db->db_graphid)) { /* graph just assigned */ db->db_graphid = currentgraph->graphid; dontpop = 1; } set(plot, db, TRUE, VF_PLOT); if (!dontpop && db->db_graphid) PopGraphContext(); } else if (db->db_type == DB_TRACENODE || db->db_type == DB_TRACEALL) { struct dvec *v, *u; int len; set(plot, db, FALSE, VF_PRINT); len = plot->pl_scale->v_length; dontpop = 0; for (v = plot->pl_dvecs; v; v = v->v_next) { if (v->v_flags & VF_PRINT) { u = plot->pl_scale; if (len <= 1 || hit <= 0 || hit2 < 0) { if (len <= 1 || hit2 < 0) term_clear(); else term_home(); hit = 1; hit2 = 1; printf( "\tExecution trace (remove with the \"delete\" command)"); term_cleol(); printf("\n"); if (u) { printf("%12s:", u->v_name); if (isreal(u)) { printf("%s", getitright(buf, u->v_realdata[len - 1])); } else { /* MW. Complex data here, realdata is NULL (why someone use realdata here again) */ printf("%s", getitright(buf, u->v_compdata[len - 1].cx_real)); printf(", %s", getitright(buf, u->v_compdata[len - 1].cx_imag)); } term_cleol(); printf("\n"); } } if (v == u) continue; printf("%12s:", v->v_name); if (isreal(v)) { printf("%s", getitright(buf, v->v_realdata[len - 1])); } else { /* MW. Complex data again */ printf("%s", getitright(buf, v->v_compdata[len - 1].cx_real)); printf(", %s", getitright(buf, v->v_compdata[len - 1].cx_imag)); } term_cleol(); printf("\n"); } } set(plot, db, TRUE, VF_PRINT); } } }
/* ----------------------------------------------------------------------- */ int term_read(int fd, char *buf, unsigned int len) { char c; int ret; static unsigned long remain; if(remain) { check_remain: if(len > remain) len = remain; byte_copy(buf, len, &term_cmdline.s[term_cmdline.len - remain]); remain -= len; if(!remain) { tcsetattr(fd, TCSANOW, &term_tcattr); stralloc_zero(&term_cmdline); } return len; } /* tcsetattr(fd, TCSANOW, &term_tcattr);*/ term_attr(term_input.fd, 1); prompt_show(); while((ret = buffer_getc(&term_input, &c)) > 0) { switch(c) { /* control-c discards the current line */ case 3: stralloc_zero(&term_cmdline); /* newline */ case '\n': term_newline(); remain = term_cmdline.len; goto check_remain; /* control-a is HOME */ case 1: term_home(); break; /* control-e is END */ case 5: term_end(); break; /* control-d is EOF */ case 4: if(!term_cmdline.len) { buffer_puts(term_output, "EOF"); buffer_putnlflush(term_output); ret = 0; goto fail; } break; /* do the ANSI codes */ case '\033': term_ansi(); break; /* backspace */ case 127: case '\b': term_backspace(); break; /* printable chars */ case '\t': c = ' '; default: if(term_insert) term_insertc(c); else term_overwritec(c); break; } } fail: return ret; }