First change stdprocs.e; adding the call_list('_on_mygotfocus_'); line.
void _on_got_focus()
{
if (command_state()) {
if (p_object==OI_TEXT_BOX) {
if (p_window_id==_cmdline ||
!p_auto_select || p_ReadOnly || p_style==PSCBO_NOEDIT ||
!def_focus_select
) return;
p_MouseActivate=MA_NOACTIVATEANDEAT;
_set_sel(1,length(p_text)+1);
}
ArgumentCompletionTerminate();
return;
}
ArgumentCompletionTerminate();
//p_MouseActivate=MA_NOACTIVATE;
p_MouseActivate=MA_NOACTIVATEANDEAT;
switch_buffer('','W');
//msg('_on_mygotfocus_wind');
//call_list('_gotfocus_');
//m.c.r+
call_list('_on_mygotfocus_');
//m.c.r-
}
Then LOAD that file.
Create __swap_window.e
#include "slick.sh"
definit(){
}
/// __swap_window.e
void _on_mygotfocus_wind()
{
//msg('_on_mygotfocus_wind');
maybe_swap_windows();
}
int win_to_swap=0;
void maybe_swap_windows()
{
if (!_mdi.p_child) {return;}
if (!win_to_swap) {return;}
if (win_to_swap) {
if (win_to_swap!=_mdi.p_child) {
window_swap_pos(_mdi.p_child,win_to_swap);
win_to_swap=0;
}
}
}
void window_swap_pos(int id1,int id2)
{
x=id1.p_x;
y=id1.p_y;
int w=id1.p_width;
h=id1.p_height;
id1.p_x=id2.p_x;
id1.p_y=id2.p_y;
id1.p_width=id2.p_width;
id1.p_height=id2.p_height;
id2.p_x=x;
id2.p_y=y;
id2.p_width=w;
id2.p_height=h;
}
/**
* Prepare to swap current window with the next activated window.
*
* Usage:Assign this to a hotkey or mousemenu; invoke the command then
* click or activate another window.
*
* Result: Two windows swap positions.
*
*/
_command void window_swap() name_info(','VSARG2_REQUIRES_MDI_EDITORCTL)
//window_swap is bound to Ins Ins C-`
{
win_to_swap=_mdi.p_child;
}
LOAD and assign to key or mouse menu.