Has anyone had selectWord act strangely since the last update (I am not really sure if that's when it started, can't go back and check tho).
Anyways, I made a script for checking the text at the cursor to see if it matches any of my predefined texts (had an old macro for this before, but it's ways faster with JS).
ie, like this (cut down version, but it's basically it, only removed unimportant function definitions):
It just checks the text at the cursor and inputs the correct 'snippet' (template in this case) instead of the text. I invoke the script by pressing shift + space.
Now, here's the thing(s):
sometimes it seems the cursor position gets completely off, especially in conjunction with undo, results in selectWord to show contents I have no idea where it found (often chars with a value < 10 (00-0F) )
[$replace$] doesn't seem to work as it used to when inserting from JS (the indentation is completely ignored, which I think wasn't the case previously).
The first I solved with doing this before invoking selectWord();
UltraEdit.activeDocument.gotoLine(0,UltraEdit.activeDocument.currentColumnNum);
The second problem I have no idea as to how to get around, anyone has any idea? (I have a version without templates where I fix the indentation right in the script, but it'd be tedious to do for all templates)
Anyways, I made a script for checking the text at the cursor to see if it matches any of my predefined texts (had an old macro for this before, but it's ways faster with JS).
ie, like this (cut down version, but it's basically it, only removed unimportant function definitions):
Code: Select all
setUpEnv();
var word = UltraEdit.activeDocument.selectWord();
word = UltraEdit.activeDocument.selection;
switch (word)
{
case "dvc":
UltraEdit.activeDocument.deleteText();
UltraEdit.activeDocument.insertTemplate(24);
break;
case "dvi":
UltraEdit.activeDocument.deleteText();
UltraEdit.activeDocument.insertTemplate(28);
break;
case "dvl":
UltraEdit.activeDocument.deleteText();
UltraEdit.activeDocument.insertTemplate(29);
break;
.
.
.
.
default:
var ColNum = UltraEdit.activeDocument.currentColumnNum;
if (typeof(UltraEdit.activeDocumentIdx) == "undefined") ColNum++;
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, ColNum); // reset selection
}
function setUpEnv()
{
UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.activeDocument.hexOff();
UltraEdit.ueReOn();
}
Now, here's the thing(s):
sometimes it seems the cursor position gets completely off, especially in conjunction with undo, results in selectWord to show contents I have no idea where it found (often chars with a value < 10 (00-0F) )
[$replace$] doesn't seem to work as it used to when inserting from JS (the indentation is completely ignored, which I think wasn't the case previously).
The first I solved with doing this before invoking selectWord();
UltraEdit.activeDocument.gotoLine(0,UltraEdit.activeDocument.currentColumnNum);
The second problem I have no idea as to how to get around, anyone has any idea? (I have a version without templates where I fix the indentation right in the script, but it'd be tedious to do for all templates)