Hi guys, The hack of the day involves enabling Lua support for OnMacro, and defining a simple Lua implementation of keystroke macros. Most of the infrastructure is already there, we just need to get Lua to listen.
The source modification: LuaExtension.h: add this to the LuaExtension class, just before the }; line: virtual bool OnMacro(const char *, const char *); LuaExtension.cpp: add this to the end of the file: bool LuaExtension::OnMacro(const char *cmd, const char *arg) { char buff[256]; snprintf(buff,sizeof(buff),"%s|%s",cmd,arg); return CallNamedFunction("OnMacro",buff); } macro.lua can then be defined as: -- macro.lua -- simple SciTE macros -- note the standard (tho undocumented) macro key bindings -- Start Recording Ctrl+F9 -- End Recording Shift+Ctrl+F9 -- Play Macro F9 local append = table.insert local state,mac -- you need to add $(status.msg) to the end of your statusbar.text.1 definition -- to see these messages on the status bar local function set_state(s) state = s props['status.msg'] = state scite.UpdateStatusBar() end function OnMacro(line) local idx = line:find('|') local cmd = line:sub(1,idx-1) local arg = line:sub(idx+1) if cmd == 'macro:record' then if state ~= 'recording' then set_state 'recording' mac = {} end local _,_,msg,wparam,isstr,str = arg:find('(%d+);(%d+);(%d+);(.*)') if isstr == '0' then str = '' end append(mac,{MSG=msg,WPARAM=wparam,STR=str}) elseif cmd == 'macro:stoprecord' then set_state '' elseif cmd == 'macro:run' then for i,m in ipairs(mac) do if m.STR ~= '' then scite.SendEditor(m.MSG,m.STR) else scite.SendEditor(m.MSG,m.wparam) end end end end To use, hit ctrl+F9 to start recording, and start entering keystrokes - you will only see 'recording' on the first key hit. When finished, stop recording with Shift+Ctrl+F9 and then F9 will play back the macro. These shortcuts are not enabled by default for GTK, so you will need to add this to your properties file: user.shortcuts=\ Shift+F9|IDM_MACROLIST| \ F9|IDM_MACROPLAY|\ Ctrl+F9|IDM_MACRORECORD| \ Shift+Ctrl+F9|IDM_MACROSTOPRECORD| Yes, I know: you can't save the macro to file. This is meant for doing some ad-hoc automation; can save a lot of typing! steve d. _______________________________________________ Scite-interest mailing list Scite-interest@lyra.org http://mailman.lyra.org/mailman/listinfo/scite-interest