Last active
August 29, 2015 14:07
-
-
Save eral/7427e00b8d3fb78d10a7 to your computer and use it in GitHub Desktop.
カーソルを任意の位置に移動させるサクラエディタ用マクロ関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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