Winedt10 添加自定義功能,並在toolbar上添加快捷命令
功能描述:
用宏實現latex+bib參考文獻的一鍵編譯。
Remark: The toolbar is the most visible and commonly used interface to many actions (especially by new users). However, a toolbar button is just an interface to invoke the associated menu item. The functionality and properties of such a button are provided through the corresponding menu item definition. This being explained, you should realize that a report "LaTeX button does not work" doesn't make sense. Buttons are there to look pretty and provide an easy interface to commonly used menu items.
此段來自Winedt10的幫助文檔,總結起來就是說,toolbar上的button項目是Main Menu中的快捷方式罷了,toolbar上所有的的項目的定義均來自Main Menu。所以想定義新的功能鍵,就必須先在Main Menu中實現該功能。
IMPORTANT: After you make changes to any particular script you must use the Load Current Script command (the first button in the Options Interface toolbar or the context popup menu) to make the changes effective immediately. It is not necessary, nor is it enough to merely restart WinEdt. In fact, no scripts are loaded at startup: the compiled raw data is stored in WinEdt.dnt (Do Not Touch). This significantly reduces the startup time and reduces the likelihood of error messages during startup.
此段是說,在修改了任何一個配置文件后,都要手動加載修改過后的配置文件。方法是:Load Current Script in the Options Interface toolbar(Option interface的左上角的一個很小的按鈕)
進入main Menu配置文件 MainMenu.ini
實現功能代碼放在文件OneClickBuild.edt中,內容如下:
Exe('%b\Exec\TeX\LaTeX.edt');
Exe('%b\Exec\TeX\BibTeX.edt');
Exe('%b\Exec\TeX\LaTeX.edt');
Exe('%b\Exec\TeX\LaTeX.edt');
Exe('%b\Exec\TeX\dvi2pdf.edt');
Winedt調用該功能代碼如下:
ITEM="OneClickBuild"
CAPTION="&OneClickBuild"
IMAGE="Play1"
MACRO="Exe('%b\Config\OneClickBuild.edt');"
然后,再進入到Toolbar.ini配置文件,添加一個快捷命令(Button),代碼
如下:
BUTTON="OneClickBuild"
至此就完成了新功能的添加。
最后別忘了 右擊MainMenu.ini選load script使得宏生效。