[script] Switch case
Posted: 06 Jun 2012 09:54
I thought about asking for this feature, but then I said to myself: Hey, why not make a script? And so I've done one:
It acts exactly like in MS Word: it switches case of a selection in a circular way: lower case --> UPPER CASE --> Name Case, and it (obviously) preserves selection -- but not in Column Mode. It works with word wrap on, too.
Rickard,
would it be possible that SelLength work on Column Mode, too? I mean that it would bring back selection as it was before deselecting. Otherwise I think one would have to use SetSelection(), but how to get all four coordinates? Perhaps you could add a new function GetSelection(), that would return, umm, an array with the four coordinates?
Code: Select all
/*
switches circularly between lower case-UPPER CASE-Name Case (like in MS Word)
*/
var s = Document.SelText;
if (s != "") {
var ss = Document.SelStart;
var sl = Document.SelLength;
if (s == Lowercase(s)) {
Document.InsertText(Uppercase(s));
} else if (s == Uppercase(s)) {
Document.InsertText(Namecase(s));
} else {
Document.InsertText(Lowercase(s));
}
if (Document.IsColumnModeActive() != true) {
Document.SelStart = ss;
Document.SelLength = sl;
}
} else {
ShowMessage("Select some text first!");
}
Rickard,
would it be possible that SelLength work on Column Mode, too? I mean that it would bring back selection as it was before deselecting. Otherwise I think one would have to use SetSelection(), but how to get all four coordinates? Perhaps you could add a new function GetSelection(), that would return, umm, an array with the four coordinates?