// --- void CCodeGen::m_pl_or_ven_id( COutputSect& old, COutputSect& anew ) { int i; if ( m_plugin_mode ) { CStr token; char* str = anew.RemoveInd( 0, noDelete ); i = old.find_by( 0, str, cmp_ignore_spaces ); if ( -1 != i ) delete [] str; else if ( !get_token((const char*&)str,token) || !get_token((const char*&)str,token) ) old.Add( str ); else if ( -1 == (i=old.find_by(0,token,cmp_by_substr_ignore_comment)) ) old.Add( str ); else if ( is_comment(old[i]) ) { uncomment( old[i] ); delete [] str; } else delete [] str; } else { i = old.find_by( 0, g_moved, cmp_ignore_spaces ); if ( -1 == i ) { old.comment_out(); old.Insert( 0, (char*)::memcpy(new char[sizeof(g_moved)], g_moved, sizeof(g_moved)) ); } return; } }
void Zredisplay(void) { zbuff_t *buff; wsize(); redisplay(); foreachbuff(buff) uncomment(buff); }
void Zrevert_file(void) { unsigned long offset; if (!Curbuff->fname) { tbell(); return; } if (Bbuff->bmodf && ask("File modifed. Ok to loose changes?") != YES) return; /* Lose the undo history */ undo_clear(Curbuff->buff); offset = blocation(Bbuff); zreadfile(Curbuff->fname); boffset(Bbuff, offset); uncomment(Curbuff); }
QFEHelpEditorWidget::QFEHelpEditorWidget(QWidget* parent) : QWidget(parent), ui(new Ui::QFEHelpEditorWidget) { modified=false; newScript=true; ui->setupUi(this); ui->edtScript->getEditor()->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); ui->edtScript->getEditor()->setLineWrapMode(QTextEdit::WidgetWidth); connect(ui->edtScript->getEditor()->document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified())); highlighter=new QFHTMLHighlighter("", ui->edtScript->getEditor()->document()); highlighter->setUseSpecial2("$(", ")$"); highlighter->setUseSpecial1("$$", "$$"); completer = new QCompleter(ui->edtScript->getEditor()); completermodel=modelFromFile(ProgramOptions::getInstance()->getAssetsDirectory()+"/qtscript/completer.txt"); completer->setModel(completermodel); completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setWrapAround(false); ui->edtScript->getEditor()->setCompleter(completer); recentHelpFiles=new QRecentFilesMenu(this); recentHelpFiles->setUseSystemFileIcons(false); recentHelpFiles->setAlwaysEnabled(true); connect(recentHelpFiles, SIGNAL(openRecentFile(QString)), this, SLOT(openScriptNoAsk(QString))); ui->btnOpen->setMenu(recentHelpFiles); connect(ui->edtScript->getEditor(), SIGNAL(cursorPositionChanged()), this, SLOT(edtScript_cursorPositionChanged())); actLoadAutosave=new QFActionWithNoMenuRole(tr("load last autosaved file ..."), this); connect(actLoadAutosave, SIGNAL(triggered()), this, SLOT(reloadLastAutosave())); cutAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_cut.png"), tr("Cu&t"), this); cutAct->setShortcut(tr("Ctrl+X")); cutAct->setToolTip(tr("Cut the current selection's contents to the " "clipboard")); connect(cutAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(cut())); copyAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_copy.png"), tr("&Copy"), this); copyAct->setShortcut(tr("Ctrl+C")); copyAct->setToolTip(tr("Copy the current selection's contents to the " "clipboard")); connect(copyAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(copy())); pasteAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_paste.png"), tr("&Paste"), this); pasteAct->setShortcut(tr("Ctrl+V")); pasteAct->setToolTip(tr("Paste the clipboard's contents into the current " "selection")); connect(pasteAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(paste())); undoAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_undo.png"), tr("&Undo"), this); undoAct->setShortcut(tr("Ctrl+Z")); undoAct->setToolTip(tr("Undo the last change ")); connect(undoAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(undo())); redoAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_redo.png"), tr("&Redo"), this); redoAct->setShortcut(tr("Ctrl+Shift+Z")); redoAct->setToolTip(tr("Redo the last undone change ")); connect(redoAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(redo())); findAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_find.png"), tr("&Find ..."), this); findAct->setShortcut(tr("Ctrl+F")); findAct->setToolTip(tr("Find a string in sequence ")); connect(findAct, SIGNAL(triggered()), this, SLOT(findFirst())); findNextAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_find_next.png"), tr("Find &next"), this); findNextAct->setShortcut(tr("F3")); findNextAct->setToolTip(tr("Find the next occurence ")); connect(findNextAct, SIGNAL(triggered()), this, SLOT(findNext())); findNextAct->setEnabled(false); replaceAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_find_replace.png"), tr("Find && &replace ..."), this); replaceAct->setShortcut(tr("Ctrl+R")); replaceAct->setToolTip(tr("Find a string in sequence and replace it with another string ")); connect(replaceAct, SIGNAL(triggered()), this, SLOT(replaceFirst())); commentAct = new QFActionWithNoMenuRole(tr("&Comment text"), this); commentAct->setShortcut(tr("Ctrl+B")); commentAct->setToolTip(tr("add (single line) comment at the beginning of each line ")); connect(commentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(comment())); unCommentAct = new QFActionWithNoMenuRole(tr("&Uncomment text"), this); unCommentAct->setShortcut(tr("Ctrl+Shift+B")); unCommentAct->setToolTip(tr("remove (single line) comment at the beginning of each line ")); connect(unCommentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(uncomment())); indentAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_indent.png"), tr("&Increase indention"), this); commentAct->setShortcut(tr("Ctrl+I")); indentAct->setToolTip(tr("increase indention ")); connect(indentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(indentInc())); unindentAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_unindent.png"), tr("&Decrease indention"), this); unindentAct->setShortcut(tr("Ctrl+Shift+I")); unindentAct->setToolTip(tr("decrease indention ")); connect(unindentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(indentDec())); gotoLineAct = new QFActionWithNoMenuRole(tr("&Goto line ..."), this); gotoLineAct->setShortcut(tr("Alt+G")); gotoLineAct->setToolTip(tr("goto a line in the opened file ")); connect(gotoLineAct, SIGNAL(triggered()), this, SLOT(gotoLine())); printAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_print.png"), tr("&Print ..."), this); printAct->setToolTip(tr("print the current SDFF file ")); connect(printAct, SIGNAL(triggered()), this, SLOT(print())); actInsertIcon = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/insert_image.png"), tr("&Insert icon ..."), this); actInsertIcon->setToolTip(tr("print the current SDFF file ")); connect(actInsertIcon, SIGNAL(triggered()), this, SLOT(insertIcon())); toEntityAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/toentity.png"), tr("&Convert characters to entities ..."), this); toEntityAct->setToolTip(tr("convert characters in the selected text to HTML entities")); connect(toEntityAct, SIGNAL(triggered()), this, SLOT(toEntity())); toCharAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/tochars.png"), tr("&Convert entities to characters ..."), this); toCharAct->setToolTip(tr("convert HTML entities in the selected text to characters")); connect(toCharAct, SIGNAL(triggered()), this, SLOT(toChars())); cutAct->setEnabled(false); copyAct->setEnabled(false); undoAct->setEnabled(false); redoAct->setEnabled(false); connect(ui->edtScript->getEditor(), SIGNAL(copyAvailable(bool)), cutAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(copyAvailable(bool)), copyAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(undoAvailable(bool)), undoAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(redoAvailable(bool)), redoAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(findNextAvailable(bool)), findNextAct, SLOT(setEnabled(bool))); QMenu* menuMore=new QMenu(ui->tbMoreOptions); menuMore->addAction(indentAct); menuMore->addAction(unindentAct); menuMore->addAction(commentAct); menuMore->addAction(unCommentAct); menuMore->addSeparator(); menuMore->addAction(toEntityAct); menuMore->addAction(toCharAct); menuMore->addSeparator(); menuMore->addAction(actInsertIcon); menuMore->addSeparator(); menuMore->addAction(gotoLineAct); menuMore->addAction(findAct); menuMore->addAction(replaceAct); menuMore->addAction(findNextAct); menuMore->addSeparator(); menuMore->addAction(actLoadAutosave); ui->tbMoreOptions->setMenu(menuMore); ui->tbFind->setDefaultAction(findAct); ui->tbFindNext->setDefaultAction(findNextAct); ui->tbReplace->setDefaultAction(replaceAct); ui->tbPrint->setDefaultAction(printAct); ui->tbCopy->setDefaultAction(copyAct); ui->tbCut->setDefaultAction(cutAct); ui->tbPaste->setDefaultAction(pasteAct); ui->tbRedo->setDefaultAction(redoAct); ui->tbUndo->setDefaultAction(undoAct); ui->tbEntity->setDefaultAction(toEntityAct); ui->tbChars->setDefaultAction(toCharAct); setScriptFilename(""); QMenu* menu; menu=new QMenu(tr("directories"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$mainhelpdir$$"); addInsertAction(menu, "$$mainhelppicdir$$"); addInsertAction(menu, "$$assetsdir$$"); addInsertAction(menu, "$$examplesdir$$"); addInsertAction(menu, "$$configdir$$"); addInsertAction(menu, "$$maindir$$"); addInsertAction(menu, "$$sourcedir$$"); menu=new QMenu(tr("version/copyright info"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$version.svnrevision$$"); addInsertAction(menu, "$$version.status$$"); addInsertAction(menu, "$$version.date$$"); addInsertAction(menu, "$$version$$"); addInsertAction(menu, "$$version_full$$"); menu->addSeparator(); addInsertAction(menu, "$$thanksto$$"); addInsertAction(menu, "$$copyright$$"); addInsertAction(menu, "$$author$$"); addInsertAction(menu, "$$weblink$$"); addInsertAction(menu, "$$license$$"); addInsertAction(menu, "$$maillist$$"); addInsertAction(menu, "$$maillistrequest$$"); menu->addSeparator(); addInsertAction(menu, "$$qfcitation$$"); addInsertAction(menu, "$$qfcitation_bibtex$$"); addInsertAction(menu, "$$jankrieger_phdthesis$$"); addInsertAction(menu, "$$jankrieger_phdthesis_ref$$"); menu=new QMenu(tr("general help links"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, tr("Link: RDR general help"), "<a href=\"$qf_ui_rdr_helpfile$$\">$$qf_ui_rdr_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: Evaluation general help"), "<a href=\"$$qf_ui_eval_helpfile$$\">$$qf_ui_eval_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: Plotter Widget general help"), "<a href=\"$$qf_ui_jkqtplotter_helpfile$$\">$$qf_ui_jkqtplotter_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: LaTeX parser general help"), "<a href=\"$$qf_ui_latex_helpfile$$\">$$qf_ui_latex_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: Expression parser help"), "<a href=\"$$qf_mathparser_helpfile$$\">$$qf_mathparser_helpfiletitle$$</a>" ); //addInsertAction(menu, tr("Link: help"), "<a href=\"$$aa$$\">$$aa$$</a>" ); //addInsertAction(menu, tr("Link: help"), QString("<a href=\"$$mainhelpdir$$aa\">aa</a>") ); addInsertAction(menu, tr("Link: Custom color palettes help"), QString("<a href=\"$$mainhelpdir$$colorpalettes.html\">custom color paletes</a>") ); addInsertAction(menu, tr("Link: Available color palettes"), QString("<a href=\"$$mainhelpdir$$installedcolorpalettes.html\">available color paletes</a>") ); addInsertAction(menu, tr("Link: Regular Expressions"), QString("<a href=\"$$mainhelpdir$$qf3_qtregexp.html\">regular expressions</a>") ); addInsertAction(menu, tr("Link: Fit Functions"), QString("<a href=\"$$mainhelpdir$$qf3_fitfunc.html\">fit functions</a>") ); addInsertAction(menu, tr("Link: Fit Algorithms"), QString("<a href=\"$$mainhelpdir$$qf3_fitalg.html\">fit algorithms</a>") ); addInsertAction(menu, tr("Link: File Formats"), QString("<a href=\"$$mainhelpdir$$qf3_fileformats.html\">file formats</a>") ); addInsertAction(menu, tr("Link: GPL 3.0"), QString("<a href=\"$$mainhelpdir$$gpl3_0.html\">GPL 3.0</a>") ); addInsertAction(menu, tr("Link: FAQs"), QString("<a href=\"$$qf_faqfile$$\">Frequently asked questions</a>") ); menu->addSeparator(); addInsertAction(menu, "$$qf_ui_rdr_helpfile$$"); addInsertAction(menu, "$$qf_ui_rdr_helpfiletitle$$"); addInsertAction(menu, "$$qf_ui_eval_helpfile$$"); addInsertAction(menu, "$$qf_ui_eval_helpfiletitle$$"); addInsertAction(menu, "$$qf_ui_jkqtplotter_helpfile$$"); addInsertAction(menu, "$$qf_ui_jkqtplotter_helpfiletitle$$"); addInsertAction(menu, "$$qf_ui_latex_helpfile$$"); addInsertAction(menu, "$$qf_ui_latex_helpfiletitle$$"); addInsertAction(menu, "$$qf_mathparser_helpfile$$"); addInsertAction(menu, "$$qf_mathparser_helpfiletitle$$"); addInsertAction(menu, "$$qf_faqfile$$"); menu=new QMenu(tr("page header/footer"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$qf_commondoc_backtop$$"); menu->addSeparator(); addInsertAction(menu, "$$qf_commondoc_footer.start$$"); addInsertAction(menu, "$$qf_commondoc_footer.end$$"); menu->addSeparator(); addInsertAction(menu, "$$qf_commondoc_header.start$$"); addInsertAction(menu, "$$qf_commondoc_header.end$$"); addInsertAction(menu, "$$qf_commondoc_header.end_notitle$$"); addInsertAction(menu, "$$qf_commondoc_header.rdr$$"); addInsertAction(menu, "$$qf_commondoc_header.eval$$"); addInsertAction(menu, "$$qf_commondoc_header.extension$$"); addInsertAction(menu, "$$qf_commondoc_header.fitfunc$$"); addInsertAction(menu, "$$qf_commondoc_header.fitalg$$"); addInsertAction(menu, "$$qf_commondoc_header.separator$$"); menu=new QMenu(tr("plugin info"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$local_plugin_icon$$"); addInsertAction(menu, "$$local_plugin_iconfilename$$"); addInsertAction(menu, "$$local_plugin_name$$"); addInsertAction(menu, "$$local_plugin_author$$"); addInsertAction(menu, "$$local_plugin_copyright$$"); addInsertAction(menu, "$$local_plugin_weblink_url$$"); addInsertAction(menu, "$$local_plugin_weblink$$"); addInsertAction(menu, "$$local_plugin_id$$"); addInsertAction(menu, "$$local_plugin_subid$$"); addInsertAction(menu, "$$local_plugin_subname$$"); addInsertAction(menu, "$$local_plugin_subshortname$$"); addInsertAction(menu, "$$local_plugin_tutorial_file$$"); addInsertAction(menu, "$$local_plugin_tutorial_link$$"); addInsertAction(menu, "$$local_plugin_mainhelp_file$$"); addInsertAction(menu, "$$local_plugin_mainhelp_link$$"); addInsertAction(menu, "$$local_plugin_version$$"); addInsertAction(menu, "$$local_plugin_typehelp_link$$"); addInsertAction(menu, "$$local_plugin_typehelp_file$$"); addInsertAction(menu, "$$local_plugin_assets$$"); addInsertAction(menu, "$$local_plugin_examples$$"); addInsertAction(menu, "$$local_plugin_help$$"); addInsertAction(menu, "$$local_plugin_config$$"); addInsertAction(menu, "$$local_plugin_tutorials$$"); menu->addSeparator(); addInsertAction(menu, "$$plugin_info:help:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:tutorial:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:helpdir:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:assetsdir:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:examplesdir:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:configdir:PLUGINID$$"); menu->addSeparator(); addInsertAction(menu, "$$fitfunction:help:PLUGINID$$"); addInsertAction(menu, "$$fitfunction:name:PLUGINID$$"); addInsertAction(menu, "$$fitfunction:short_name:PLUGINID$$"); menu->addSeparator(); addInsertAction(menu, "$$fitalgorithm:help:PLUGINID$$"); addInsertAction(menu, "$$fitalgorithm:name:PLUGINID$$"); addInsertAction(menu, "$$fitalgorithm:short_name:PLUGINID$$"); menu->addSeparator(); addInsertAction(menu, "$$importer:help:PLUGINID$$"); addInsertAction(menu, "$$importer:name:PLUGINID$$"); addInsertAction(menu, "$$exporter:help:PLUGINID$$"); addInsertAction(menu, "$$exporter:name:PLUGINID$$"); menu=new QMenu(tr("plugin lists"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$list:extension:INTERFACENAME$$"); addInsertAction(menu, "$$list:fitfunc:$$"); addInsertAction(menu, "$$list:fitfunc:STARTSWITH$$"); addInsertAction(menu, "$$list:fitfunc_inplugin:PLUGIN_ID|STARTSWITH$$"); addInsertAction(menu, "$$list:fitfunc_inplugin:PLUGIN_ID$$"); addInsertAction(menu, "$$list:fitalg:$$"); addInsertAction(menu, "$$list:fitalg:STARTSWITH$$"); addInsertAction(menu, "$$list:importers:STARTSWITH$$"); addInsertAction(menu, "$$list:exporters:STARTSWITH$$"); addInsertAction(menu, "$$list:plugin_tutorials:PLUGIN_ID$$"); menu=new QMenu(tr("help lists"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$tutorials_contents$$"); addInsertAction(menu, "$$help_contents$$"); addInsertAction(menu, "$$settings_contents$$"); menu=new QMenu(tr("insert files"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$insert:FILENAME$$"); addInsertAction(menu, "$$insertglobal:FILENAME$$"); menu=new QMenu(tr("insert Equations (LaTeX)"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$math:LATEX$$"); addInsertAction(menu, "$(LATEX)$"); addInsertAction(menu, "$$bmath:LATEX$$"); addInsertAction(menu, "$[LATEX]$"); menu=new QMenu(tr("insert Literature References"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$ref:<ID>:Text$$"); addInsertAction(menu, "$$ref:<ID>:$$"); addInsertAction(menu, "$$invisibleref:<ID>:Text$$"); addInsertAction(menu, "$$references$$"); menu=new QMenu(tr("insert Figures"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$fig:FILENAME:CAPTION$$"); menu=new QMenu(tr("insert Info boxes"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$see:Text$$"); addInsertAction(menu, "$$note:Text$$"); addInsertAction(menu, "$$info:Text$$"); addInsertAction(menu, "$$warning:Text$$"); addInsertAction(menu, "$$example:Text$$"); addInsertAction(menu, "$$codeexample:Text$$"); addInsertAction(menu, "$$bqtt:Text$$"); addInsertAction(menu, "$$bqcode:Text$$"); menu->addSeparator(); addInsertAction(menu, "$$startbox$$"); addInsertAction(menu, "$$startbox_info$$"); addInsertAction(menu, "$$startbox_note$$"); addInsertAction(menu, "$$startbox_see$$"); addInsertAction(menu, "$$startbox_warning$$"); addInsertAction(menu, "$$startbox_example$$"); addInsertAction(menu, "$$startbox:backgroundcolor:bordercolor$$"); addInsertAction(menu, "$$startbox:lightgrey:midnightblue$$"); addInsertAction(menu, "$$endbox$$"); menu=new QMenu(tr("insert Tooltips"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$tooltip:PHRASE$$"); menu=new QMenu(tr("FAQs"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, tr("FAQ entry"), "$$faq_start$$\n <a name=\"FAQ1\"><b>Question?</b>\n$$faq_answer$$\n Answer ...\n$$faq_end$$"); menu->addSeparator(); addInsertAction(menu, "$$faq_start"); addInsertAction(menu, "$$faq_answer"); addInsertAction(menu, "$$faq_end"); menu=new QMenu(tr("Function References"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, tr("Function reference entry"), "$$funcref_start$$<a name=\"NAME\"/><!-- func:NAME -->\n <b><tt><!-- template -->NAME<!-- /template --></tt> - <i> DESCRIPTION </i>:</b>\n$$funcref_description$$\n DESCRIPTION\n <!-- /func:NAME -->\n$$funcref_end$$"); menu->addSeparator(); addInsertAction(menu, "$$funcref_start"); addInsertAction(menu, "$$funcref_description"); addInsertAction(menu, "$$funcref_end"); menu=new QMenu(tr("insert other markups"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$tt:Text$$"); menu=new QMenu(tr("LaTeX"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "\\left(%1#\\right)"); addInsertAction(menu, "\\left[%1#\\right]"); addInsertAction(menu, "\\left\\{%1#\\right\\}"); addInsertAction(menu, "\\left\\langle%1#\\right\\rangle"); menu->addSeparator(); addInsertAction(menu, "\\sqrt{%1#}"); menu->addSeparator(); addInsertAction(menu, "\\sum_{#}^{}%1"); addInsertAction(menu, "\\prod_{#}^{}%1"); addInsertAction(menu, "\\int_{#}^{}%1\\;\\mathrm{d}x"); addInsertAction(menu, "\\iint_{#}^{}%1\\;\\mathrm{d}^2x"); addInsertAction(menu, "\\iiint_{#}^{}%1\\;\\mathrm{d}^3x"); addInsertAction(menu, "\\oint_{#}^{}%1\\;\\mathrm{d}x"); addInsertAction(menu, "\\lim_{%1#}"); addInsertAction(menu, "\\argmin_{%1#}"); addInsertAction(menu, "\\argmax_{%1#}"); menu->addSeparator(); addInsertAction(menu, "\\vec{%1#}"); addInsertAction(menu, "\\hat{%1#}"); addInsertAction(menu, "\\tilde{%1#}"); addInsertAction(menu, "\\mathbf{%1#}"); addInsertAction(menu, "\\mathrm{%1#}"); addInsertAction(menu, "\\mathit{%1#}"); addInsertAction(menu, "\\mathsf{%1#}"); addInsertAction(menu, "\\mathbb{%1#}"); addInsertAction(menu, "\\mathscript{%1#}"); addInsertAction(menu, "\\underline{%1#}"); //addInsertAction(menu, "$$$$"); menu=new QMenu(tr("Special Characters"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$" "$"); addInsertAction(menu, "$$" "$$"); QTimer::singleShot(AUTOSAVE_INTERVAL_MSEC, this, SLOT(autosave())); }
static BOOL loadConfig(char *file, GRABBER **grabbers, int *countGrabbers) { FILE *config; config = fopen(file,"r"); if(config) { char buffer[512], param[256], value[256], *comment; int e; e = 0; while(fgets(buffer,sizeof(buffer),config)) { uncomment(buffer); sscanf(buffer,"%[^=]=%[^=]",param,value); strip(param); if(!stricmp(param,"grabberid")) e++; } *grabbers = (GRABBER *) calloc(e, sizeof(GRABBER)); rewind(config); e = -1; while(fgets(buffer,sizeof(buffer),config)) { uncomment(buffer); sscanf(buffer,"%[^=]=%[^=]",param,value); strip(param); strip(value); if(!stricmp(param,"grabberid")) { e++; strcpy((*grabbers)[e].id, value); } else if(e >=0) { if(!stricmp(param,"grabberexe")) strcpy((*grabbers)[e].exe, value); else if(!stricmp(param,"grabbertype")) { if(!stricmp(value,"win32os2")) (*grabbers)[e].type = WIN32OS2; else if(!stricmp(value,"vio")) (*grabbers)[e].type = VIO; else if(!stricmp(value,"vdm")) (*grabbers)[e].type = VDM; } else if(!stricmp(param,"grabberin")) strcpy((*grabbers)[e].input, value); else if(!stricmp(param,"grabberout")) strcpy((*grabbers)[e].output, value); else if(!stricmp(param,"grabbermangling")) strcpy((*grabbers)[e].mangling, value); else if(!stricmp(param,"grabberbefore")) strcpy((*grabbers)[e].before, value); else if(!stricmp(param,"grabberafter")) strcpy((*grabbers)[e].after, value); else if(!stricmp(param,"grabberacceptsoutput")) { if(!stricmp(value,"true")) (*grabbers)[e].acceptsOutput = TRUE; else (*grabbers)[e].acceptsOutput = FALSE; } else if(!stricmp(param,"grabbernodrive")) { if(!stricmp(value,"true")) (*grabbers)[e].noDrive = TRUE; else (*grabbers)[e].noDrive = FALSE; } } } *countGrabbers = e+1; fclose(config); return TRUE; } return FALSE; }
QFESPIMB040ScriptedAcquisition::QFESPIMB040ScriptedAcquisition(QFESPIMB040MainWindow2* mainWindow, QFESPIMB040AcquisitionTools* acqTools, QFPluginLogService* log, QWidget* parent, QFPluginServices* pluginServices, QFESPIMB040OpticsSetupBase* opticsSetup, QFESPIMB040AcquisitionDescription* acqDescription, QFESPIMB040ExperimentDescription* expDescription, QString /*configDirectory*/) : QWidget(parent), ui(new Ui::QFESPIMB040ScriptedAcquisition) { this->m_pluginServices=pluginServices; this->opticsSetup=opticsSetup; this->acqDescription=acqDescription; this->expDescription=expDescription; this->log=log; this->acqTools=acqTools; this->mainWindow=mainWindow; acquisitionTools=new QFESPIMB040ScriptedAcquisitionTools(this, mainWindow, acqTools, log, this, pluginServices, opticsSetup, acqDescription, expDescription); instrumentControl=new QFESPIMB040ScriptedAcquisitionInstrumentControl(this, mainWindow, acqTools, log, this, pluginServices, opticsSetup, acqDescription, expDescription); acquisitionControl=new QFESPIMB040ScriptedAcquisitionAcquisitionControl(this, mainWindow, acqTools, log, this, pluginServices, opticsSetup, acqDescription, expDescription); engine=new QScriptEngine(); ui->setupUi(this); findDlg=new QFESPIMB040FindDialog(this); replaceDlg=new QFESPIMB040ReplaceDialog(this); highlighter=new QFQtScriptHighlighter("", ui->edtScript->getEditor()->document()); completer = new QCompleter(ui->edtScript->getEditor()); completermodel=modelFromFile(ProgramOptions::getInstance()->getAssetsDirectory()+"/qtscript/completer.txt"); completer->setModel(completermodel); completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setWrapAround(false); ui->edtScript->getEditor()->setCompleter(completer); recentMaskFiles=new QRecentFilesMenu(this); recentMaskFiles->setUseSystemFileIcons(false); recentMaskFiles->setAlwaysEnabled(true); connect(recentMaskFiles, SIGNAL(openRecentFile(QString)), this, SLOT(openScriptNoAsk(QString))); ui->btnOpen->setMenu(recentMaskFiles); connect(ui->edtScript->getEditor(), SIGNAL(cursorPositionChanged()), this, SLOT(edtScript_cursorPositionChanged())); cutAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_cut.png"), tr("Cu&t"), this); cutAct->setShortcut(tr("Ctrl+X")); cutAct->setStatusTip(tr("Cut the current selection's contents to the " "clipboard")); connect(cutAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(cut())); copyAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_copy.png"), tr("&Copy"), this); copyAct->setShortcut(tr("Ctrl+C")); copyAct->setStatusTip(tr("Copy the current selection's contents to the " "clipboard")); connect(copyAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(copy())); pasteAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_paste.png"), tr("&Paste"), this); pasteAct->setShortcut(tr("Ctrl+V")); pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current " "selection")); connect(pasteAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(paste())); undoAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_undo.png"), tr("&Undo"), this); undoAct->setShortcut(tr("Ctrl+Z")); undoAct->setStatusTip(tr("Undo the last change ")); connect(undoAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(undo())); redoAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_redo.png"), tr("&Redo"), this); redoAct->setShortcut(tr("Ctrl+Shift+Z")); redoAct->setStatusTip(tr("Redo the last undone change ")); connect(redoAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(redo())); findAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_find.png"), tr("&Find ..."), this); findAct->setShortcut(tr("Ctrl+F")); findAct->setStatusTip(tr("Find a string in sequence ")); connect(findAct, SIGNAL(triggered()), this, SLOT(findFirst())); findNextAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_find_next.png"), tr("Find &next"), this); findNextAct->setShortcut(tr("F3")); findNextAct->setStatusTip(tr("Find the next occurence ")); connect(findNextAct, SIGNAL(triggered()), this, SLOT(findNext())); findNextAct->setEnabled(false); replaceAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_find_replace.png"), tr("Find && &replace ..."), this); replaceAct->setShortcut(tr("Ctrl+R")); replaceAct->setStatusTip(tr("Find a string in sequence and replace it with another string ")); connect(replaceAct, SIGNAL(triggered()), this, SLOT(replaceFirst())); commentAct = new QFActionWithNoMenuRole(tr("&Comment text"), this); commentAct->setShortcut(tr("Ctrl+B")); commentAct->setStatusTip(tr("add (single line) comment at the beginning of each line ")); connect(commentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(comment())); unCommentAct = new QFActionWithNoMenuRole(tr("&Uncomment text"), this); unCommentAct->setShortcut(tr("Ctrl+Shift+B")); unCommentAct->setStatusTip(tr("remove (single line) comment at the beginning of each line ")); connect(unCommentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(uncomment())); indentAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_indent.png"), tr("&Increase indention"), this); commentAct->setShortcut(tr("Ctrl+I")); indentAct->setStatusTip(tr("increase indention ")); connect(indentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(indentInc())); unindentAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_unindent.png"), tr("&Decrease indention"), this); unindentAct->setShortcut(tr("Ctrl+Shift+I")); unindentAct->setStatusTip(tr("decrease indention ")); connect(unindentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(indentDec())); gotoLineAct = new QFActionWithNoMenuRole(tr("&Goto line ..."), this); gotoLineAct->setShortcut(tr("Alt+G")); gotoLineAct->setStatusTip(tr("goto a line in the opened file ")); connect(gotoLineAct, SIGNAL(triggered()), this, SLOT(gotoLine())); printAct = new QFActionWithNoMenuRole(QIcon(":/spimb040/script_print.png"), tr("&Print ..."), this); printAct->setStatusTip(tr("print the current SDFF file ")); connect(printAct, SIGNAL(triggered()), this, SLOT(print())); cutAct->setEnabled(false); copyAct->setEnabled(false); undoAct->setEnabled(false); redoAct->setEnabled(false); connect(ui->edtScript->getEditor(), SIGNAL(copyAvailable(bool)), cutAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(copyAvailable(bool)), copyAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(undoAvailable(bool)), undoAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(redoAvailable(bool)), redoAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(findNextAvailable(bool)), findNextAct, SLOT(setEnabled(bool))); QMenu* menuMore=new QMenu(ui->tbMoreOptions); menuMore->addAction(indentAct); menuMore->addAction(unindentAct); menuMore->addAction(commentAct); menuMore->addAction(unCommentAct); menuMore->addSeparator(); menuMore->addAction(gotoLineAct); menuMore->addAction(findAct); menuMore->addAction(replaceAct); menuMore->addAction(findNextAct); ui->tbMoreOptions->setMenu(menuMore); ui->tbFind->setDefaultAction(findAct); ui->tbFindNext->setDefaultAction(findNextAct); ui->tbReplace->setDefaultAction(replaceAct); ui->tbPrint->setDefaultAction(printAct); ui->tbCopy->setDefaultAction(copyAct); ui->tbCut->setDefaultAction(cutAct); ui->tbPaste->setDefaultAction(pasteAct); ui->tbRedo->setDefaultAction(redoAct); ui->tbUndo->setDefaultAction(undoAct); updateReplaces(); //bindLineEdit(ui->edtPrefix1); ui->btnCancel->setVisible(false); ui->widProgress->setVisible(false); ui->labStatus->setVisible(false); setScriptFilename(tr("new_acquisition_script.js")); QDir d(QFPluginServices::getInstance()->getPluginHelpDirectory("ext_spimb040")+"acquisition_script/"); QStringList filter; filter<<"*.html"<<"*.htm"<<"*.txt"; QStringList files=d.entryList(filter, QDir::Files); threadsFinished=0; maxThreads=2; QList<QStringList> absFiles; for (int i=0; i<maxThreads; i++) { QStringList sl; absFiles.push_back(sl); } for (int i=0; i<files.size(); i++) { QString file=d.absoluteFilePath(files[i]); absFiles[i%maxThreads].append(file); } for (int i=0; i<maxThreads; i++) { threads.append(new QFESPIMB040ScriptedAcquisitionDocSearchThread(absFiles[i], this)); connect(threads[i], SIGNAL(finished()), this, SLOT(threadFinished())); connect(threads[i], SIGNAL(foundFunction(QString,QString,QString)), this, SLOT(addFunction(QString,QString,QString))); } QTimer::singleShot(10, this, SLOT(delayedStartSearchThreads())); }
bool get_wrap_data(char *wrapid, char *handler, char *cgi, t_wrap *wrap_data, char *user_directory) { FILE *fp; char line[257], *item, *rest, *pipe; struct passwd *pwd; bool wrap_oke = false, handler_oke; size_t len; handler_oke = (handler == NULL); wrap_data->chroot = NULL; /* WrapID is local userid? */ if (*wrapid == '~') { if ((pwd = getpwnam(wrapid + 1)) == NULL) { return false; } if ((wrap_data->uid = pwd->pw_uid) == 0) { return false; } len = strlen(pwd->pw_dir); if ((wrap_data->cgiroot = (char*)malloc(len + strlen(user_directory) + 1)) == NULL) { return false; } memcpy(wrap_data->cgiroot, pwd->pw_dir, len); strcpy(wrap_data->cgiroot + len, user_directory); if (strncmp(wrap_data->cgiroot, cgi, strlen(wrap_data->cgiroot)) != 0) { return false; } if (lookup_group_ids(wrap_data->uid, &(wrap_data->gid), &(wrap_data->groups)) == -1) { return false; } if (handler_oke) { return true; } wrap_oke = true; } else { wrap_data->cgiroot = NULL; } /* Read CGI wrapper configuration */ if ((fp = fopen(CONFIG_DIR"/cgi-wrapper.conf", "r")) != NULL) { line[256] = '\0'; while (fgets(line, 256, fp) != NULL) { rest = uncomment(line); if (*rest == '\0') { continue; } if (split_configline(rest, &item, &rest) == 0) { strlower(item); if (strcmp(item, "cgihandler") == 0) { /* CGI handler */ if (handler_oke) { continue; } do { split_string(rest, &item, &rest, ','); if (strcmp(handler, item) == 0) { handler_oke = true; break; } } while (rest != NULL); } else if (strcmp(item, "wrap") == 0) { /* Wrap entry */ if (wrap_oke) { continue; } /* Wrap Id */ if (split_string(rest, &item, &rest, DELIMITER) == -1) { break; } if (strcmp(item, wrapid) != 0) { continue; } /* Homedirectory */ if (split_string(rest, &item, &rest, DELIMITER) == -1) { break; } if (*item == '/') { /* chroot directory */ if ((pipe = strchr(item, '|')) != NULL) { *pipe = '\0'; len = pipe - item + 1; if ((wrap_data->chroot = (char*)malloc(len)) == NULL) { break; } memcpy(wrap_data->chroot, item, len); *pipe = '/'; } if ((len = strlen(item)) == 0) { break; } if ((strncmp(item, cgi, len) != 0) || (*(cgi + len) != '/')) { log_error("CGI not in WebsiteRoot"); break; } if (pipe != NULL) { cgi += (pipe - item); item = pipe; } wrap_data->cgiroot = strdup(item); } else if (*item == '~') { if ((pwd = getpwnam(item + 1)) == NULL) { log_error("invalid username"); break; } len = strlen(pwd->pw_dir); if ((wrap_data->cgiroot = (char*)malloc(len + strlen(user_directory) + 1)) == NULL) { break; } memcpy(wrap_data->cgiroot, pwd->pw_dir, len); strcpy(wrap_data->cgiroot + len, user_directory); if (strncmp(wrap_data->cgiroot, cgi, strlen(wrap_data->cgiroot)) != 0) { log_error("CGI not in user directory"); break; } } else { log_error("invalid CGI root"); break; } /* User Id */ split_string(rest, &item, &rest, ':'); if (parse_userid(item, &(wrap_data->uid)) != 1) { log_error("invalid userid"); break; } /* Group id */ if (rest != NULL) { if (parse_groups(rest, &(wrap_data->gid), &(wrap_data->groups)) != 1) { log_error("syntax error in groupid"); break; } } else { if (lookup_group_ids(wrap_data->uid, &(wrap_data->gid), &(wrap_data->groups)) != 1) { log_error("invalid group (user member of root?)"); break; } } wrap_oke = true; } else { /* Crap in configurationfile */ log_error("syntax error in configurationfile"); break; } if (wrap_oke && handler_oke) { break; } } else { /* split_string() error */ break; } } fclose(fp); if (wrap_oke == false) { log_error("no valid Wrap found"); } if (handler_oke == false) { log_error("no valid CGIhandler found"); } return (wrap_oke && handler_oke); } else { return false; } }
void Zfind_file(void) { if (get_findfile("Find File: ") == 0) if (findfile(Fname)) uncomment(NULL); }