/** ToggleHeaderSource.bsh by Alan Ezust alan dot ezust at gmail dot com 2005-11-09 version 0.4 - works with c and cxx files too. A jedit beanshell macro that toggles your current buffer between the header file (.h) and the source file (.cpp). Enables you to switch the current text buffer between c++ header and sourcecode file. If the file does not already exist, it opens a buffer of that name for you (!). */ String[] sourceExtensions = new String[]{"cpp", "c", "cxx" }; String defaultSourceExtension = "cpp"; String getSourceFile(String baseName) { int numExt = sourceExtensions.length; String tryFile = null; for (int i=numExt-1; i>=0; --i) { String ext = sourceExtensions[i]; String tryFile = baseName + "." + ext; File f = new File(tryFile); if (f.canRead()) return f.getPath(); } return baseName + "." + defaultSourceExtension; } boolean isSourceFile(String extension) { for (int i=0; i