UEStudio supports that natively. In UltraEdit you have to use a script. A macro is not good because it does not support variables and that would make the macro very complicated. Here is a quickly written script for your need. It may not work on Linux because of case-sensitive file names and I have not tested it with FTP files. The whole script is not fully tested. You need the function
GetFileExt from
FileNameFunctions.js- Code: Select all
/* Insert here the function GetFileExt from FileNameFunctions.js !!! */
if (UltraEdit.document.length > 0) { // Is any file open?
var sFileExt = GetFileExt(-1); // Get file extension of active file.
if (sFileExt.length > 0) { // Has the file an extension?
// Get full name of active file and convert file extension to lowercase.
var sFileName = UltraEdit.activeDocument.path.toLowerCase();
var sExtension = sFileExt.toLowerCase();
var sFileToOpen = "";
switch (sExtension) { // Is this a known file extension?
case "c": sFileToOpen = sFileName.replace(/\.c$/,".h");
break;
case "cpp": sFileToOpen = sFileName.replace(/\.cpp$/,".hpp");
break;
case "h": sFileToOpen = sFileName.replace(/\.h$/,".c");
break;
case "hpp": sFileToOpen = sFileName.replace(/\.hpp$/,".cpp");
break;
}
if (sFileToOpen.length > 0) { // Is there a header or source file for the active file?
var nDocIndex = 0; // Look if this file is already open.
do {
sFileName = UltraEdit.document[nDocIndex].path.toLowerCase();
if (sFileName == sFileToOpen) {
UltraEdit.document[nDocIndex].setActive();
break;
}
}
while (++nDocIndex < UltraEdit.document.length)
if (nDocIndex >= UltraEdit.document.length) UltraEdit.open(sFileToOpen);
}
}
}