/* for parsing: loop through all the available symbols to add them ** to the parser. linfoused indicates which (latex)maptables are already used ** and fonts using that table are skipped. Undefined fonts are also ** skipped. (otherwise it would result in 256*256*2=131072 loops, now the ** maximum is 256*30*2=15360 loops, but usually much less (standard 2048). */ char *char_latex_next(Char *data, int *math) { #ifdef MATH_OLD_WAY int i,j,h,m,id; char *lh; if (!*data) for (i=0; i<30; linfoused[i++]=0); if (!*math) (*math)++; else { *math=0; (*data)++; } i=Char2Font(*data); j=Char2ASCII(*data); h = FINFO(grnr, i).lnr; lh=linfo[h].code; m=*math; while (1) { /* end if i>=256 */ if (!h || linfoused[h]) { /* font is not available or uses same coding: skip it */ i++; j=0;m=0; if (i==256) break; h = FINFO(grnr, i).lnr; lh=linfo[h].code; } else if (((m && aig(id=linfo[h].math[j])) || (!m && aig(id=linfo[h].normal[j]))) && ((lh[id]!=j) || (lh[id+1]!=0))) { /* found something of interest */ *data=(Char)Font2Char(i,j); *math=m; return lh+id; } else { /* increase (i,j,m) */ if (!m) { /* increase math tag (m) */ m=1; } else { m=0; if (j<255) { /* increase character position (j) */ j++; } else { /* increase font position (i) */ j=0; linfoused[h]=1; i++; if (i==256) break; h = FINFO(grnr,i).lnr; lh=linfo[h].code; } } } } #endif *data=0; *math=0; return 0; }
bool strash_command::execute() { if ( opts.is_set( "new" ) ) { const auto current = aig(); store.extend(); aig() = strash( current ); } else { aig() = strash( aig() ); } return true; }
void open_temporary_file(char *editname, char *filename, int disp, int linenum) { EDITINFO *edata; int i; Char *newname; newname=concat(LocaletoUstr(editname),0); i=0; while (aig(edata = (EDITINFO*) next_data_with_type(MAINEDITWINDOW, &i)) && Ustrcmp(edata->pathname,newname)) i++; if (!edata) { as_icon=1; edit_open(); as_icon=0; if (state_window) edata = state_window; } handle_view_filename((void *) edata, concat(LocaletoUstr(filename),NULL)); editwindow_line(edata->info, linenum-1); set_name(edata,newname); if (edata->iconized) { XMapWindow(display, edata->win_id); } if (disp) XRaiseWindow(display, edata->win_id); }
static EDITINFO *message_window(Char *messagetitle) { int i=0; EDITINFO *edata; if (!messagetitle) return NULL; while (aig(edata = (EDITINFO*) next_data_with_type(MAINEDITWINDOW, &i)) && Ustrcmp(edata->pathname,messagetitle)) { i++; } if (!edata) { int old_icon=as_icon; as_icon=MP_True; edit_open(); as_icon=old_icon; if (state_window) { edata=state_window; edata->view_mode=MP_True; set_name(edata, concat(messagetitle,NULL)); } } if (edata && edata->iconized && 0) { XMapWindow(display, edata->win_id); XFlush(display); } return edata; }
/* header to be able to add this function to a menu */ void open_helpfile(void *data, int nr __attribute__((unused))) { Char *c = (Char*) data; int i=0,hpos=0; Char *f; Char *name; Char *fullname; EDITINFO *edata; if (!c || !(f = (Char*) malloc(sizeof(Char)*(Ustrlen(c)+1)))) return; for (i=0; (f[i]=c[i]) ; i++) if (c[i]=='#') if (!i) hpos=-1; else if (hpos) hpos=0; else hpos=i; if (hpos>0) { name = c+hpos+1; f[hpos]='\0'; } else name = c+i; f = standard_dir(f); fullname = search_through_dirs(help_dirs, nr_help_dirs, f); if (!fullname && f[0]=='/') fullname=f; else free(f); if (!fullname) { message(MP_ERROR, translate("Help document not found.")); return; } i=0; while (aig(edata = (EDITINFO*) next_data_with_type(MAINEDITWINDOW, &i)) && Ustrcmp(edata->pathname,fullname)) i++; if (!edata) { as_icon=1; edit_open(); as_icon=0; if (state_window) { edata = state_window; handle_view_filename((void *) state_window, concat(fullname,NULL)); word_wrap_window(edata->info); } } if (!edata) { message2(MP_CLICKREMARK, translate("Unable to open an edit window for document "), name); return; } if (name[0]) { int j=Ustrlen(name)+1; Char *cname = (Char*) malloc(j*sizeof(Char)); if (cname) { for (i=j-1;i>=0; i--) cname[i]=name[i]; editwindow_topto(edata->info, cname); free(cname); } } if (edata->iconized) { XMapWindow(display, edata->win_id); } XRaiseWindow(display, edata->win_id); }
static void add_format_to_parser(Char *c, int len, int ivnr, Char mode, int tabbing, int pmode, int prec, int shortop) { int i,j,n=1,llp; char *str=NULL; Char *tmp; j=0; for (i=0;i<len;i++) if (IsPh(c[i])) n++; n=n*2; tmp = (Char*) malloc(n*sizeof(Char)); tex_set_string(&str); if (tabbing) out_latex_char(TabOpen); out_latex_char(mode); llp=tex_current_pos(); if (shortop) tex_code(SOpOpen); n=0; for (i=0; i<len; i++) { if (IsPh(c[i])) { switch (Ph(c[i])) { case MP_Expr: tex_code(ExprOpen); break; case MP_Op: tex_code(LOpOpen); break; case MP_Id: tex_code(SIdOpen); break; case MP_Var: tex_code(VarOpen); break; case MP_Text: tex_code(TextOpen); break; default: break; } out_latex_char(' '); j=tex_current_pos()-1; if (j!=llp && str[j]==' ') { str[j]='\0'; if (aig(tmp[n]=lex_add_string(str+llp, 0))) n++; str[j]=' '; } llp=j+1; switch (Ph(c[i])) { case MP_Expr: tex_code(ExprClose); break; case MP_Op: tex_code(LOpClose); break; case MP_Id: tex_code(SIdClose); break; case MP_Var: tex_code(VarClose); break; case MP_Text: tex_code(TextClose); break; default: break; } tmp[n++]=c[i]; } out_latex_char(c[i]); } if (shortop) tex_code(SOpClose); if (llp!=tex_current_pos()) tmp[n++]=lex_add_string(str+llp,0); tmp[n]=0; tex_unset(); if (!str) free(tmp); else if (!parse_add_rule(pmode, tmp, n, ivnr, prec)) free(tmp); }
bool simgraph_command::execute() { std::vector<unsigned> types; foreach_string( vectors, ",", [&]( const std::string& s ) { if ( s == "ah" ) types += 0u; else if ( s == "1h" ) types += 3u; else if ( s == "2h" ) types += 5u; else if ( s == "ac" ) types += 1u; else if ( s == "1c" ) types += 2u; else if ( s == "2c" ) types += 4u; } ); auto settings = make_settings(); settings->set( "simulation_signatures", signatures ? boost::optional<unsigned>( signatures ) : boost::optional<unsigned>() ); if ( opts.is_set( "dotname" ) ) { settings->set( "dotname", dotname ); } statistics = std::make_shared<properties>(); const auto graph = create_simulation_graph( aig(), types, settings, statistics ); std::cout << format( "[i] create_simulation_graph: %.2f secs" ) % statistics->get<double>( "runtime" ) << std::endl << format( "[i] - labeling time: %.2f secs" ) % statistics->get<double>( "labeling_runtime" ) << std::endl << format( "[i] - vertices: %d" ) % boost::num_vertices( graph ) << std::endl << format( "[i] - edges: %d" ) % boost::num_edges( graph ) << std::endl; if ( opts.is_set( "signatures" ) && signatures ) { const auto& _info = info(); const auto& meta = boost::get_property( graph, boost::graph_meta ); const auto offset = meta.num_inputs + meta.num_vectors; const auto& sigs = boost::get( boost::vertex_simulation_signature, graph ); std::cout << "[i] simulation signatures:" << std::endl; for ( auto i = 0u; i < _info.outputs.size(); ++i ) { std::cout << format( "[i] %s : %s" ) % _info.outputs.at( i ).second % any_join( *sigs[offset + i], " " ) << std::endl; } } if ( opts.is_set( "patternname" ) ) { write_pattern_file(); } return true; }
void edit_signal_to_proces(int signl, Char *shname) { EDITINFO *edata; int i=0; while (aig(edata = (EDITINFO*) next_data_with_type(MAINEDITWINDOW,&i)) && Ustrcmp(edata->pathname,shname)) i++; if (!edata) { message2(MP_ERROR, shname, translate(" is not running.")); return; } if (!edata->pid) { message2(MP_ERROR, translate("Unable to send signals to "),shname); return; } kill(edata->pid, signl); }
static void edit_handle_fileselc_output(void *data, Char *name) { EDITINFO *einf = (EDITINFO *) data; FILE *f; if (aig(f=fopen((char*)UstrtoFilename(name), "w"))) { tex_set_file(f); tex_mode(texmode); tex_placeholders(ON); latex_editwindow(einf->info); tex_unset(); fclose(f); free(einf->outputname); einf->outputname = name; sprintf(envbuf,"OUTPUTFILE=%s", UstrtoFilename(einf->outputname)); if (putenv(envbuf)!=0) printf("No outputfile set!!!\n"); message(MP_MESSAGE, translate("Document converted.")); } else { message2(MP_CLICKREMARK, translate("No output made. Unable to open file "), name); failure=MP_True; } }
static int set_name(void *data, Char *pathname) { EDITINFO *einf = (EDITINFO *) data; XTextProperty prop_name; Char *name; int namesize; Char *stripname, *nname; if (pathname == NULL) { EDITINFO *tinf; FlexArray istck; int i=0,j; int_init(istck); while (aig(tinf=(EDITINFO*)next_data_with_type(MAINEDITWINDOW, &i))) { if (!Ustrncmp(translate(EMPTYFILE),tinf->filename, Ustrlen(translate(EMPTYFILE)))) { j = Ustrtol(tinf->filename+Ustrlen(translate(EMPTYFILE)), NULL, 10); int_add(istck, j); } i++; } i=1; while (int_contains(istck,i)) i++; int_clear(istck); nname = (Char *) malloc(sizeof(Char)*(Ustrlen(userdir) + Ustrlen(translate("/" EMPTYFILE)) + 5 +Ustrlen(translate(EXTENSION)))); concat_in(nname, userdir, translate("/" EMPTYFILE)); stripname = nname + Ustrlen(nname); { Char sb[40]; Char *s; sb[39]=0; s=Ultostr(i,sb+39); Ustrcat(stripname,s); } Ustrcat(stripname, translate(EXTENSION)); } else nname = pathname; stripname = concat(strip_name(nname),NULL); if (!Ustrcmp(stripname+Ustrlen(stripname)-Ustrlen(translate(EXTENSION)), translate(EXTENSION))) stripname[Ustrlen(stripname)-Ustrlen(translate(EXTENSION))] = 0; namesize = Ustrlen(translate(EDITNAME)) + Ustrlen(stripname) + 1 + (einf->saved ? 0 : Ustrlen(translate(CHANGED))) + (einf->view_mode && !einf->shell ? Ustrlen(translate(VIEWCOM)) : 0) + (einf->shell && !einf->fini ? Ustrlen(translate(RUNCOM)) : 0) + (einf->shell && einf->fini ? Ustrlen(translate(DONECOM)) : 0); name = (Char *) malloc((size_t) namesize*sizeof(Char) ); if (name) { name[0]= '\0'; Ustrcat(name, translate(EDITNAME)); Ustrcat(name, stripname); if (!einf->saved && !einf->shell) Ustrcat(name, translate(CHANGED)); if (einf->view_mode && !einf->shell) Ustrcat(name, translate(VIEWCOM)); if (einf->shell && !einf->fini) Ustrcat(name, translate(RUNCOM)); if (einf->shell && einf->fini) Ustrcat(name, translate(DONECOM)); } { char *n; n= (char*)UstrtoLocale(name); if (!name || !XStringListToTextProperty(&n, 1, &prop_name)) { message(MP_ERROR, translate("No location for editname.")); return 0; } } XSetWMName(display, einf->win_id, &prop_name); free(einf->headername); if (einf->pathname!=nname) free(einf->pathname); free(einf->filename); einf->headername = name; einf->filename = stripname; einf->pathname = nname; { char *icn; icn = (char*)UstrtoLocale(stripname); if (!XStringListToTextProperty(&icn, 1, &prop_name)) { message(MP_ERROR, translate("No location for editicon.")); return 0; } } XSetWMIconName(display, einf->win_id, &prop_name); return 1; }
void edit_string_to_proces(Char *txt, Char *shname) { EDITINFO *edata; char *c,*h; Char *d; char *arg[4]; Bool only_text=MP_False; int len=0,i=0; char lpref='\0'; /* ** txt uses the following format sequences: ** %t %1 target selection ** %s %2 source selection ** %a %3 argument selection ** %P? ? is added at the beginning of each line (in a selection) ** %T only text place holders are passed through ** %E all place holders are passed through ** %? ? character ** To add: some way to select the output mode. */ while (aig(edata = (EDITINFO*) next_data_with_type(MAINEDITWINDOW, &i)) && Ustrcmp(edata->pathname,shname)) i++; if (!edata) { message2(MP_ERROR, shname,translate(" is not running.")); return; } if (!edata->shell) { message2(MP_ERROR, shname,translate(" can not receive input.")); return; } if (edata->fini) { message2(MP_ERROR, shname,translate(" is finished.")); return; } if (!edata->strt) message2(MP_MESSAGE, shname, translate(" is still busy.")); /* scan txt for arguments, to determine len */ d=txt; for (i=0; i<4; arg[i++]=NULL); while (*d) { switch (*d) { case '%': d++; i=0; switch (*d) { case 't': case '1': i=1; break; case 's': case '2': i=2; break; case 'a': case '3': i=3; break; case 'P': d++; lpref=*d; if (!*d) d--; break; case 'T': only_text=MP_True; break; case 'E': only_text=MP_False; break; case '\0': c--; break; default: len++; break; } if (i) { if (!arg[i]) { tex_set_string(&arg[i]); tex_placeholders(ON); tex_mode(ASCII); latex_text_only(only_text); latex_selection(i); latex_text_only(MP_False); tex_unset(); } if (arg[i]) { len+=strlen(arg[i]); if (lpref>32) { h=arg[i]; while (*h) { if (*h=='\n') len++; h++; } } } else { arg[0]=malloc(sizeof(char)); arg[0][0]=0; } } break; default: len++; break; } d++; } if (arg[0]) { message(MP_ERROR, translate("Selections not set properly.")); for (i=0;i<4;i++) if (arg[i]) free(arg[i]); return; } /* make string */ c=h=(char*)malloc(sizeof(char)*(len+2)); while (*txt) { switch (*txt) { case '%': txt++; i=0; switch (*txt) { case 't': case '1': i=1; break; case 's': case '2': i=2; break; case 'a': case '3': i=3; break; case 'P': txt++; lpref=*txt; if (!*txt) txt--; break; case 'T': break; case '\0': txt--; break; default: *h++=*txt; break; } if (i && arg[i]) { if (lpref>32) { char *t=arg[i]; while (aig(*h=*t)) { if (*h=='\n') { h++; *h=lpref; } h++; t++; } } else { strcpy(h, arg[i]); while (*h) h++; } } break; default: *h++=*txt; break; } txt++; } *h='\0'; /* send string c */ edit_send_to_proces((void*)edata, (unsigned char*) c, len); free(c); for (i=0; i<4; i++) if (arg[i]) free(arg[i]); }
bool read_sym_command::execute() { read_symmetries( aig(), filename ); return true; }