int calc_node_action::program_ (int n) { switch (status) { case TOP_DOWN: emitstr (n, "\t\tPROGRAM %s\n");break; case PASS_OVER: break; case BOTTOM_UP: emitstr (n, "\t\tEND PROGRAM %s\n"); break; } return 1; // OK }
int calc_node_action::if_ (int n) { switch (status) { case TOP_DOWN: emitstr (n, "if&0:\n"); break; case PASS_OVER: break; case BOTTOM_UP: emitstr (n, "endif&0:\n"); break; } return 1; // OK }
int calc_node_action::goal_ (int n) { // int a = nact_arg [node[n].prod]; // Get first node action argument. switch (status) { case TOP_DOWN: emitstr (n, "\t\tSTART\n"); break; case PASS_OVER: break; case BOTTOM_UP: emitstr (n, "\t\tEOF\n"); break; } return 1; // OK }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget window; QLabel *label = new QLabel(QApplication::translate("windowlayout", "Scale:"),&window); QCheckBox *chb = new QCheckBox(QApplication::translate("windowlayout", "Calc mode"),&window); mle *myline = new mle(&window); render widget(&window); QPainter painter; QSlider *spinbox = new QSlider(Qt::Horizontal,&window); spinbox->setValue(30); widget.setGeometry(10,10, 512, 512); myline->setGeometry(10,532,512,20); myline->setText("Enter expession"); myline->createStandardContextMenu(); myline->selectAll(); label->setGeometry(532,10,200,20); chb->move(532,535); spinbox->setGeometry(567,10,165,20); spinbox->setRange(1, 200); //Святое место определения механизма сигналов и слотов, унёсший 8 дней практики на реализацию передачи значений между экземплярами класса //изменять с осторожностью и благословлением, церковная зона QObject::connect(spinbox, SIGNAL(valueChanged(int)), &widget, SLOT(scale(int))); QObject::connect(spinbox, SIGNAL(valueChanged(int)), myline, SLOT(emitsig())); QObject::connect(myline, SIGNAL(returnPressed()), myline, SLOT(emitsig())); QObject::connect(myline, SIGNAL(givechar(QString)), &widget, SLOT(calc(QString))); QObject::connect(chb, SIGNAL(stateChanged(int)), &widget, SLOT(chk(int))); QObject::connect(&widget, SIGNAL(emitstr(QString)), myline, SLOT(takestr(QString))); //конец защищенной церковной зоны window.setWindowTitle( QApplication::translate("GCPLOT", "GCPLOT")); window.setFixedSize(742, 562); window.show(); return app.exec(); }
int calc_node_action::else_ (int n) { switch (status) { case TOP_DOWN: emitstr (n, "\t\tBR Z endif&1 \nelse&1:\n"); break; case PASS_OVER: break; case BOTTOM_UP: break; } return 1; // OK }
int calc_node_action::div_ (int n) { switch (status) { case TOP_DOWN: break; case PASS_OVER: break; case BOTTOM_UP: emitstr (n, "\t\tDIV\n"); break; } return 1; // OK }
int calc_node_action::emit (int n) { int a; // Get string for this status (0 = TOP_DOWN, 1 = PASS_OVER, 2 = BOTTOM_UP). a = nact_arg [node[n].prod] + status; // Has to be a valid number, always have 3 arguments. if (arg_numb[a] >= 0) // If current arg_numb not -1 (empty). { emitstr (n, arg_text [arg_numb[a]]); } return 1; // OK }
void emithtmlchar(int r) { static char buf[10]; int i; i = lookup(r, htmlchars, nelem(htmlchars)); if(i >= 0) emitstr(htmlchars[i].name); else emit(r); }
void process(Biobuf *b, char *name) { int c, r, v, i; char *p; cno = 0; prevlineH = res; filename = name; for(;;){ c = getc(b); switch(c){ case Beof: /* go to ground state */ attr = 0; emit('\n'); return; case '\n': break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': v = c-'0'; c = getc(b); if(c<'0' || '9'<c) sysfatal("illegal character motion at %s:#%d", filename, cno); v = v*10 + (c-'0'); hp += v; /* fall through to character case */ case 'c': indent(); r = getc(b); emithtmlchar(r); break; case 'D': /* draw line; ignore */ do c = getc(b); while(c!='\n' && c!= Beof); break; case 'f': v = setnum(b, "font", 0, Nfont); switchfont(v); break; case 'h': v = setnum(b, "hpos", -20000, 20000); /* generate spaces if motion is large and within a line */ if(!atnewline && v>2*72) for(i=0; i<v; i+=72) emitstr(" "); hp += v; break; case 'n': setnum(b, "n1", -10000, 10000); //Bprint(&bout, " N1=%d", v); getc(b); /* space separates */ setnum(b, "n2", -10000, 10000); atnewline = 1; if(!didP && hp < (Wid-1)*res) /* if line is less than 19" long, probably need a line break */ emitstr("<br>"); emit('\n'); break; case 'p': page = setnum(b, "ps", -10000, 10000); break; case 's': ps = setnum(b, "ps", 1, 1000); break; case 'v': vp += setnum(b, "vpos", -10000, 10000); /* BUG: ignore motion */ break; case 'x': xcmd(b); break; case 'w': emit(' '); break; case 'C': indent(); p = getstr(b); emitstr(troffchar(p)); break; case 'H': hp = setnum(b, "hpos", 0, 20000); //Bprint(&bout, " H=%d ", hp); break; case 'V': vp = setnum(b, "vpos", 0, 10000); break; default: fprint(2, "dhtml: unknown directive %c(0x%.2ux) at %s:#%d\n", c, c, filename, cno); return; } } }
void xcmd(Biobuf *b) { char *p, *fld[16], buf[1024]; int i, nfld; p = getline(b); if(p == nil) sysfatal("xcmd error: %r"); if(debug) fprint(2, "x command '%s'\n", p); nfld = tokenize(p, fld, nelem(fld)); if(nfld == 0) return; switch(fld[0][0]){ case 'f': /* mount font */ if(nfld != 3) break; i = atoi(fld[1]); if(i<0 || Nfont<=i) sysfatal("font %d out of range at %s:#%d", i, filename, cno); mountfont(i, fld[2]); return; case 'i': /* init */ return; case 'r': if(nfld<2 || atoi(fld[1])!=res) sysfatal("typesetter has unexpected resolution %s", fld[1]? fld[1] : "<unspecified>"); return; case 's': /* stop */ return; case 't': /* trailer */ return; case 'T': if(nfld!=2 || strcmp(fld[1], "utf")!=0) sysfatal("output for unknown typesetter type %s", fld[1]); return; case 'X': if(nfld<3 || strcmp(fld[1], "html")!=0) break; /* is it a man reference of the form cp(1)? */ /* X manref start/end cp (1) */ if(nfld==6 && strcmp(fld[2], "manref")==0){ /* was the right macro; is it the right form? */ if(strlen(fld[5])>=3 && fld[5][0]=='(' && fld[5][2]==')' && '0'<=fld[5][1] && fld[5][1]<='9'){ if(strcmp(fld[3], "start") == 0){ /* set anchor attribute and remember string */ attr |= (1<<Anchor); snprint(buf, sizeof buf, "<a href=\"/magic/man2html/%c/%s\">", fld[5][1], fld[4]); nanchors++; anchors = erealloc(anchors, nanchors*sizeof(char*)); anchors[nanchors-1] = estrdup(buf); }else if(strcmp(fld[3], "end") == 0) attr &= ~(1<<Anchor); } }else if(strcmp(fld[2], "manPP") == 0){ didP = 1; emitchar(Epp); }else if(nfld<4 || strcmp(fld[2], "manref")!=0){ if(nfld>2 && strcmp(fld[2], "<P>")==0){ /* avoid triggering extra <br> */ didP = 1; /* clear all font attributes before paragraph */ emitchar(' ' | (attr & ~(0xFFFF|((1<<Italic)|(1<<Bold)|(1<<CW))))); emitstr("<P>"); /* next emittec char will turn font attributes back on */ }else if(nfld>2 && strcmp(fld[2], "<H4>")==0) attr |= (1<<Heading); else if(nfld>2 && strcmp(fld[2], "</H4>")==0) attr &= ~(1<<Heading); else if(debug) fprint(2, "unknown in-line html %s... at %s:%#d\n", fld[2], filename, cno); } return; } if(debug) fprint(2, "unknown or badly formatted x command %s\n", fld[0]); }