Created
June 10, 2012 06:08
-
-
Save saitoha/2904086 to your computer and use it in GitHub Desktop.
mouse reporting support for "cygwin ck terminal emulator" 3.3.4 (http://www.geocities.jp/meir000/ck/)
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
diff -ur ck-3.3.4.bak/src/app.cpp ck-3.3.4/src/app.cpp | |
--- ck-3.3.4.bak/src/app.cpp 2011-02-18 23:04:39.000000000 +0900 | |
+++ ck-3.3.4/src/app.cpp 2012-06-10 14:15:30.119755200 +0900 | |
@@ -203,11 +203,11 @@ | |
} | |
return id; | |
} | |
-static HRESULT invoke_v(IDispatch* disp, DISPID id, UINT argc, VARIANTARG* argv){ | |
+static HRESULT invoke_v(IDispatch* disp, DISPID id, UINT argc, VARIANTARG* argv, VARIANT *presult = NULL){ | |
HRESULT hr=E_FAIL; | |
if(disp && id){ | |
DISPPARAMS param = { argv, NULL, argc, 0 }; | |
- hr = disp->Invoke(id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶m, 0,0,0); | |
+ hr = disp->Invoke(id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶m, presult,0,0); | |
} | |
return hr; | |
} | |
@@ -272,6 +272,9 @@ | |
DISPID m_event_app_on_new_command; | |
DISPID m_event_wnd_on_closed; | |
DISPID m_event_wnd_on_key_down; | |
+ DISPID m_event_wnd_on_mouse_down; | |
+ DISPID m_event_wnd_on_mouse_up; | |
+ DISPID m_event_wnd_on_mouse_move; | |
DISPID m_event_wnd_on_mouse_wheel; | |
DISPID m_event_wnd_on_menu_init; | |
DISPID m_event_wnd_on_menu_execute; | |
@@ -433,15 +436,88 @@ | |
invoke_v(m_event_root, m_event_wnd_on_key_down, 2, args); | |
return S_OK; | |
} | |
- STDMETHOD(OnMouseWheel)(IWnd* sender, int delta){ | |
- VARIANTARG args[3]; | |
- args[2].vt = VT_DISPATCH; | |
- args[2].pdispVal = sender; | |
+ STDMETHOD(OnMouseDown)(IWnd* sender, LONG button, LONG x, LONG y, LONG modifier, VARIANT_BOOL *presult){ | |
+ VARIANTARG args[5]; | |
+ VARIANT result; | |
+ VariantInit(&result); | |
+ result.vt = VT_BOOL; | |
+ args[4].vt = VT_DISPATCH; | |
+ args[4].pdispVal = sender; | |
+ args[3].vt = VT_I4; | |
+ args[3].lVal = (LONG) button; | |
+ args[2].vt = VT_I4; | |
+ args[2].lVal = (LONG) x; | |
+ args[1].vt = VT_I4; | |
+ args[1].lVal = (LONG) y; | |
+ args[0].vt = VT_I4; | |
+ args[0].lVal = (LONG) modifier; | |
+ invoke_v(m_event_root, m_event_wnd_on_mouse_down, 5, args, &result); | |
+ if (result.vt == VT_BOOL) { | |
+ *presult = result.boolVal; | |
+ } else { | |
+ *presult = VARIANT_FALSE; | |
+ } | |
+ return S_OK; | |
+ } | |
+ STDMETHOD(OnMouseUp)(IWnd* sender, LONG button, LONG x, LONG y, LONG modifier, VARIANT_BOOL *presult){ | |
+ VARIANTARG args[5]; | |
+ VARIANT result; | |
+ VariantInit(&result); | |
+ result.vt = VT_BOOL; | |
+ args[4].vt = VT_DISPATCH; | |
+ args[4].pdispVal = sender; | |
+ args[3].vt = VT_I4; | |
+ args[3].lVal = (LONG) button; | |
+ args[2].vt = VT_I4; | |
+ args[2].lVal = (LONG) x; | |
+ args[1].vt = VT_I4; | |
+ args[1].lVal = (LONG) y; | |
+ args[0].vt = VT_I4; | |
+ args[0].lVal = (LONG) modifier; | |
+ invoke_v(m_event_root, m_event_wnd_on_mouse_up, 5, args, &result); | |
+ if (result.vt == VT_BOOL) { | |
+ *presult = result.boolVal; | |
+ } else { | |
+ *presult = VARIANT_FALSE; | |
+ } | |
+ return S_OK; | |
+ } | |
+ STDMETHOD(OnMouseMove)(IWnd* sender, LONG button, LONG x, LONG y, LONG modifier, VARIANT_BOOL *presult){ | |
+ VARIANTARG args[5]; | |
+ VARIANT result; | |
+ VariantInit(&result); | |
+ result.vt = VT_BOOL; | |
+ args[4].vt = VT_DISPATCH; | |
+ args[4].pdispVal = sender; | |
+ args[3].vt = VT_I4; | |
+ args[3].lVal = (LONG) button; | |
+ args[2].vt = VT_I4; | |
+ args[2].lVal = (LONG) x; | |
+ args[1].vt = VT_I4; | |
+ args[1].lVal = (LONG) y; | |
+ args[0].vt = VT_I4; | |
+ args[0].lVal = (LONG) modifier; | |
+ invoke_v(m_event_root, m_event_wnd_on_mouse_move, 5, args, &result); | |
+ if (result.vt == VT_BOOL) { | |
+ *presult = result.boolVal; | |
+ } else { | |
+ *presult = VARIANT_FALSE; | |
+ } | |
+ return S_OK; | |
+ } | |
+ STDMETHOD(OnMouseWheel)(IWnd* sender, LONG x, LONG y, long delta){ | |
+ VARIANTARG args[5]; | |
+ args[4].vt = VT_DISPATCH; | |
+ args[4].pdispVal = sender; | |
+ args[3].vt = VT_I4; | |
+ args[3].lVal = (LONG) x; | |
+ args[2].vt = VT_I4; | |
+ args[2].lVal = (LONG) y; | |
args[1].vt = VT_I4; | |
args[1].lVal = (LONG) get_mod_key(0); | |
args[0].vt = VT_I4; | |
args[0].lVal = (LONG) delta; | |
- invoke_v(m_event_root, m_event_wnd_on_mouse_wheel, 3, args); | |
+ invoke_v(m_event_root, m_event_wnd_on_mouse_wheel, 5, args); | |
return S_OK; | |
} | |
STDMETHOD(OnMenuInit)(IWnd* sender, int* menu){ | |
@@ -623,6 +699,9 @@ | |
m_event_app_on_new_command(0), | |
m_event_wnd_on_closed(0), | |
m_event_wnd_on_key_down(0), | |
+ m_event_wnd_on_mouse_down(0), | |
+ m_event_wnd_on_mouse_up(0), | |
+ m_event_wnd_on_mouse_move(0), | |
m_event_wnd_on_mouse_wheel(0), | |
m_event_wnd_on_menu_init(0), | |
m_event_wnd_on_menu_execute(0), | |
@@ -684,6 +763,9 @@ | |
m_event_app_on_new_command = get_disp_id(m_event_root, L"app_on_new_command"); | |
m_event_wnd_on_closed = get_disp_id(m_event_root, L"wnd_on_closed"); | |
m_event_wnd_on_key_down = get_disp_id(m_event_root, L"wnd_on_key_down"); | |
+ m_event_wnd_on_mouse_down = get_disp_id(m_event_root, L"wnd_on_mouse_down"); | |
+ m_event_wnd_on_mouse_up = get_disp_id(m_event_root, L"wnd_on_mouse_up"); | |
+ m_event_wnd_on_mouse_move = get_disp_id(m_event_root, L"wnd_on_mouse_move"); | |
m_event_wnd_on_mouse_wheel = get_disp_id(m_event_root, L"wnd_on_mouse_wheel"); | |
m_event_wnd_on_menu_init = get_disp_id(m_event_root, L"wnd_on_menu_init"); | |
m_event_wnd_on_menu_execute = get_disp_id(m_event_root, L"wnd_on_menu_execute"); | |
diff -ur ck-3.3.4.bak/src/interface.idl ck-3.3.4/src/interface.idl | |
--- ck-3.3.4.bak/src/interface.idl 2007-08-09 22:29:17.000000000 +0900 | |
+++ ck-3.3.4/src/interface.idl 2012-06-10 14:15:32.635299700 +0900 | |
@@ -7,25 +7,38 @@ | |
}; | |
enum PrivMode{ | |
- Priv_Col132 = 0x00000001, | |
- Priv_Allow132 = 0x00000002, | |
- Priv_RVideo = 0x00000004, | |
- Priv_RelOrg = 0x00000008, | |
- Priv_Screen = 0x00000010, | |
- Priv_AutoWrap = 0x00000020, | |
- Priv_AplCUR = 0x00000040, | |
- Priv_AplKP = 0x00000080, | |
- Priv_Backspace = 0x00000100, | |
- Priv_ShiftKey = 0x00000200, | |
- Priv_VisibleCur = 0x00000400, | |
- Priv_MouseX10 = 0x00000800, | |
- Priv_MouseX11 = 0x00001000, | |
- Priv_ScrlTtyOut = 0x00002000, | |
- Priv_ScrlTtyKey = 0x00004000, | |
- Priv_SmoothScrl = 0x00008000, | |
- Priv_VT52 = 0x00010000, | |
- Priv_UseBell = 0x20000000, | |
- Priv_CjkWidth = 0x40000000, | |
+ Priv_None = 0x00000000, | |
+ Priv_Col132 = 0x00000001, | |
+ Priv_Allow132 = 0x00000002, | |
+ Priv_RVideo = 0x00000004, | |
+ Priv_RelOrg = 0x00000008, | |
+ Priv_Screen = 0x00000010, | |
+ Priv_AutoWrap = 0x00000020, | |
+ Priv_AplCUR = 0x00000040, | |
+ Priv_AplKP = 0x00000080, | |
+ Priv_Backspace = 0x00000100, | |
+ Priv_ShiftKey = 0x00000200, | |
+ Priv_VisibleCur = 0x00000400, | |
+ | |
+ Priv_MouseModeMask = 0x00003800, | |
+ Priv_MouseMode_None = 0x00000000, | |
+ Priv_MouseMode_Normal = 0x00000800, | |
+ Priv_MouseMode_Highlight = 0x00001000, | |
+ Priv_MouseMode_ButtonEvent = 0x00001800, | |
+ Priv_MouseMode_AnyEvent = 0x00002000, | |
+ | |
+ Priv_MouseProtocolMask = 0x0000c000, | |
+ Priv_MouseProtocol_X11 = 0x00000000, | |
+ Priv_MouseProtocol_X10 = 0x00004000, | |
+ Priv_MouseProtocol_Urxvt = 0x00008000, | |
+ Priv_MouseProtocol_Sgr = 0x0000c000, | |
+ | |
+ Priv_ScrlTtyOut = 0x00020000, | |
+ Priv_ScrlTtyKey = 0x00040000, | |
+ Priv_SmoothScrl = 0x00080000, | |
+ Priv_VT52 = 0x00100000, | |
+ Priv_UseBell = 0x20000000, | |
+ Priv_CjkWidth = 0x40000000, | |
}; | |
enum ModKey{ | |
@@ -202,7 +215,28 @@ | |
interface IWndNotify: IUnknown{ | |
HRESULT OnClosed([in] IWnd* sender); | |
HRESULT OnKeyDown([in] IWnd* sender, [in] DWORD vk); | |
- HRESULT OnMouseWheel([in] IWnd* sender, [in] int delta); | |
+ HRESULT OnMouseDown([in] IWnd* sender, | |
+ [in] long button, | |
+ [in] long x, | |
+ [in] long y, | |
+ [in] long modkey, | |
+ [out,retval] VARIANT_BOOL *handled); | |
+ HRESULT OnMouseUp([in] IWnd* sender, | |
+ [in] long button, | |
+ [in] long x, | |
+ [in] long y, | |
+ [in] long modkey, | |
+ [out,retval] VARIANT_BOOL *handled); | |
+ HRESULT OnMouseMove([in] IWnd* sender, | |
+ [in] long button, | |
+ [in] long x, | |
+ [in] long y, | |
+ [in] long modkey, | |
+ [out,retval] VARIANT_BOOL *handled); | |
+ HRESULT OnMouseWheel([in] IWnd* sender, | |
+ [in] long x, | |
+ [in] long y, | |
+ [in] long delta); | |
HRESULT OnMenuInit([in] IWnd* sender, [in] int* menu); | |
HRESULT OnMenuExec([in] IWnd* sender, [in] DWORD id); | |
HRESULT OnTitleInit([in] IWnd* sender); | |
diff -ur ck-3.3.4.bak/src/pty.cpp ck-3.3.4/src/pty.cpp | |
--- ck-3.3.4.bak/src/pty.cpp 2011-02-19 04:27:52.000000000 +0900 | |
+++ ck-3.3.4/src/pty.cpp 2012-06-10 14:15:33.135283700 +0900 | |
@@ -270,11 +270,12 @@ | |
bool _process_sequence_esc(WCHAR* input, int& idx, int max, UpdateStore& upp); | |
bool _process_sequence_vt52(WCHAR* input, int& idx, int max, UpdateStore& upp); | |
bool _process_sequence(WCHAR* input, int& idx, int max, UpdateStore& upp); | |
- bool _get_priv(PrivMode mask){ return (m_priv & mask)? true: false;} | |
- bool _set_priv(char mode, PrivMode mask){ | |
+ int _get_priv(int mask){ return m_priv & mask;} | |
+ bool _set_priv(char mode, int mask, int flag = (int)Priv_None){ | |
if(mode=='t') mode = (m_priv & mask) ? 'l' : 'h'; | |
- if(mode=='h' || mode=='s'){ m_priv=(PrivMode)(m_priv | mask); return true;} | |
- if(mode=='l' || mode=='r'){ m_priv=(PrivMode)(m_priv & ~mask); return false;} | |
+ m_priv = (PrivMode)(m_priv & ~mask); | |
+ if(mode=='h' || mode=='s'){ m_priv=(PrivMode)(m_priv | (mask & flag)); return true;} | |
+ if(mode=='l' || mode=='r'){ return false;} | |
return _get_priv(mask); | |
} | |
void _reset(bool full){ | |
@@ -555,7 +556,7 @@ | |
} | |
STDMETHODIMP Pty_::PutMouse(int x, int y, ModKey key, int nclicks, VARIANT_BOOL* handled){ | |
- if(_get_priv(Priv_MouseX10) || _get_priv(Priv_MouseX11)){ | |
+ if(_get_priv(Priv_MouseModeMask)){ | |
*handled = TRUE; | |
int w = m_screen.Current().GetPageWidth(); | |
int h = m_screen.Current().GetPageHeight(); | |
@@ -1040,7 +1041,7 @@ | |
case 8://DECARM auto repeat keys | |
break; | |
case 9://mouse X10 | |
- _set_priv(priv, Priv_MouseX10); | |
+ _set_priv(priv, Priv_MouseProtocolMask, Priv_MouseProtocol_X10); | |
break; | |
case 12://att610 blinking cursor | |
case 18://DECPFF print from feed | |
@@ -1065,11 +1066,11 @@ | |
case 45://reverse wraparound mode | |
case 46://start/stop logging | |
case 47://normal/alternate screen buffer | |
- m_screen.Set( _set_priv(priv, Priv_Screen) ); | |
+ m_screen.Set( _set_priv(priv, Priv_Screen) != 0 ); | |
break; | |
case 1047://secondary screen clearing | |
case 1049://secondary buffer & cursor | |
- m_screen.Set( _set_priv(priv, Priv_Screen) ); | |
+ m_screen.Set( _set_priv(priv, Priv_Screen) != 0 ); | |
m_screen.Back().ErasePage(2); | |
break; | |
case 66://DECNKM | |
@@ -1079,10 +1080,22 @@ | |
_set_priv(priv, Priv_Backspace); | |
break; | |
case 1000://X11 mouse reporting (VT200 mouse) | |
+ _set_priv(priv, Priv_MouseModeMask, Priv_MouseMode_Normal); | |
+ break; | |
case 1001://X11 mouse highliting (VT200 highlight mouse) | |
+ _set_priv(priv, Priv_MouseModeMask, Priv_MouseMode_Highlight); | |
+ break; | |
case 1002://X11 button event mouse | |
+ _set_priv(priv, Priv_MouseModeMask, Priv_MouseMode_ButtonEvent); | |
+ break; | |
case 1003://X11 any event mouse | |
- _set_priv(priv, Priv_MouseX11); | |
+ _set_priv(priv, Priv_MouseModeMask, Priv_MouseMode_AnyEvent); | |
+ break; | |
+ case 1005://UTF8 1005 mouse protocol | |
+ // ignore | |
+ break; | |
+ case 1006://SGR 1006 mouse protocol | |
+ _set_priv(priv, Priv_MouseProtocolMask, Priv_MouseProtocol_Sgr); | |
break; | |
case 1010://scroll to bottom TTY output inhibit | |
_set_priv(priv, Priv_ScrlTtyOut); | |
@@ -1090,6 +1103,9 @@ | |
case 1011://scroll to bottom on key press | |
_set_priv(priv, Priv_ScrlTtyKey); | |
break; | |
+ case 1015://urxvt 1015 mouse protocol | |
+ _set_priv(priv, Priv_MouseProtocolMask, Priv_MouseProtocol_Urxvt); | |
+ break; | |
case 1035://numlock | |
case 1036://meta sends escape | |
case 1037://delete is del | |
diff -ur ck-3.3.4.bak/src/script_sys.js ck-3.3.4/src/script_sys.js | |
--- ck-3.3.4.bak/src/script_sys.js 2011-02-19 00:21:48.000000000 +0900 | |
+++ ck-3.3.4/src/script_sys.js 2012-06-10 14:55:50.216103000 +0900 | |
@@ -168,11 +168,38 @@ | |
}; | |
var Priv ={ | |
- Backspace :0x00000100, | |
- ScrlTtyOut :0x00002000, | |
- ScrlTtyKey :0x00004000, | |
- UseBell :0x20000000, | |
- CjkWidth :0x40000000 | |
+ None :0x00000000, | |
+ Col132 :0x00000001, | |
+ Allow132 :0x00000002, | |
+ RVideo :0x00000004, | |
+ RelOrg :0x00000008, | |
+ Screen :0x00000010, | |
+ AutoWrap :0x00000020, | |
+ AplCUR :0x00000040, | |
+ AplKP :0x00000080, | |
+ Backspace :0x00000100, | |
+ ShiftKey :0x00000200, | |
+ VisibleCur :0x00000400, | |
+ | |
+ MouseModeMask :0x00003800, | |
+ MouseMode_None :0x00000000, | |
+ MouseMode_Normal :0x00000800, | |
+ MouseMode_Highlight :0x00001000, | |
+ MouseMode_ButtonEvent :0x00001800, | |
+ MouseMode_AnyEvent :0x00002000, | |
+ | |
+ MouseProtocolMask :0x0000c000, | |
+ MouseProtocol_X11 :0x00000000, | |
+ MouseProtocol_X10 :0x00004000, | |
+ MouseProtocol_Urxvt :0x00008000, | |
+ MouseProtocol_Sgr :0x0000c000, | |
+ | |
+ ScrlTtyOut :0x00020000, | |
+ ScrlTtyKey :0x00040000, | |
+ SmoothScrl :0x00080000, | |
+ VT52 :0x00100000, | |
+ UseBell :0x20000000, | |
+ CjkWidth :0x40000000 | |
}; | |
var WinTransp ={ | |
@@ -318,7 +345,7 @@ | |
(this.window.background_repeat_x << 8 ) | | |
(this.window.background_align_x << 0 ); | |
if(this.window.background_file != null && | |
- this.window.background_file != ""){ | |
+ this.window.background_file != ""){ | |
app.trace("[file] \"" + this.window.background_file + "\"\n"); | |
window.BackgroundImage = this.window.background_file; | |
} | |
@@ -476,9 +503,9 @@ | |
}, | |
match : function(k){ | |
if((this.key & 0x00FFFFFF)==(k & 0x00FFFFFF) && | |
- this.chkmod(k, Keys.Ctrl ) && | |
- this.chkmod(k, Keys.Shift) && | |
- this.chkmod(k, Keys.Alt )) | |
+ this.chkmod(k, Keys.Ctrl ) && | |
+ this.chkmod(k, Keys.Shift) && | |
+ this.chkmod(k, Keys.Alt )) | |
return true; | |
return false; | |
} | |
@@ -750,13 +777,221 @@ | |
var p = window.Pty; | |
if(p) p.PutKeyboard(key); | |
}, | |
- wnd_on_mouse_wheel : function(window, key, delta){ | |
- if(key & Keys.Ctrl){ | |
- window.FontSize -= (delta * 2); | |
- } | |
- else{ | |
- delta = (key & Keys.Alt) ? (delta*1) : (delta*5); | |
- Helper.scroll_relative(window, 0, -delta); | |
+ wnd_on_mouse_down : function(window, button, x, y, modifier){ | |
+ var pty = window.Pty; | |
+ if (pty) { | |
+ var priv = pty.PrivMode; | |
+ var mode = priv & Priv.MouseModeMask; | |
+ if (mode === Priv.MouseMode_None) { | |
+ return false; | |
+ } | |
+ var protocol = priv & Priv.MouseProtocolMask; | |
+ var messsage; | |
+ this._current_button = button; | |
+ this._x = 0; | |
+ this._y = 0; | |
+ switch (protocol) { | |
+ case Priv.MouseProtocol_X10: | |
+ case Priv.MouseProtocol_X11: | |
+ message = "\x1b[M" | |
+ + String.fromCharCode(32 + button, 32 + x + 1, 32 + y + 1); | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ case Priv.MouseProtocol_Urxvt: | |
+ message = "\x1b[" | |
+ + (32 + button) + ";" | |
+ + (32 + x + 1) + ";" | |
+ + (32 + y + 1) | |
+ + "M"; | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ case Priv.MouseProtocol_Sgr: | |
+ message = "\x1b[<" | |
+ + button + ";" | |
+ + (x + 1) + ";" | |
+ + (y + 1) | |
+ + "M"; | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ default: | |
+ break; | |
+ } | |
+ return true; | |
+ } | |
+ return false; | |
+ }, | |
+ wnd_on_mouse_up : function(window, button, x, y, modifier){ | |
+ var pty = window.Pty; | |
+ if (pty) { | |
+ var priv = pty.PrivMode; | |
+ var mode = priv & Priv.MouseModeMask; | |
+ if (mode === Priv.MouseMode_None) { | |
+ return false; | |
+ } | |
+ var protocol = priv & Priv.MouseProtocolMask; | |
+ var messsage; | |
+ this._current_button = 3; | |
+ this._x = 0; | |
+ this._y = 0; | |
+ switch (protocol) { | |
+ | |
+ case Priv.MouseProtocol_X10: | |
+ case Priv.MouseProtocol_X11: | |
+ message = "\x1b[M" | |
+ + String.fromCharCode(32 + 3, 32 + x + 1, 32 + y + 1); | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ case Priv.MouseProtocol_Urxvt: | |
+ message = "\x1b[" | |
+ + (32 + 3) + ";" | |
+ + (32 + x + 1) + ";" | |
+ + (32 + y + 1) | |
+ + "M"; | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ case Priv.MouseProtocol_Sgr: | |
+ message = "\x1b[<" | |
+ + button + ";" | |
+ + (x + 1) + ";" | |
+ + (y + 1) | |
+ + "m"; | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ default: | |
+ break; | |
+ } | |
+ return true; | |
+ } | |
+ return false; | |
+ }, | |
+ wnd_on_mouse_move : function(window, button, x, y, modifier){ | |
+ var pty = window.Pty; | |
+ if (pty) { | |
+ var priv = pty.PrivMode; | |
+ var mode = priv & Priv.MouseModeMask; | |
+ button = this._current_button; | |
+ if (mode === Priv.MouseMode_None) { | |
+ return false; | |
+ } | |
+ if (mode === Priv.MouseMode_Normal) { | |
+ return true; | |
+ } | |
+ if (mode === Priv.MouseMode_ButtonEvent && button === 3) { | |
+ return true; | |
+ } | |
+ var protocol = priv & Priv.MouseProtocolMask; | |
+ var messsage; | |
+ if (this._x === x && this._y === y){ | |
+ return true; | |
+ } | |
+ this._x = x; | |
+ this._y = y; | |
+ if (button != 3) { | |
+ button |= 0x20; | |
+ } | |
+ switch (protocol) { | |
+ | |
+ case Priv.MouseProtocol_X10: | |
+ case Priv.MouseProtocol_X11: | |
+ message = "\x1b[M" | |
+ + String.fromCharCode(32 + button, 32 + x + 1, 32 + y + 1); | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ case Priv.MouseProtocol_Urxvt: | |
+ message = "\x1b[" | |
+ + (32 + button) + ";" | |
+ + (32 + x + 1) + ";" | |
+ + (32 + y + 1) + "M"; | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ case Priv.MouseProtocol_Sgr: | |
+ message = "\x1b[<" | |
+ + button + ";" | |
+ + (x + 1) + ";" | |
+ + (y + 1) + "M"; | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ default: | |
+ return true; | |
+ } | |
+ return true; | |
+ } | |
+ return false; | |
+ }, | |
+ wnd_on_mouse_wheel : function(window, x, y, key, delta){ | |
+ var pty = window.Pty; | |
+ if (pty) { | |
+ var priv = pty.PrivMode; | |
+ var mode = priv & Priv.MouseModeMask; | |
+ if (mode === Priv.MouseMode_None) { | |
+ if(key & Keys.Ctrl){ | |
+ window.FontSize -= (delta * 2); | |
+ } | |
+ else{ | |
+ delta = (key & Keys.Alt) ? (delta*1) : (delta*5); | |
+ if (priv & Priv.AplKP) { | |
+ // for less(1) | |
+ var key = (delta > 0) ? Keys.Up: Keys.Down; | |
+ var count = Math.abs(delta); | |
+ for (var i = 0; i < count; ++i) { | |
+ pty.PutKeyboard(key); | |
+ } | |
+ } else { | |
+ // for shell | |
+ Helper.scroll_relative(window, 0, -delta); | |
+ } | |
+ } | |
+ } else { | |
+ var protocol = priv & Priv.MouseProtocolMask; | |
+ var messsage; | |
+ var button; | |
+ if (delta > 0) { | |
+ button = 64; | |
+ } else { | |
+ button = 65; | |
+ } | |
+ switch (protocol) { | |
+ | |
+ case Priv.MouseProtocol_X10: | |
+ case Priv.MouseProtocol_X11: | |
+ message = "\x1b[M" | |
+ + String.fromCharCode(32 + button) | |
+ + String.fromCharCode(32 + x + 1) | |
+ + String.fromCharCode(32 + y + 1); | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ case Priv.MouseProtocol_Urxvt: | |
+ message = "\x1b[" | |
+ + (32 + button) + ";" | |
+ + (32 + x + 1) + ";" | |
+ + (32 + y + 1) | |
+ + "M"; | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ case Priv.MouseProtocol_Sgr: | |
+ message = "\x1b[<" | |
+ + button + ";" | |
+ + (32 + x + 1) + ";" | |
+ + (32 + y + 1) | |
+ + "M"; | |
+ pty.PutString(message); | |
+ break; | |
+ | |
+ default: | |
+ break; | |
+ } | |
+ } | |
} | |
}, | |
wnd_on_menu_init : function(window){ | |
@@ -1016,8 +1251,11 @@ | |
Events.wnd_on_closed = Events.base.wnd_on_closed; | |
Events.wnd_on_key_down = Events.base.wnd_on_key_down; | |
+Events.wnd_on_mouse_down = Events.base.wnd_on_mouse_down; | |
+Events.wnd_on_mouse_up = Events.base.wnd_on_mouse_up; | |
+Events.wnd_on_mouse_move = Events.base.wnd_on_mouse_move; | |
Events.wnd_on_mouse_wheel = Events.base.wnd_on_mouse_wheel; | |
-Events.wnd_on_menu_init = Events.base.wnd_on_menu_init; | |
+Events.wnd_on_menu_init = Events.base.wnd_on_menu_init; | |
Events.wnd_on_menu_execute = Events.base.wnd_on_menu_execute; | |
Events.wnd_on_title_init = Events.base.wnd_on_title_init; | |
Events.wnd_on_drop = Events.base.wnd_on_drop; | |
diff -ur ck-3.3.4.bak/src/window.cpp ck-3.3.4/src/window.cpp | |
--- ck-3.3.4.bak/src/window.cpp 2011-02-18 23:04:27.000000000 +0900 | |
+++ ck-3.3.4/src/window.cpp 2012-06-10 14:52:48.300049500 +0900 | |
@@ -805,7 +805,10 @@ | |
public: | |
STDMETHOD(OnClosed)() = 0; | |
STDMETHOD(OnKeyDown)(DWORD vk) = 0; | |
- STDMETHOD(OnMouseWheel)(int delta) = 0; | |
+ STDMETHOD(OnMouseDown)(LONG button, LONG x, LONG y, LONG modifier, VARIANT_BOOL *presult) = 0; | |
+ STDMETHOD(OnMouseUp)(LONG button, LONG x, LONG y, LONG modifier, VARIANT_BOOL *presult) = 0; | |
+ STDMETHOD(OnMouseMove)(LONG button, LONG x, LONG y, LONG modifier, VARIANT_BOOL *presult) = 0; | |
+ STDMETHOD(OnMouseWheel)(LONG x, LONG y, LONG delta) = 0; | |
STDMETHOD(OnMenuInit)(HMENU menu) = 0; | |
STDMETHOD(OnMenuExec)(DWORD id) = 0; | |
STDMETHOD(OnTitleInit)() = 0; | |
@@ -1050,13 +1053,90 @@ | |
case WM_WINDOWPOSCHANGING: wm_on_window_pos_changing((WINDOWPOS*)lp);return 0; | |
case WM_WINDOWPOSCHANGED: wm_on_window_pos_changed ((WINDOWPOS*)lp);return 0; | |
case WM_TIMER: wm_on_timer((DWORD)wp);break; | |
- case WM_MOUSEMOVE: wm_on_mouse_move(GET_X_LPARAM(lp), GET_Y_LPARAM(lp));return 0; | |
- case WM_LBUTTONDOWN: wm_on_mouse_down(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_lbtn_cmd);return 0; | |
- case WM_LBUTTONUP: wm_on_mouse_up (GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_lbtn_cmd);return 0; | |
- case WM_MBUTTONDOWN: wm_on_mouse_down(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_mbtn_cmd);return 0; | |
- case WM_MBUTTONUP: wm_on_mouse_up (GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_mbtn_cmd);return 0; | |
- case WM_RBUTTONDOWN: wm_on_mouse_down(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_rbtn_cmd);return 0; | |
- case WM_RBUTTONUP: wm_on_mouse_up (GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_rbtn_cmd);return 0; | |
+ case WM_MOUSEMOVE: | |
+ { | |
+ int x = (GET_X_LPARAM(lp) - m_border.left) / (m_font_width + 0); | |
+ int y = (GET_Y_LPARAM(lp) - m_border.top ) / (m_font_height + m_linespace); | |
+ | |
+ VARIANT_BOOL result = VARIANT_FALSE; | |
+ m_notify->OnMouseMove(3, x, y, ModKey_Mask, &result); | |
+ if (result == VARIANT_FALSE) { | |
+ wm_on_mouse_move(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)); | |
+ } | |
+ } | |
+ return 0; | |
+ case WM_LBUTTONDOWN: | |
+ { | |
+ int x = (GET_X_LPARAM(lp) - m_border.left) / (m_font_width + 0); | |
+ int y = (GET_Y_LPARAM(lp) - m_border.top ) / (m_font_height + m_linespace); | |
+ | |
+ VARIANT_BOOL result = VARIANT_FALSE; | |
+ m_notify->OnMouseDown(0, x, y, ModKey_Mask, &result); | |
+ if (result == VARIANT_FALSE) { | |
+ wm_on_mouse_down(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_lbtn_cmd); | |
+ } | |
+ } | |
+ return 0; | |
+ case WM_LBUTTONUP: | |
+ { | |
+ int x = (GET_X_LPARAM(lp) - m_border.left) / (m_font_width + 0); | |
+ int y = (GET_Y_LPARAM(lp) - m_border.top ) / (m_font_height + m_linespace); | |
+ | |
+ VARIANT_BOOL result = VARIANT_FALSE; | |
+ m_notify->OnMouseUp(0, x, y, ModKey_Mask, &result); | |
+ if (result == VARIANT_FALSE) { | |
+ wm_on_mouse_up(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_lbtn_cmd); | |
+ } | |
+ } | |
+ return 0; | |
+ case WM_MBUTTONDOWN: | |
+ { | |
+ int x = (GET_X_LPARAM(lp) - m_border.left) / (m_font_width + 0); | |
+ int y = (GET_Y_LPARAM(lp) - m_border.top ) / (m_font_height + m_linespace); | |
+ | |
+ VARIANT_BOOL result = VARIANT_FALSE; | |
+ m_notify->OnMouseDown(1, x, y, ModKey_Mask, &result); | |
+ if (result == VARIANT_FALSE) { | |
+ wm_on_mouse_down(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_mbtn_cmd); | |
+ } | |
+ } | |
+ return 0; | |
+ case WM_MBUTTONUP: | |
+ { | |
+ int x = (GET_X_LPARAM(lp) - m_border.left) / (m_font_width + 0); | |
+ int y = (GET_Y_LPARAM(lp) - m_border.top ) / (m_font_height + m_linespace); | |
+ | |
+ VARIANT_BOOL result = VARIANT_FALSE; | |
+ m_notify->OnMouseUp(1, x, y, ModKey_Mask, &result); | |
+ if (result == VARIANT_FALSE) { | |
+ wm_on_mouse_up(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_mbtn_cmd); | |
+ } | |
+ } | |
+ return 0; | |
+ case WM_RBUTTONDOWN: | |
+ { | |
+ int x = (GET_X_LPARAM(lp) - m_border.left) / (m_font_width + 0); | |
+ int y = (GET_Y_LPARAM(lp) - m_border.top ) / (m_font_height + m_linespace); | |
+ | |
+ VARIANT_BOOL result = VARIANT_FALSE; | |
+ m_notify->OnMouseDown(2, x, y, ModKey_Mask, &result); | |
+ if (result == VARIANT_FALSE) { | |
+ wm_on_mouse_down(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_rbtn_cmd); | |
+ } | |
+ } | |
+ return 0; | |
+ case WM_RBUTTONUP: | |
+ { | |
+ int x = (GET_X_LPARAM(lp) - m_border.left) / (m_font_width + 0); | |
+ int y = (GET_Y_LPARAM(lp) - m_border.top ) / (m_font_height + m_linespace); | |
+ | |
+ VARIANT_BOOL result = VARIANT_FALSE; | |
+ m_notify->OnMouseUp(2, x, y, ModKey_Mask, &result); | |
+ if (result == VARIANT_FALSE) { | |
+ wm_on_mouse_up(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), m_rbtn_cmd); | |
+ } | |
+ } | |
+ return 0; | |
case WM_ERASEBKGND: | |
return 1; | |
@@ -1070,11 +1150,14 @@ | |
return 0; | |
case WM_MOUSEWHEEL: | |
{ | |
+ int x = (GET_X_LPARAM(lp) - m_border.left) / (m_font_width + 0); | |
+ int y = (GET_Y_LPARAM(lp) - m_border.top ) / (m_font_height + m_linespace); | |
+ | |
m_wheel_delta += GET_WHEEL_DELTA_WPARAM(wp); | |
int notch = m_wheel_delta / WHEEL_DELTA; | |
if(notch){ | |
m_wheel_delta -= notch * WHEEL_DELTA; | |
- m_notify->OnMouseWheel(notch); | |
+ m_notify->OnMouseWheel(x, y, notch); | |
} | |
} | |
return 0; | |
@@ -2020,7 +2103,16 @@ | |
STDMETHOD(OnClosed)(){ return m_notify->OnClosed(this);} | |
STDMETHOD(OnKeyDown)(DWORD vk){ return m_notify->OnKeyDown(this, vk);} | |
- STDMETHOD(OnMouseWheel)(int delta){ return m_notify->OnMouseWheel(this,delta);} | |
+ STDMETHOD(OnMouseDown)(LONG button, LONG x, LONG y, LONG modifier, VARIANT_BOOL *presult){ | |
+ return m_notify->OnMouseDown(this, button, x, y, modifier, presult); | |
+ } | |
+ STDMETHOD(OnMouseUp)(LONG button, LONG x, LONG y, LONG modifier, VARIANT_BOOL *presult){ | |
+ return m_notify->OnMouseUp(this, button, x, y, modifier, presult); | |
+ } | |
+ STDMETHOD(OnMouseMove)(LONG button, LONG x, LONG y, LONG modifier, VARIANT_BOOL *presult){ | |
+ return m_notify->OnMouseMove(this, button, x, y, modifier, presult); | |
+ } | |
+ STDMETHOD(OnMouseWheel)(LONG x, LONG y, LONG delta){ return m_notify->OnMouseWheel(this, x, y, delta);} | |
STDMETHOD(OnMenuInit)(HMENU menu){ return m_notify->OnMenuInit(this, (int*)menu);} | |
STDMETHOD(OnMenuExec)(DWORD id){ return m_notify->OnMenuExec(this, id);} | |
STDMETHOD(OnTitleInit)(){ return m_notify->OnTitleInit(this);} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment