Skip to content

Instantly share code, notes, and snippets.

@eral
Last active August 29, 2015 14:07
Show Gist options
  • Save eral/7427e00b8d3fb78d10a7 to your computer and use it in GitHub Desktop.
Save eral/7427e00b8d3fb78d10a7 to your computer and use it in GitHub Desktop.
カーソルを任意の位置に移動させるサクラエディタ用マクロ関数
// Created by ERAL
// This is free and unencumbered software released into the public domain.
function GetCursorPosition() {
return {'x':0|Editor.ExpandParameter('$x'), 'y':0|Editor.ExpandParameter('$y')};
}
function SetCursorPosition(pos) {
var is_text_selected = 0 != Editor.IsTextSelected();
var crnt_pos = null;
while (true) {
crnt_pos = GetCursorPosition();
if (crnt_pos.y == pos.y) {
break;
}
for (var i = 0, i_max = crnt_pos.y - pos.y; i < i_max; ++i) {
((is_text_selected)? Editor.Up_Sel: Editor.Up);
}
for (var i = 0, i_max = pos.y - crnt_pos.y; i < i_max; ++i) {
((is_text_selected)? Editor.Down_Sel(): Editor.Down());
}
}
crnt_pos = GetCursorPosition();
for (var i = 0, i_max = crnt_pos.x - pos.x; i < i_max; ++i) {
((is_text_selected)? Editor.Left_Sel: Editor.Left);
}
for (var i = 0, i_max = pos.x - crnt_pos.x; i < i_max; ++i) {
((is_text_selected)? Editor.Right_Sel: Editor.Right);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment