// !Mode:: "ASCII:EDT" // bibFindEntry.edt // part of the bibMacros package // (schlicht 20011219) // $Revision: 1.13 $ // ---------------------------------- GetBuild(0); IfNum(%!0,20060814,"<","Exe('%b\Macros\LaTeX\bibFindEntry54.edt');Exit;"); PushTagsandRegisters; Assign("BM_find_before"); IfStr("%$('BM_findEntry_active');","cite","=",> !"CMD('Char Left');"); IfStr("%$('BM_findEntry_active');","cite-cont","=",> !"CMD('Backspace');CMD('Backspace');CMD('Char Left');Assign('BM_find_before',',');"); IfStr("%$('BM_findEntry_active');","cite-sel","=",> !`FindInString("%L","[\{ ,]", 0,1,1111,%c-4);> FindInString("%L",",,", 0,2,1011,%!1);> ExtractByIndex(2,"%L",%!1+1,%!0-1);> CMD('Backspace');> CMD('Backspace');> GlobalMark;> GotoCol(%!1+2);> Mark(0);> GlobalReturn;> CMD("Select From Mark");> TrackCaret;> GlobalMark;> `); Release("BM_findEntry_active"); // Read the global configuration file, if it exists: IfFileExists("%b\Macros\LaTeX\bibMacros.cfg",> !"Exe('%b\Macros\LaTeX\bibMacros.cfg');",> !"IfFileExists('%B\Macros\LaTeX\bibMacros.cfg',> !'Exe(''%B\Macros\LaTeX\bibMacros.cfg'');',> !'Assign(''bib_beginLine'',''<'');> Assign(''Borb'',> !*IfFileExists(''%b\%$(|BorbFile|);'',> !''Assign(""%$(|BorbName|);"",""%b\%$(|BorbFile|);"");'',> !''IfFileExists(""%B\%$(|BorbFile|);"",> !""Assign(''''%$(|BorbName|);'''',''''%B\%$(|BorbFile|);'''');"",> !""Assign(''''%$(|BorbName|);'''',''''???'''');"");'');> Release(''BorbName'');> Release(''BorbFile'');> *);'> );"> ); // Get the bibliography: Assign("BM_bibliography",""); Assign("BM_bibliographies"); JMP("done_getbib"); :do_getbib:: PushTagsandRegisters; IfFileExists("%b\Macros\LaTeX\bibGetFile.edt",!"> Exe('%b\Macros\LaTeX\bibGetFile.edt');",!"> IfFileExists('%B\Macros\LaTeX\bibGetFile.edt',> !'Exe(''%B\Macros\LaTeX\bibGetFile.edt'');',> !'Assign(''BM_getFile'',''noBM'');');"); IfStr("%$('BM_getFile');","cancel","=","PopTagsandRegisters;PopTagsandRegisters;Exit;"); IfStr("%$('BM_getFile');","noBM","=",// stand-alone version, less smart <> !`IfStr("%$('BM_%$(|BM_file|);_%!6');","","=",> !"Assign('BM_%$(|BM_file|);_%!6','%P');");> IfFileExists("%$('BM_%$(|BM_file|);_%!6');\%!6.bib",> !"ReadFile('%$(|BM_%$(*BM_file*);_%!6|);\%!6.bib',4);",> !"Prompt('I cannot locate the the file%\ ""%!6.bib"" !> %\%\Can you help me, please?%\%\(If you were using the complete ""bibMacros"" package%\I would probably be able to find the file.)',2,3,> !'Browse(4,|Looking for ""%!6.bib""||*.bib|,|%P|);> GetFilePath(|%!4|,2);> Assign(|BM_%$(*BM_file*);_%!6|,|%!2|);> ReadFile(|%!4|,4);',> !'Exit;'> );"> );`> ); Assign("BM_bibliography","%$('BM_bibliography');%\%!4"); IfStr("%$('BM_getFile');","no","<>",> !"Assign('BM_bibliographies','%$(|BM_bibliographies|);, ""%!6.bib""');"); PopTagsandRegisters; Return; :done_getbib:: IfisMode("BibTeX","%!m",> !`// we either are in a BibTeX file: <> GetDocAsASCII(0,"%f",0,0);> Assign("BM_file","%f");> Assign("BM_bibliography","%!0");> Assign("BM_bibliographies",',"%n%t"');`,> !`// or we'll get it from the .aux file (to be on the safe side) <> Assign("BM_file","%P\%N");> IfFileExists("%$('BM_file');.aux",> !"ReadFile('%$(|BM_file|);.aux',0);",> !"Prompt('I need the file%\ ""%$(|BM_file|);.aux"".%\%\Run LaTeX on your main file, and then we can try again.',3,1);> PopTagsandRegisters;Exit;");> FindInString("%!0","\\bibdata\{*\}",1,2,11);> IfOK(!"ExtractByIndex(1,'%!0',%!1+9,%!2-1);",> !"Prompt('I found no \bibliography command%\in %$(|BM_file|);.tex.%\%\No bibliographies to search.',3,1);> PopTagsandRegisters;Exit;");> LetRegNum(3,-1);> Loop(!:> FindInString("%!1,","\(*\),",2,3,1011,%!3+1);> IfOK(!"GetTag(0,6);> // (filter out biblatex's auxiliary bibliography) IfStr('%!6','blx-%N','<>',!'Call(''do_getbib'');');",> !"Stop;");> :);> `); IfStr("%$('BM_bibliography');","","=","Prompt('Bibliography is empty!%\Cannot search for entries.',3,1);PopTagsandRegisters;Exit;"); Assign("BM_bibliography_","%$('BM_bibliography');"); ReplaceInString("%$('BM_bibliographies');","",0,0,0,0); Assign("BM_bibliographies","%!0"); IfStr("%$('bib_bibStyle');","","=","",!"> Assign('BorbName','BM_Fields_%$(|bib_bibStyle|);.cfg');> Assign('BorbFile','Macros\LaTeX\bibMacrosFields_%$(|bib_bibStyle|);.cfg');> IfStr('%[|%$(:Borb:);|];%$(|BM_Fields_%$(*bib_bibStyle*);.cfg|);','???','<>',> !'Exe(''%$(|BM_Fields_%$(*bib_bibStyle*);.cfg|);'');');"> ); IfStr("%$('bib_ENTRIES%$(|bib_bibStyle|);');","","=","Release('bib_bibStyle');"); Assign("BorbName","BM_Fields.cfg"); Assign("BorbFile","Macros\LaTeX\bibMacrosFields.cfg"); IfStr("%['%$(|Borb|);'];%$('BM_Fields.cfg');","???","=",> !"Assign('bib_ENTRIES',!'{ARTICLE}{BOOK}{BOOKLET}{INBOOK}{INCOLLECTION}{INPROCEEDINGS}> {CONFERENCE}{MANUAL}{MASTERSTHESIS}{PHDTHESIS}{MISC}{PROCEEDINGS}{TECHREPORT}{UNPUBLISHED}');",> !"Exe('%$(|BM_Fields.cfg|);');"); // show MUI MUIReset('Find Bibliography Entry'); MUISet('','position','1'); MUISet('','width','380'); //MUISet('','height','480'); // set at end Assign('mui_margin','8'); Assign('mui_tmargin','20'); MUIGet('','client width',9); LetRegNum(9,"%!9-2*%$('mui_margin');"); Assign('mui_width','%!9'); LetRegNum(9,"%$('mui_width');-4*%$('mui_margin');"); LetRegNum(9,"%!9/5"); Assign('mui_button_w','%!9'); Assign('mui_button_h','25'); MUIGet('','text width',9,'Regular Expression'); LetRegNum(9,"%!9+%$('mui_tmargin');"); Assign("mui_second_w","%!9"); LetRegNum(9,"%$('mui_width');-%$('mui_second_w');-%$('mui_tmargin');-%$('mui_margin');"); Assign("mui_first_w","%!9"); Assign("mui_curr","%$('mui_margin');"); // Button panel MUIAdd(0,0,0,"%$('mui_button_h');+2*%$('mui_margin');","pnl_bottom","TPanel"); MUISet('pnl_bottom','aligned','alBottom'); MUIAdd(0,0,"5*(%$(`mui_button_w`);+%$(`mui_margin`);)",0,'pnl_modal','TPanel','pnl_bottom'); MUISet('pnl_modal','aligned','alRight'); MUIAdd(0,"%$('mui_margin');","%$('mui_button_w');","%$('mui_button_h');", 'btn_insert','TButton','pnl_modal','&Insert'); MUISet('btn_insert','enabled','0'); MUISet('btn_insert','on click', !'Call("evt_insert");'); MUIAdd("%$('mui_button_w');+%$('mui_margin');","%$('mui_margin');","%$('mui_button_w');","%$('mui_button_h');", 'btn_sort','TButton','pnl_modal','S&ort'); MUISet('btn_sort','enabled','0'); MUISet('btn_sort','on click', !'Call("evt_sort");'); MUIAdd("2*(%$('mui_margin');+%$('mui_button_w');)","%$('mui_margin');","%$('mui_button_w');","%$('mui_button_h');", 'btn_find','TButton','pnl_modal','&Find'); MUISet('btn_find','default', '1'); MUISet('btn_find','on click', !'Call("evt_find");'); MUIAdd("3*(%$('mui_button_w');+%$('mui_margin');)","%$('mui_margin');","%$('mui_button_w');","%$('mui_button_h');", 'btn_reset','TButton','pnl_modal','Rese&t'); MUISet('btn_reset','on click', !'Call("evt_reset");'); MUIAdd("4*(%$('mui_button_w');+%$('mui_margin');)","%$('mui_margin');","%$('mui_button_w');","%$('mui_button_h');", 'btn_cancel','TButton','pnl_modal','Cancel'); MUISet('btn_cancel','cancel', '1'); MUISet('btn_cancel','on click', !'MUIHide(2);'); // Bibliographies (read-only): MUIAdd("%$('mui_margin');","%$('mui_curr');","%$('mui_width');","30", 'p_bibs','TPanel','',''); MUISet('p_bibs','color','clGray'); MUISet('p_bibs','outer bevel','1'); MUIAdd("%$('mui_margin');","%$('mui_margin');",0,0,'l_bibs','TLabel','p_bibs','in:%$("BM_bibliographies");'); MUISet('l_bibs','font color','clWhite'); MUIGet('p_bibs','height',7); LetRegNum(7,"%$('mui_curr');+%!7+8") Assign('mui_curr','%!7'); // Search strings MUIAdd("%$('mui_margin');","%$('mui_curr');","%$('mui_width');","4*%$('mui_tmargin');", 'g_strings','TGroupBox','','&Search strings'); MUIGet('g_strings','height',7); LetRegNum(7,"%$('mui_curr');+%!7+8") Assign('mui_curr','%!7'); MUIAdd("%$('mui_margin');","%$('mui_tmargin');","%$('mui_first_w');",0,'e_string_1','TEdit','g_strings'); MUIAdd("%$('mui_margin');","2*%$('mui_tmargin');+%$('mui_margin');","%$('mui_first_w');",0,'e_string_2','TEdit','g_strings'); MUISet('','active','e_string_1'); MUISet("e_string_1",'on change',"MUISet('btn_insert','default','0');MUISet('btn_find','default', '1');"); MUISet("e_string_2",'on change',"MUISet('btn_insert','default','0');MUISet('btn_find','default', '1');"); MUIAdd("%$('mui_first_w');+%$('mui_tmargin');","%$('mui_tmargin');-4","%$('mui_second_w');",0,'r_findBoth_and','TRadioButton','g_strings','Match &all'); MUIAdd("%$('mui_first_w');+%$('mui_tmargin');","2*%$('mui_tmargin');-6","%$('mui_second_w');",0,'r_findBoth_or','TRadioButton','g_strings','Match an&y'); MUISet('r_findBoth_and','checked','1'); MUISet("r_findBoth_and",'on click',"MUISet('btn_insert','default','0');MUISet('btn_find','default', '1');"); MUISet("r_findBoth_or",'on click',"MUISet('btn_insert','default','0');MUISet('btn_find','default', '1');"); // Switches MUIAdd("%$('mui_margin');","%$('mui_curr');","%$('mui_width');","4*%$('mui_tmargin');-4",'g_switches','TGroupBox','','Switches'); MUIGet('g_switches','height',7); LetRegNum(7,"%$('mui_curr');+%!7+8"); Assign('mui_curr','%!7'); MUIAdd("%$('mui_margin');","%$('mui_tmargin');","%$('mui_first_w');",0,'c_type','TComboBox','g_switches',''); MUISet('c_type','index','0'); LetRegNum(2,0); Loop(!`> FindInString("%$('bib_ENTRIES%$(|bib_bibStyle|);');","\{\(*\)\}",1,2,1001,%!2);> IfOK(!"MUIAddItem('c_type','%#0');","Stop;");> `); MUIAdd("%$('mui_margin');","2*%$('mui_tmargin');+%$('mui_margin');","%$('mui_first_w');",0,'x_results','TCheckBox','g_switches','Search &in Results'); MUISet("x_results",'enabled','0'); MUISet("x_results",'save mode','-1'); MUIAdd("%$('mui_first_w');+%$('mui_tmargin');","4+%$('mui_margin');","%$('mui_second_w');",0,'x_whole','TCheckBox','g_switches','&Whole words only'); MUIAdd("%$('mui_first_w');+%$('mui_tmargin');","4+%$('mui_margin');+%$('mui_tmargin');","%$('mui_second_w');",0,'x_cs','TCheckBox','g_switches','&Case sensitive'); MUIAdd("%$('mui_first_w');+%$('mui_tmargin');","4+%$('mui_margin');+2*%$('mui_tmargin');","%$('mui_second_w');",0,'x_re','TCheckBox','g_switches','Regular &expression'); MUISet("c_type",'on change',"MUISet('btn_insert','default','0');MUISet('btn_find','default', '1');"); MUISet("x_whole",'on click',"MUISet('btn_insert','default','0');MUISet('btn_find','default', '1');"); MUISet("x_cs",'on click',"MUISet('btn_insert','default','0');MUISet('btn_find','default', '1');"); MUISet("x_re",'on click',"MUISet('btn_insert','default','0');MUISet('btn_find','default', '1');"); MUISet("x_results",'on click',"MUISet('btn_insert','default','0');MUISet('btn_find','default', '1');"); // Results MUIAdd("%$('mui_margin');","%$('mui_curr');","%$('mui_width');","9*%$('mui_tmargin');",'g_result','TGroupBox','','&Results'); // previous results: JMP("done_previous"); :do_previous:: // we also need this somewhere else LetRegNum(2,0); LetReg(7,""); Loop(!`> FindInString("%$('BM_findEntry_%$(*BM_file*);');","<{~>}*>",1,2,1001,%!2);> IfOK(!"> ExtractByIndex(1,'%$(|BM_findEntry_%$(*BM_file*);|);',%!1,%!2-2);> FindInString('%!1','_\(0+^_\)_\(1+^_\)_\(2+^_\)_\(3+^_\)_\(4*\)_',3,4,101);> SubstituteInString('%#0','|','||',0,6);// search string <> IfStr('%#4','','=',// entry type <> !'LetReg(6,|''%!6''|);',> !'LetReg(6,|''%!6'' (%#4)|);');> IfStr('%#1','1','=',!'LetReg(6,|%!6 /w|);');// whole words? <> IfStr('%#2','1','=',!'LetReg(6,|%!6 /c|);');// case sensitive? <> IfStr('%#3','1','=',!'LetReg(6,|%!6 /r|);');// regular expression? <> IfStr('%$(|%!1|);','NONE','=',!'LetReg(6,|%!6 [NONE]|);');// any results? <> LetReg(7,'%!7|%!6');",> !"ReplaceInString('%!7','',0,0,0,7);> Stop;"> );> `); Return; :done_previous:: Call("do_previous"); MUIAdd("%$('mui_margin');","%$('mui_tmargin');","%$('mui_width');-2*%$('mui_margin');",0,'c_previous','TComboBox','g_result','|%!7'); MUISet("c_previous",'save mode','-1'); MUISet("c_previous",'index','0'); MUISet("c_previous",'on change',"MUISet('x_results','enabled','1');MUISet('btn_sort','enabled','1');Call('evt_previous');"); MUIAdd("%$('mui_margin');","2*%$('mui_tmargin');+%$('mui_margin');","%$('mui_width');-2*%$('mui_margin');","6*%$('mui_tmargin');",'ls_result','TListBox','g_result'); MUISet("ls_result",'save mode','-1'); MUISet('ls_result','on click',!"> MUISet('btn_insert','default', '1');> MUISet('btn_insert','enabled','1');> MUIGet('ls_result','text',0);> MUISet('ls_result','hint','%$(|BM_find_[%!0]|);');> "); MUISet('ls_result','on double click',"Call('evt_insert');"); MUISet('ls_result','on right click',"Call('evt_insert_entry');"); MUIGet('g_result','height',7); LetRegNum(7,"%$('mui_curr');+%!7+%$('mui_button_h');+2*%$('mui_margin');+28"); MUISet('','height','%!7'); MUILoad("%b\MUI\bibMacros\bibFindEntry-mui.edt"); MUIShow; IfOK("","PopTagsandRegisters;Exit;"); JMP('done_evt'); :evt_reset:: -------------------------------------------------------------------- MUISet('e_string_1','text',''); MUISet('e_string_2','text',''); MUISet('x_whole','checked','0'); MUISet('x_cs','checked','0'); MUISet('x_re','checked','0'); MUISet('r_findBoth_and','checked','1'); MUISet('c_type','index','0'); MUISet('c_previous','index','-1'); MUISet("x_results",'enabled','0'); MUISet('ls_result','items',''); MUISet('ls_result','hint',''); MUISet('g_result','caption','&Results'); MUISet('btn_insert','enabled','0'); MUISet('btn_sort','enabled','0'); MUISet('btn_find','default', '1'); Return; :evt_find:: -------------------------------------------------------------------- // Parse options MUIGet('e_string_1','text',1); MUIGet('e_string_2','text',2); LetReg(8,""); LetReg(9,""); IfStr("%!1","","=",> !"IfStr('%!2','','<>',!'LetReg(8,''%!2'');');",> !"LetReg(8,'%!1');> IfStr('%!2','','<>',!'LetReg(9,''%!2'');');"); MUIGetVar('x_re','checked','BM_findEntryRE'); // internally, it's a RE, therefore we have to protect special characters IfStr("%$('BM_findEntryRE');","0","=",> // !"IfStr('%!8','','<>','LetReg(8,''\""§%!8§'');');> // IfStr('%!9','','<>','LetReg(9,''\""§%!9§'');');"); !"LetRegNum(7,8);> Repeat(2,!'> LetRegNum(3,-2);> Loop(''> SetOK(1);> FindInString(|%%!%!7|,|[\\?*+@$\[\]{}||~^<>.]|,2,3,1001,%%!3+2);> IfOK(!|InsertByIndex(%!7,""%%!%!7"",""\"",%%!3);|,> |Stop;|);> '');> LetRegNum(7,9);> ');"); MUIGetVar('r_findBoth_and','checked','BM_findBoth'); IfStr("%!9","","=",> !"LetReg(9,'%!8');",> !"IfStr('%$(|BM_findBoth|);','1','=',> !'LetReg(9,''%!8&%!9'');',> !'LetReg(9,''%!8|%!9'');');"); MUIGetVar('c_type','text','BM_findEntryType'); IfStr("%$('BM_findEntryType');","","=","Release('BM_findEntryType');"); IfStr("%!9","","=","LetReg(9,' ');");// empty search //IfStr("%!9","","=",// allow empty search strings only if TYPE isn't empty <> // !"IfStr('%$(|BM_findEntryType|);','','=',> // !'Prompt(''You cannot search for empty strings!'',3,1);JMP(''done_find'');',> // !'LetReg(9,'' '');');"); MUIGetVar('x_whole','checked','BM_findEntryWhole'); MUIGetVar('x_cs','checked','BM_findEntryCS'); MUIGetVar('x_results','checked','BM_findResults'); IfFileExists("%b\MUI\bibMacros\","","CreateFolders('%b\MUI\bibMacros',1);"); MUISave("%b\MUI\bibMacros\bibFindEntry-mui.edt"); // RESET all search results (mainly for debugging purposes): IfStr("%!9","reset!","=",!`> Prompt("Forget all search results?",1,3,"","PopTagsandRegisters;Exit;");> LetRegNum(2,0);> Loop(!"> FindInString('%$(|BM_findEntry_%$(*BM_file*);|);','<\({~>}*\)>',1,2,1011,%!2);> IfOK(!'Release(''%#0'');','Stop;');> ");> Release('BM_findEntry_%$(*BM_file*);');> MUISet("c_previous","items","");> MUISet('ls_result','items','');> MUISet('ls_result','hint','');> MUISet('g_result','caption','&Results');> JMP('done_find');> `); // search within results? IfNum("%$('BM_findResults');",1,"=",!`> MUIGet('ls_result','count',1);> IfNum(%!1,0,"=",!"Prompt('No results to search in!',3,0);JMP('done_find');",!"> Release('BM_bibliography');> MUIGet('ls_result','items',0);> LetRegNum(2,0);> Loop(!'> FindInString(''%!0|'',''\(+^\|\)\|'',1,2,1001,%!2);> IfOK(!''Assign(|BM_bibliography|,|%$(*BM_bibliography*);%$(*BM_find_[%#0]*);%\%\|);'',> !''Stop;'');> ');> ");> `); MUISet('ls_result','items',''); MUISet('ls_result','hint',''); // Prepare search string LetRegNum(2,-1); LetRegNum(7,1); Loop(!`> FindInString("%!9&","{~&}*&",1,2,1011,%!2+1);> IfOK(!"> ExtractByIndex(4,'%!9',%!1,%!2-1);> // international chars // (for BibTeX, the diacritical characters should be embraced like {\`a} or {\`{a}}, // but we also allow \`a and \`{a}) SubstituteInString('%!4','à','{à|\{\\``a\}|\{\\``\{a\}\}|\\``a|\\``\{a\}}',100,4);> SubstituteInString('%!4','á','{á|\{\\''a\}|\{\\''\{a\}\}|\\''a|\\''\{a\}}',100,4);> SubstituteInString('%!4','â','{â|\{\\\^a\}|\{\\\^\{a\}\}|\\\^a|\\\^\{a\}}',100,4);> SubstituteInString('%!4','ã','{ã|\{\\\~a\}|\{\\\~\{a\}\}|\\\~a|\\\~\{a\}}',100,4);> SubstituteInString('%!4','ä','{ä|\{\\""a\}|\{\\""\{a\}\}|\\""a|\\""\{a\}|""a}',100,4);> SubstituteInString('%!4','å','{å|\{\\aa\}|\\aa }',100,4);> SubstituteInString('%!4','æ','{æ|\{\\ae\}|\\ae }',100,4);> SubstituteInString('%!4','ç','{ç|\{\\c c\}|\{\\c\{c\}\}|\\c c|\\c\{c\}}',10,4);> SubstituteInString('%!4','Ç','{Ç|\{\\c C\}|\{\\c\{C\}\}|\\c C|\\c\{C\}}',10,4);> SubstituteInString('%!4','è','{è|\{\\``e\}|\{\\``\{e\}\}|\\``e|\\``\{e\}}',100,4);> SubstituteInString('%!4','é','{é|\{\\''e\}|\{\\''\{e\}\}|\\''e|\\''\{e\}}',100,4);> SubstituteInString('%!4','ê','{ê|\{\\\^e\}|\{\\\^\{e\}\}|\\\^e|\\\^\{e\}}',100,4);> SubstituteInString('%!4','ë','{ë|\{\\""e\}|\{\\""\{e\}\}|\\""e|\\""\{e\}|""e}',100,4);> SubstituteInString('%!4','ì','{ì|\{\\``i\}|\{\\``\{i\}\}|\\``i|\\``\{i\}}',100,4);> SubstituteInString('%!4','í','{í|\{\\''i\}|\{\\''\{i\}\}|\\''i|\\''\{i\}}',100,4);> SubstituteInString('%!4','î','{î|\{\\\^i\}|\{\\\^\{i\}\}|\\\^i|\\\^\{i\}}',100,4);> SubstituteInString('%!4','ï','{ï|\{\\""i\}|\{\\""\{i\}\}|\\""i|\\""\{i\}|""i}',100,4);> SubstituteInString('%!4','ñ','{ñ|\{\\\~n\}|\{\\\~\{n\}\}|\\\~n|\\\~\{n\}}',100,4);> SubstituteInString('%!4','ò','{ò|\{\\``o\}|\{\\``\{o\}\}|\\``o|\\``\{o\}}',100,4);> SubstituteInString('%!4','ó','{ó|\{\\''o\}|\{\\''\{o\}\}|\\''o|\\''\{o\}}',100,4);> SubstituteInString('%!4','ô','{ô|\{\\\^o\}|\{\\\^\{o\}\}|\\\^o|\\\^\{o\}}',100,4);> SubstituteInString('%!4','õ','{õ|\{\\\~o\}|\{\\\~\{o\}\}|\\\~o|\\\~\{o\}}',100,4);> SubstituteInString('%!4','ö','{ö|\{\\""o\}|\{\\""\{o\}\}|\\""o|\\""\{o\}|""o}',100,4);> SubstituteInString('%!4','œ','{œ|\{\\oe\}|\\oe }',100,4);> SubstituteInString('%!4','ù','{ù|\{\\``u\}|\{\\``\{u\}\}|\\``u|\\``\{u\}}',100,4);> SubstituteInString('%!4','ú','{ú|\{\\''u\}|\{\\''\{u\}\}|\\''u|\\''\{u\}}',100,4);> SubstituteInString('%!4','û','{û|\{\\\^u\}|\{\\\^\{u\}\}|\\\^u|\\\^\{u\}}',100,4);> SubstituteInString('%!4','ü','{ü|\{\\""u\}|\{\\""\{u\}\}|\\""u|\\""\{u\}|""u}',100,4);> SubstituteInString('%!4','š','{š|\{\\v s\}|\{\\v\{s\}\}|\\v s|\\v\{s\}}',10,4);> SubstituteInString('%!4','š','{š|\{\\v S\}|\{\\v\{S\}\}|\\v S|\\v\{S\}}',10,4);> SubstituteInString('%!4','ß','{ß|\{\\ss\}|\\ss |""s}',0,4);> SubstituteInString('%!4','ý','{ý|\{\\''y\}|\{\\''\{y\}\}|\\''y|\\''\{y\}}',100,4);> SubstituteInString('%!4','ÿ','{ÿ|\{\\""y\}|\{\\""\{y\}\}|\\""y|\\""\{y\}|""y}',100,4);> SubstituteInString('%!4','ž','{ž|\{\\v z\}|\{\\v\{z\}\}|\\v z|\\v\{z\}}',10,4);> SubstituteInString('%!4','Ž','{Ž|\{\\v Z\}|\{\\v\{Z\}\}|\\v Z|\\v\{Z\}}',10,4);> IfStr('%$(|BM_findEntryWhole|);','1','=',> !'Assign(''BM_findEntryString%!7'',''$~Alpha${%!4}$~Alpha$'');',> !'Assign(''BM_findEntryString%!7'',''%!4'');');> LetRegNum(7,%!7+1);",> "Stop;");> `); Assign("BM_query_string",> "BM_findEntry_%$('BM_file');_%!9_%$('BM_findEntryWhole');_%$('BM_findEntryCS');_%$('BM_findEntryRE');_%$('BM_findEntryType');_"); // Already searched for this one? IfNum("%$('BM_findResults');",1,"<>",!`> IfStr("%$('%$(|BM_query_string|);');","","=",> !``Assign("BM_findEntry_%$(|BM_file|);","%$('BM_query_string');%\%$('BM_findEntry_%$(|BM_file|);');");``,> !``SetOK(1);> FindInString("%$('BM_findEntry_%$(|BM_file|);');","<\""§%$('BM_query_string');§>",1,2,11);> IfOK(!"> ReplaceInString('%$(|BM_findEntry_%$(*BM_file*);|);','',%!1,%!2,0,1);> Assign('BM_findEntry_%$(|BM_file|);','%$(|BM_query_string|);%\%!1');");``);> `); // Find entries Release("%$('BM_query_string');"); GetLength(8,"%$('BM_bibliography');"); LetRegNum(2,0); Loop(!`> // visual indicator Release("working");> Repeat("76-((%!2*75)/%!8)",!"Assign('working','%$(|working|);|');");> StartWorking("%$('working');");> // jump to the next entry: SetOK(1);> FindInString("%$('BM_bibliography');","%$('bib_beginLine');\@%$('BM_findEntryType');",1,2,1001,%!2);> IfOK("","Stop;");> SetOK(1);> FindInString("%$('BM_bibliography');","%$('BM_findEntryString1');",1,2,1001,%!2);> IfOK(!"> SetOK(1);> FindInString('%$(|BM_bibliography|);','%$(|bib_beginLine|);\@+{$Alpha$}@{ }{\{@{>|{\{@{>|{\{@{>|{\{@{>|{\{*\}}|^{\}}}\}}|^{\}}}\}}|^{\}}}\}}|^{\}}}\}}|{(@{>|{(@{>|{(@{>|{(@{>|{(*)}|^{)}})}|^{)}})}|^{)}})}|^{)}})}',1,3,1101,%!2);> ExtractByIndex(1,'%$(|BM_bibliography|);',%!1,%!3);> SubstituteInString('%!1','$[#9]$',' ',1,1);> // correct entry type? IfStr('%$(|BM_findEntryType|);','','<>',!'> FindInString(|%!1|,|\@*{\{||(}|,3,4,1);> ExtractByIndex(3,|%!1|,%!3+1,%!4-1);> FormatString(|%!3|,3,|trimboth|);> IfIStr(|%!3|,|%$(*BM_findEntryType*);|,|<>|,|LetReg(1,||||);|);> ');> // find additional search strings Repeat(%!7-1,!'> SetOK(1);> FindInString(''%!1'',''%$(|BM_findEntryString%!c|);'',3,4,''%$(|BM_findEntryCS|);1'');> IfOK('''',''LetReg(1,||);'');> ');> IfStr('%!1','','=','',!'> SetOK(1);> FindInString(''%!1'',''{\{|(}+^{,}'',4,5,11);> ExtractByIndex(3,''%!1'',%!4+1,%!5);> FormatString(''%!3'',3,''trimboth'');> MUIAddItem(|ls_result|,|%!3|);> // wasting lots of registers to remember the complete entries: Assign(|BM_find_[%!3]|,|%!1|);> // store search result for next time: IfNum(''%$(|BM_findResults|);'',1,''<>'',!''> Assign(|%$(*BM_query_string*);|,|%$(:%$(*BM_query_string*):);%!3%\|);> '');> ');",> "Stop;"> );> `); StopWorking; // found anything? MUIGet('ls_result','count',7); MUISet('g_result','caption','&Results (%!7 items)'); IfNum(%!7,0,"=",> !"IfNum('%$(|BM_findResults|);',1,'<>',!'Assign(''%$(|BM_query_string|);'',''NONE'');');> SubstituteInString('%!9','&','&&',0,9);> Prompt('No %$(|BM_findEntryType|); entries matching string%\ ''%!9''');> MUISet('x_results','enabled','0');> MUISet('btn_sort', 'enabled','0');",> !"MUISet('x_results','enabled','1');> MUISet('btn_sort', 'enabled','1');"); // update previous results, including current search IfNum("%$('BM_findResults');",1,"<>",!`> PushTagsandRegisters;> Call('do_previous');> MUISet('c_previous','items','%!7');> MUISet('c_previous','index','0');> PopTagsandRegisters;> `); // restore bibliography in case of "Search in results" Assign("BM_bibliography","%$('BM_bibliography_');"); :done_find:: Return; // from :evt_find:: :evt_previous:: -------------------------------------------------------------------- // previous queries MUIGet('c_previous','text',7); IfStr("%!7","","<>",> !`LetReg(0,"BM_findEntry_%$(|BM_file|);");> FindInString("%!7","'\(*\)'",3,4,1);> LetReg(0,"%!0_%#0");> FindInString("%!7","/w",3,4);> IfOK(!"LetReg(0,'%!0_1');",!"LetReg(0,'%!0_0');");> FindInString("%!7","/c",3,4);> IfOK(!"LetReg(0,'%!0_1');",!"LetReg(0,'%!0_0');");> FindInString("%!7","/r",3,4);> IfOK(!"LetReg(0,'%!0_1');",!"LetReg(0,'%!0_0');");> FindInString("%!7","(\(*\))",3,4,1);> IfOK(!"LetReg(0,'%!0_%#0_');",!"LetReg(0,'%!0__');");> Assign("BM_prev_query_string","%!0");> `); MUISet('ls_result','items',''); MUISet('ls_result','hint',''); StartWorking(""); LetRegNum(2,0); Loop(!"> FindInString('%$(|%$(*BM_prev_query_string*);|);','<\({~>}*\)>',1,2,1011,%!2);> IfOK(!'MUIAddItem(''ls_result'',''%#0'');','Stop;');> "); MUIGet('ls_result','count',7); MUISet('g_result','caption','&Results (%!7 items)'); IfNum(%!7,0,"=",!"MUISet('x_results','enabled','0');MUISet('btn_sort','enabled','0');") StopWorking; Return; :evt_sort:: -------------------------------------------------------------------- MUIGet('ls_result','items','0'); // it is stupid enough to lose a key in a bar, but to use a bar in a key ...? SubstituteInString("%!0","||","&@$!",0,0); LstEnum("%!0","|"); LstSort(1,-1,1,1,-1,1); LstGetStr(0,"|"); SubstituteInString("%!0","&@$!","||",0,0); LstRelease; MUISet('ls_result','items','%!0'); Return; :evt_insert:: -------------------------------------------------------------------- MUIGet("ls_result",'text',0); BeginGroup; InsText("%$('BM_find_before');%!0"); EndGroup; MUIHide(1); Return; :evt_insert_entry:: --------------------------------------------------------------- MUIGet("ls_result",'text',0); BeginGroup; InsText("%$('BM_find_[%!0]');"); EndGroup; MUIHide(1); Return; :done_evt:: -------------------------------------------------------------------- PopTagsandRegisters; End; //============================================================================= This macro finds all entries containing a specified string (possibly a Regular Expression) and inserts the key from the one you choose. If you invoke the macro from your main TeX file, all \bibliography's will be searched (you have to have LaTeX'ed the file once); if you invoke it from a BibTeX file, only this one will be searched. This macro requires WinEdt 5.5, in particular the new MUI. The macro is part of the bibMacros package (available from www.winedt.org), but can also be used as a standalone version. R Schlicht w.m.l@gmx.net //------------------------------------------------------------------------------ $Id: bibFindEntry.edt,v 1.13 2007-06-07 20:08:46+02 schlicht Exp schlicht $