SciTEでEmacsキーバインド
これでSciTEにxkeymacsかぶせる日々ともオサラバだ!ヒャッハー!
(なおkillringはまだ動かない…)
SciTEStartup.lua
dofile(props["SciteDefaultHome"].."\\lua\\emacs.lua")
-- emacs like keybind function inRegion = false inCx = false inMx = false inSrch = false --if some lua already uses the OnKey callback, follow below to imprement emacs keybind. function OnKey(kc, shift, ctrl, alt) --Copy from here if emacs(kc, shift, ctrl, alt) then return true end --Copy until here return false end function emacs(kc, shift, ctrl, alt) --C-x combination if inCx then if ctrl then if kc == 70 then --f scite.MenuCommand(IDM_OPEN) inCx = false return true end if kc == 83 then --s scite.MenuCommand(IDM_SAVE) inCx = false return true end end if kc == 67 then --c scite.MenuCommand(IDM_QUIT) inCx = false return true end if kc == 72 then --h editor:SelectAll() inCx = false return true end if kc == 75 then --k scite.MenuCommand(IDM_CLOSE) inCx = false return true end if kc == 85 then --u editor:Undo() inRegion = false inCx = false inMx = false return true end inCx = false return true end --C combination if ctrl then if kc == 32 then --spc inRegion = true return true end if kc == 65 then --a if inRegion then editor:VCHomeExtend() else editor:VCHome() end inSrch = false return true end if kc == 66 then --b if inRegion then editor:CharLeftExtend() else editor:CharLeft() end inSrch = false return true end if kc == 68 then --d editor:CharRightExtend() editor:DeleteBack() inRegion = false return true end if kc == 69 then --e if inRegion then editor:LineEndExtend() else editor:LineEnd() end inSrch = false return true end if kc == 70 then --f if inRegion then editor:CharRightExtend() else editor:CharRight() end inSrch = false return true end if kc == 71 then --g inRegion = false inCx = false inMx = false inSrch = false if editor:AutoCActive() then editor:AutoCCancel() end local tmpPos = editor.CurrentPos editor:ClearSelections() --ClearSelections moves the carret pos to document top editor:GotoPos(tmpPos) --So we gotta reset the carret pos return true end if kc == 72 then --h editor:DeleteBack() inRegion = false return true end if kc == 75 then --k inRegion = false local oriPos = editor.CurrentPos editor:ClearSelections() --ClearSelections moves the carret pos to document top editor:GotoPos(oriPos) --So we gotta reset the carret pos editor:LineEndExtend() local newPos = editor.CurrentPos if oriPos == newPos then editor:CharRight() editor:DeleteBack() else editor:Cut() end end if kc == 76 then --l local line = editor:LineFromPosition(editor.CurrentPos) local top = editor.FirstVisibleLine local middle = top + editor.LinesOnScreen / 2 editor:LineScroll(0, line - middle) return true end if kc == 77 then --m if editor:CallTipActive() then editor:AutoCComplete() else editor:NewLine() end return true end if kc == 78 then --n if inRegion then editor:LineDownExtend() else editor:LineDown() end inSrch = false return true end if kc == 80 then --p if inRegion then editor:LineUpExtend() else editor:LineUp() end inSrch = false return true end if kc == 82 then --r if inSrch then scite.MenuCommand(IDM_FINDNEXTBACK) else scite.MenuCommand(IDM_FIND) inSrch = true end return true end if kc == 83 then --s if inSrch then scite.MenuCommand(IDM_FINDNEXT) else scite.MenuCommand(IDM_FIND) inSrch = true end return true end if kc == 86 then --v if inRegion then editor:PageDownExnd() else editor:PageDown() end return true end if kc == 87 then --w editor:Cut() inRegion = false return true end if kc == 88 then --x inCx = true return true end if kc == 89 then --y editor:Paste() inRegion = false return true end end --M combination if alt then if kc == 66 then --b if inRegion then editor:WordLeftExtend() else editor:WordLeft() end inSrch = false return true end if kc == 70 then --f if inRegion then editor:WordRightExtend() else editor:WordRight() end inSrch = false return true end if kc == 82 then --r scite.MenuCommand(IDM_REPLACE) return true end if kc == 86 then --v if inRegion then editor:PageUpExtend() else editor:PageUp() end return true end if kc == 87 then --w editor:Copy() inRegion = false local tmpPos = editor.CurrentPos editor:ClearSelections() --ClearSelections moves the carret pos to document top editor:GotoPos(tmpPos) --So we gotta reset the carret pos return true end if kc == 188 then --, if shift then --< if inRegion then editor:DocumentStartExtend() else editor:DocumentStart() end end return true end if kc == 190 then --. if shift then --> if inRegion then editor:DocumentEndExtend() else editor:DocumentEnd() end end return true end end return false end