Hi,
How is it possible to integrate Perltidy in the UE IDE, to use Perltidy directly out of the editor?
Has anyone experience with Perltidy and Ultraedit?
Ciao - Jens
Welcome to the IDM Forum. This forum is meant as a user-to-user support mechanism where users can share knowledge and tips for all IDM software.
Since these forums are user-to-user based, IDM does not regularly read or reply to the posts in this forum. For problem reports, suggestions, or feature requests, you must email us directly. Our trained technical support staff answers most inquiries within 30 minutes.
jens_g wrote:How is it possible to integrate Perltidy in the UE IDE, to use Perltidy directly out of the editor?
perltidy "%f"
/*
* Run perltidy on the current selection
*/
if (UltraEdit.activeDocument.isSel()) {
var tidyin = "C:\\Temp\\perltidy.txt";
var tidyout = tidyin + '.tdy';
// Hack! Thanks, jorrasdk
// http://www.ultraedit.com/index.php?name=Forums&file=viewtopic&t=4571
var idx = getActiveDocumentIndex();
// Switch to a clipboard that's probably not in use
UltraEdit.selectClipboard(9);
// Save selection to temporary file
UltraEdit.activeDocument.copy();
UltraEdit.newFile();
UltraEdit.activeDocument.paste();
UltraEdit.saveAs(tidyin);
// Run perltidy on code from selection
// Tool must exist and be configured to run 'perltidy "%f"'
UltraEdit.runTool("perltidy file");
// Close tempfile
UltraEdit.closeFile(tidyin, 2);
// Get perltidy output
UltraEdit.open(tidyout);
UltraEdit.activeDocument.selectAll();
UltraEdit.activeDocument.copy();
UltraEdit.closeFile(tidyout, 2);
// Replace selection with output of perltidy
UltraEdit.document[idx].paste(); // why doesn't activeDocument work here?
// Restore the clipboard we were probably using before
UltraEdit.selectClipboard(0);
}
/* Find the tab index of the active document */
function getActiveDocumentIndex() {
var tabindex = -1; /* start value */
for (i = 0; i < UltraEdit.document.length; i++) {
if (UltraEdit.activeDocument.path==UltraEdit.document[i].path) {
tabindex = i;
break;
}
}
return tabindex;
}
