Skip to content

Instantly share code, notes, and snippets.

@umitanuki
Created June 2, 2010 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umitanuki/422148 to your computer and use it in GitHub Desktop.
Save umitanuki/422148 to your computer and use it in GitHub Desktop.
/*=============================
* upperCase.ms
==============================*/
#command upperCaseKeyword "Keyword"
var FgKeyword = 8;
switch(command){
case "upperCaseKeyword":
upperCaseKeyword();
break;
default:
error("command [" + command + "] not found");
break;
}
exit();
function upperCaseKeyword(){
if(view){
var selection = getSelection();
var cur, to;
if(selection[0].line == selection[1].line &&
selection[0].index == selection[1].index){
cur = EP(1);
to = EP(getLineCount(), getLine(getLineCount()).length);
}else{
cur = EP(selection[0].line);
to = EP(selection[1].line, getLine(selection[1].line).length);
}
enterUndoGroup();
gotoPoint(cur);
while(cur.line < to.line ||
(cur.line == to.line && cur.index < to.index)){
var prev = new Point(cur);
if(getColorCode() == FgKeyword){
upperCaseWord();
}
if(/^[\r\n]/.test(getText())){
charRight();
}else{
wordRight();
}
cur = getCurrentPoint();
}
leaveUndoGroup();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment