#pragma rtGlobals=1 // Use modern global access method. StrConstant kBlack = "#000000" Menu "GeSHi" "Create Igor Language File",/Q,CreateLanguagePrompt() End Function RedBD(num) // Reduces the bit depth of a number from 16 bit to 8 bit Variable num num /= 2^16 num *= 2^8 num = floor(num) return num End Function CreateLanguagePrompt() Variable colorsToUse = 1 Prompt colorsToUse, "Select color set", popup, "Use Igor's default syntax colors;Use syntax colors currently being used;" DoPrompt "", colorsToUse if (V_flag == 1) // User hit cancel. return 0 endif CreateLanguageFile(colorsToUse - 1) End Function CreateLanguageFile(colorsToUse) Variable colorsToUse // see description in CreateIgorGeSHiLanguage() function String fileText = "" String fileNameStr Variable refNum // open file Open/M="Save Language File As..." /T=".php" refNum as "igor.php" if (strlen(S_fileName) < 1) // User hit cancel button. return 0 endif fileNameStr = S_fileName fileText = CreateIgorGeSHiLanguage(colorsToUse, fileNameStr) // write text to file Variable startPos = 0 Variable posDelta = 300 Variable n, length = strlen(fileText) For (n=0; n 0) // dont add item if its empty sprintf item, "'%s', ", currentItem endif keywords += item newNum += 1 EndFor keywords = RemoveEnding(keywords, " ") keywords = RemoveEnding(keywords, ",") keywords = RemoveEnding(keywords, " ") file += keywords file += "\n\t\t\t),\n" // function, macro, window, procs, object and reference keywords file += "\t\t2 => array(" // reverse sort all of the lists of functions, operations, etc. list = SortList(TypesList(), ";", 5) // reverse sort list num = ItemsInList(list, ";") newNum = 0 keywords = "", item = "" For (n=0; n 0) // dont add item if its empty sprintf item, "'%s', ", currentItem endif keywords += item newNum += 1 EndFor keywords = RemoveEnding(keywords, " ") keywords = RemoveEnding(keywords, ",") keywords = RemoveEnding(keywords, " ") file += keywords file += "\n\t\t\t),\n" // built in Igor functions file += "\t\t3 => array(" // reverse sort all of the lists of functions, operations, etc. list = SortList(FunctionList("*", ";", "KIND:1"), ";", 5) // reverse sort list num = ItemsInList(list, ";") newNum = 0 keywords = "", item = "" For (n=0; n 0) // dont add item if its empty sprintf item, "'%s', ", currentItem endif keywords += item newNum += 1 EndFor keywords = RemoveEnding(keywords, " ") keywords = RemoveEnding(keywords, ",") keywords = RemoveEnding(keywords, " ") file += keywords file += "\n\t\t\t),\n" // built in Igor operations file += "\t\t4 => array(" // reverse sort all of the lists of functions, operations, etc. list = SortList(OperationList("*", ";", "internal"), ";", 5) // reverse sort list num = ItemsInList(list, ";") newNum = 0 keywords = "", item = "" For (n=0; n 0) // dont add item if its empty sprintf item, "'%s', ", currentItem endif keywords += item newNum += 1 EndFor keywords = RemoveEnding(keywords, " ") keywords = RemoveEnding(keywords, ",") keywords = RemoveEnding(keywords, " ") file += keywords file += "\n\t\t\t),\n" // pragmas control file += "\t\t5 => array(" // reverse sort all of the lists of functions, operations, etc. list = SortList(PragmasList(), ";", 5) // reverse sort list num = ItemsInList(list, ";") newNum = 0 keywords = "", item = "" For (n=0; n 0) // dont add item if its empty sprintf item, "'%s', ", currentItem endif keywords += item newNum += 1 EndFor keywords = RemoveEnding(keywords, " ") keywords = RemoveEnding(keywords, ",") keywords = RemoveEnding(keywords, " ") file += keywords file += "\n\t\t\t),\n" file += "\t\t),\n" file += "\t'SYMBOLS' => array(\n" file += "\t\t'(', ')', '[', ']', '{', '}', '!', '@', '%', '&', '*', '|', '/', '<', '>'\n" file += "\t\t),\n" file += "\t'CASE_SENSITIVE' => array(\n" file += "\t\tGESHI_COMMENTS => false,\n" file += "\t\t\t1 => false,\n" file += "\t\t\t2 => false,\n" file += "\t\t\t3 => false,\n" file += "\t\t\t4 => false,\n" file += "\t\t\t5 => false\n" file += "\t\t\t),\n" file += "\t'STYLES' => array(\n" file += "\t\t'KEYWORDS' => array(\n" // poundColor file += "\t\t\t1 => 'color: " + langColor + ";',\n" // flow control file += "\t\t\t2 => 'color: " + langColor + ";',\n" // variables, functions, data and reference types file += "\t\t\t3 => 'color: " + biFuncColor + ";',\n" // Igor built in functions file += "\t\t\t4 => 'color: " + biOpColor + ";',\n" // Igor built in operations file += "\t\t\t5 => 'color: " + poundColor + ";'\n" // compiler directives file += "\t\t\t),\n" file += "\t\t'COMMENTS' => array(\n" file += "\t\t\t1 => 'color: " + commColor + "; font-style: italic;',\n" // single line comments file += "\t\t\t),\n" file += "\t\t'ESCAPE_CHAR' => array(\n" file += "\t\t\t0 => 'color: " + strColor + ";'\n" file += "\t\t\t),\n" file += "\t\t'BRACKETS' => array(\n" file += "\t\t\t0 => 'color: " + kBlack + ";'\n" file += "\t\t\t),\n" file += "\t\t'STRINGS' => array(\n" file += "\t\t\t0 => 'color: " + strColor + ";'\n" file += "\t\t\t),\n" file += "\t\t'NUMBERS' => array(\n" file += "\t\t\t0 => 'color: " + kBlack + ";'\n" file += "\t\t\t),\n" file += "\t\t'METHODS' => array(\n" file += "\t\t\t0 => 'color: " + kBlack + ";'\n" file += "\t\t\t),\n" file += "\t\t'SYMBOLS' => array(\n" file += "\t\t\t0 => 'color: " + kBlack + ";'\n" file += "\t\t\t),\n" file += "\t\t'REGEXPS' => array(\n" file += "\t\t\t0 => 'color: " + kBlack + ";'\n" file += "\t\t\t),\n" file += "\t\t'SCRIPT' => array(\n" file += "\t\t\t0 => '',\n" file += "\t\t\t1 => '',\n" file += "\t\t\t2 => '',\n" file += "\t\t\t3 => ''\n" file += "\t\t\t)\n" file += "\t\t\t),\n" file += "\t'URLS' => array(\n" file += "\t\t\t1 => '',\n" file += "\t\t\t2 => '',\n" file += "\t\t\t3 => '',\n" file += "\t\t\t4 => '',\n" file += "\t\t\t5 => ''\n" file += "\t\t\t),\n" file += "\t'OOLANG' => false,\n" file += "\t'OBJECT_SPLITTERS' => array(\n" file += "\t\t1 => '',\n" file += "\t\t2 => ''\n" file += "\t\t),\n" file += "\t'REGEXPS' => array(\n" file += "\t\t0 => \"[\\$]{1,2}[a-zA-Z_][a-zA-Z0-9_]*\",\n" file += "\t\t1 => array(\n" file += "\t\t\tGESHI_SEARCH => \"([a-zA-Z]+)(\\n)(.*)(\\n)(\\1;?)\",\n" file += "\t\t\tGESHI_REPLACE => '\\3',\n" file += "\t\t\tGESHI_BEFORE => '\\1\\2',\n" file += "\t\t\tGESHI_AFTER => '\\4\\5',\n" file += "\t\t\tGESHI_MODIFIERS => 'siU'\n" file += "\t\t\t)\n" file += "\t\t),\n" file += "\t'STRICT_MODE_APPLIES' => GESHI_NEVER,\n" file += "\t'SCRIPT_DELIMITERS' => array(\n" file += "\t\t0 => array(\n" file += "\t\t\t' '?>'\n" file += "\t\t\t),\n" file += "\t\t1 => array(\n" file += "\t\t\t' '?>'\n" file += "\t\t\t),\n" file += "\t\t2 => array(\n" file += "\t\t\t'<%' => '%>'\n" file += "\t\t\t),\n" file += "\t\t3 => array(\n" file += "\t\t\t''\n" file += "\t\t\t)\n" file += "\t\t\t),\n" file += "\t'HIGHLIGHT_STRICT_BLOCK' => array(\n" file += "\t\t0 => true,\n" file += "\t\t1 => true,\n" file += "\t\t2 => true,\n" file += "\t\t3 => true,\n" file += "\t\t4 => true,\n" file += "\t\t5 => true\n" file += "\t\t)\n" file += ");" return file End Function/S FlowControlList() String list = "" // flow control list += "if;else;elseif;endif;for;endfor;" list += "strswitch;switch;case;endswitch;" list += "do;while;try;catch;endtry;break;continue;return;" return list End Function/S TypesList() String list = "" // data types list += "variable;string;constant;strconstant;" // reference types list += "NVAR;SVAR;WAVE;STRUCT;" // function/procedure/macro types list += "function;end;static;macro;window;graph;Structure;EndStructure;EndMacro;" list += "FuncFit;Proc;Picture;Menu;SubMenu;ThreadSafe;MultiThread;" // Commands list += "Prompt;DoPrompt;" return list End Function/S PragmasList() String list = "#include;#pragma;" return list End