--▽▽UTF-8▽▽ --[[ copyleft by jinzhongjie(xjinzhongjie@hotmail.com).anyone who want change the code please tell writer. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. ]]-- --[[ just a helper for me ]] scite_MessageTbl { 'get_receiver_HWND $(MessageLparam)|55|.*', 'do_msg|56|.*', 'set_director_hwnd|57|.*', } scite_OnInit(function(order1, order2) if order1 == 0 and order2 == 0 then local ahk_exe = props['LocalAHK'] local ahk_file = props['ext.ahk.startup.script'] if ahk_exe and ahk_file then --print(ahk_exe..' '..ahk_file) /Debug=localhost:9001 exe_command(ahk_exe..' '..ahk_file) -- end end return false end) local ATM_OFFSET = 0x1000 local ATM_STARTDEBUG = ATM_OFFSET+0 local ATM_STOPDEBUG = ATM_OFFSET+1 local ATM_RELOAD = ATM_OFFSET+2 local ATM_DIRECTOR = ATM_OFFSET+3 local ATM_DRUNTOGGLE = ATM_OFFSET+4 local ATM_GETCMDID = ATM_OFFSET+5 local ATM_GETSTATUS = ATM_OFFSET+6 local ATM_EXIT = ATM_OFFSET+99 local ATM_HELLO = ATM_OFFSET+100 ----------------------------------------------------------- local hwnd_toolbar = 0 local toolbar_exit=false scite_OnFinalise(function(level1, level2) --local hwnd_toolbar = scite_GetPropNumber('DirectorHwnd', 0) act_valid = false if not toolbar_exit then local ret = SendMessage(hwnd_toolbar, ATM_EXIT, 0, 0) toolbar_exit=true end --print('ret:',tostring(ret)) return false end) function GetMessage( addr ) local message if type(addr) == 'string' then addr = tonumber(addr) end if spawner and addr > 0 then message = spawner.getMessage(addr) end return message end function SendMessageStr(hwnd, msgId, wParam, lParamStr) local ret = -1 if type(hwnd) == 'string' then hwnd = tonumber(hwnd) end if type(msgId) == 'string' then msgId = tonumber(msgId) end if type(wParam) == 'string' then wParam = tonumber(wParam) end if spawner and hwnd > 0 then ret = spawner.sendMsgStr(hwnd, msgId, wParam, lParamStr) else print('hwnd:'..hwnd..',msgId:'..msgId..',wParam:'..wParam..',lParamStr:'..lParamStr) end return ret end function SendMessage(hwnd, msgId, wParam, lParam) local ret = -1 if type(hwnd) == 'string' then hwnd = tonumber(hwnd) end if type(msgId) == 'string' then msgId = tonumber(msgId) end if type(wParam) == 'string' then wParam = tonumber(wParam) end if type(lParam) == 'string' then lParam = tonumber(lParam) end if spawner and hwnd > 0 then ret = spawner.sendMessage(hwnd, msgId, wParam, lParam) end return ret end function PostMessage(hwnd, msgId, wParam, lParam) local ret = -1 if type(hwnd) == 'string' then hwnd = tonumber(hwnd) end if type(msgId) == 'string' then msgId = tonumber(msgId) end if type(wParam) == 'string' then wParam = tonumber(wParam) end if type(lParam) == 'string' then lParam = tonumber(lParam) end if spawner and hwnd > 0 then ret = spawner.postMessage(hwnd, msgId, wParam, lParam) end return ret end function SendMessageAfterCheck(msgId, wParam, lParam) local ret = -1 local hwnd = scite_GetPropNumber('DirectorHwnd', 0) if hwnd >0 then ret = SendMessage(hwnd, ATM_HELLO, wParam, lParam) --print('------------ret:'..ret) if ret == 555 then ret = SendMessage(hwnd, msgId, wParam, lParam) else props['DirectorHwnd'] = 0 end end return ret end -- =========================================================== -- -- Get direction interface HWND function (used by the toolbar) -- -- =========================================================== -- function get_receiver_HWND(hwnd) SendMessage(hwnd, ATM_DIRECTOR, hwnd_toolbar, scite_GetPropNumber('WindowID', 0)) end function set_director_hwnd(hwnd) hwnd_toolbar = scite_GetPropNumber('MessageLparam', -1) --props['DirectorHwnd'] = hwnd_toolbar end function do_msg() if spawner then local cmd_num = scite_GetPropNumber('MessageLparam', -1) if cmd_num <1000 then --local hwnd_toolbar = scite_GetPropNumber('DirectorHwnd', 0) local cmd_id if cmd_num == 0 then local stat_num = 0 local st = dbg_status() if st == 'dead' then stat_num = 0 elseif st == 'running' then stat_num = 1 elseif st == 'active' then stat_num = 2 end --print('------------stat_num:'..st..':'..stat_num) SendMessage(hwnd_toolbar, ATM_GETSTATUS, stat_num, 0) return elseif cmd_num == 1 then cmd_id = scite_get_CommandID('Run') --print('------------:'..props['MessageLparam']..':'..props['MessageWparam']..':'..scite_GetPropNumber('DirectorHwnd',0)..":"..scite_get_CommandID('Run')) elseif cmd_num == 2 then cmd_id = scite_get_CommandID('Kill') elseif cmd_num == 3 then cmd_id = scite_get_CommandID('Step Over') elseif cmd_num == 4 then cmd_id = scite_get_CommandID('Step') elseif cmd_num == 5 then cmd_id = scite_get_CommandID('Step Out') end --print('------------:'..cmd_num..':'..cmd_id) SendMessage(hwnd_toolbar, ATM_GETCMDID, cmd_id, 0) else end end end function debug_start() SendMessageAfterCheck(ATM_STARTDEBUG, 1, 0) end function debug_end() SendMessageAfterCheck(ATM_STOPDEBUG, 0, 0) end