acarril / StataLinux

Sublime Text 3 plugin that adds support for Stata (all versions) in Linux.
MIT License
7 stars 2 forks source link

Execution line (`do <file>`) is not executed in Stata if Command pane is completely hidden #4

Open acarril opened 4 years ago

acarril commented 4 years ago

Peek 2020-02-06 09-06

When Stata's command pane is fully hidden, the program is only able to paste the execution line do <file>, but it won't select the text that was already in there (with crtl+a) and, most importantly, won't execute the line (with Return).

I have no clue what may be causing this issue, although it is a minor one.

avila commented 3 years ago

funny bug. Apparently when the command pane is hidden, stata's accepts any input only once. And then the focus goes somewhere else. This can be overcome by typing Ctrl+1 in between every keystroke. So the following works:

if [ ! -z "$winid_stata" ]; then
    xdotool key  --window ${winid_stata} --delay 10 ctrl+a
    xdotool key  --window ${winid_stata} --delay 0 ctrl+1
    xdotool type --window ${winid_stata} --delay 0 "${string}" 
    xdotool sleep 0.010 #sleep in seconds
    xdotool key  --window ${winid_stata} --delay 1 ctrl+1
    xdotool key  --window ${winid_stata} --delay 1 Return
else
    echo "No Stata window open."
    exit 1
fi

I'm not sure I would implement it though because it is very sensible to the --delay flags. After long testing, the above constellation of delays worked quite reliably. But still, I am not sure how the delay of 0 might affect older machines.
I am writing here in case someone really wants to use the command pane fully closed. it does work fine (without any of the xdotook key ctrl+1 lines) if the command pane is nearly fully closed.