April 11, 2013 at 8:46 am #10943
Stefan
Participant
Woohoo :-D
That works! Many thanks.
But leads to next question:
how to determine between line and block selection?
The answer I found in the help:
EmEditor Help – EmEditor Macro Reference – Selection Object
Mode Property
So I can use code like this:
nMode = document.selection.Mode;
switch( nMode & eeModeMask ) {
case eeModeStream:
alert( "Stream selection mode.");
work();
document.selection.text = out;
break;
case eeModeLine:
alert( "Line selection mode." );
work();
document.selection.text = out;
break;
case eeModeBox:
alert( "Vertical selection mode.");
oldCB = clipboardData.getData("Text"); //store
work();
clipboardData.setData("BoxText", out);
document.selection.Paste(eeCopyUnicode);
clipboardData.setData("Text", oldCB); //re set
break;
}
if( nMode & eeModeKeyboard ) alert( "And also the keyboard selection mode." );
function work(){
sel = document.selection.text;
Lines = sel.split("rn");
out = "";
for(L=0,E=Lines.length; L<E; L++){
line = Lines[L];
out += line.replace("i", "X");
if(L<E-1)out += "rn";
}
alert(out);
}
Fun! 8-)
… I gonna try this now for my real work.
Thank you much Yutaka!