I’m looking for a way to programmatically position the cursor at the end of a Script Debugger document so that I can append text to it without altering the visual appearance of the code above it. If I update the entire source text it will all appear formatted as new, uncompiled code. I would prefer for only the newly added text at the bottom of the script to appear formatted this way.
I find the editable ‘selection ASObjC range’ value to manipulate the cursor, but no method to determine the limits of the ‘selection ASObjC range’ values. I can do a select all and then get the range of the ‘selection ASObjC range’ to find the end of the document’s text range then set the origin of ‘selection ASObjC range’ to that value and it’s range to 0. It seems to be more reliable to select all and press the right arrow to jump to end-of-selection.
Does anyone here know a better or more reliable method for doing this? This one can only operate on the frontmost document due to the select all keystroke command.
on ScriptDebugger_Move_Cursor_To_End()
tell application "Script Debugger"
tell document 1
tell application "System Events"
keystroke "a" using command down
key code 124
end tell
end tell
end tell
end ScriptDebugger_Move_Cursor_To_End