I've tried the following code - it's not working correctly yet. _kill_timer doesn't work and the timer seems to run faster than it should. I don't understand selection functions very well. I'll try slickedit support if I can't figure it out.
#include "slick.sh"
#pragma option(strictsemicolons,on)
#pragma option(strict,on)
#pragma option(autodecl,off)
#pragma option(strictparens,on)
static int catch_selection_timer;
static bool was;
static typeless last_mark;
static int countdown;
static bool xstop;
static int xselect_active(_str markid='')
{
if ( _select_type(markid)!='' ) {
int first_col,last_col,buf_id;
_get_selinfo(first_col,last_col,buf_id,markid);
if ( buf_id==_mdi.p_child.p_buf_id ) {
return(MARK_SEARCH);
}
}
return(0);
}
static void catch_selection_callback()
{
if ( xselect_active() && !xstop ) {
if ( was ) {
_free_selection(last_mark);
}
say('ysys');
save_selection(last_mark);
was = true;
countdown = 50;
}
else if ( countdown > 0 ) {
--countdown;
}
}
_command void restore_lost_selection() name_info(',')
{
if ( countdown > 0 ) {
xstop = true;
restore_selection(last_mark);
}
}
static void start_timer()
{
catch_selection_timer = _set_timer(100, catch_selection_callback);
}
_command void xgp1() name_info(',')
{
save_selection(last_mark);
}
_command void xgp2() name_info(',')
{
xstop = true;
_kill_timer(catch_selection_timer);
}
_command void xgp4() name_info(',')
{
restore_selection(last_mark);
}
_command void xgp3() name_info(',')
{
start_timer();
xstop = false;
}
definit()
{
start_timer();
xstop = false;
countdown = 0;
}