* Namecase() fails if a word starts with non-letter, e.g. ( or " or when selection starts with a space -- interestingly, Format (in the Manin Menu) > Change Case > Capitalize works fine in this regard (it would be beneficial to fix Namecase(), I think)
* if column mode is on, selection isn't preserved
Enjoy!
Code: Select all
/*
switches circularly between lower case--UPPER CASE--Name Case (like in MS Word)
*/
var selection = Document.SelText;
var selectionStart = Document.SelStart;
var selectionLength = Document.SelLength;
if (selection == "") {
Document.CursorWordLeft(false);
Document.CursorWordRight(true);
selection = Document.SelText;
}
if (selection == Lowercase(selection)) {
Document.InsertText(Uppercase(selection));
} else if (selection == Uppercase(selection)) {
Document.InsertText(Namecase(selection));
} else {
Document.InsertText(Lowercase(selection));
}
// bring back original selection
if (Document.IsColumnModeActive() != true) {
Document.SelStart = selectionStart;
Document.SelLength = selectionLength;
}