X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Fioncore_bindings.lua;h=01588ebaed474057aff36fb5be578232a71d2746;hp=ec03dddd2f6fd141cf526adb90bd27eb8208a4ef;hb=HEAD;hpb=471a5e5f9928e2d324b2e10422a420f458bd63ff diff --git a/ioncore/ioncore_bindings.lua b/ioncore/ioncore_bindings.lua index ec03ddd..01588eb 100644 --- a/ioncore/ioncore_bindings.lua +++ b/ioncore/ioncore_bindings.lua @@ -1,12 +1,9 @@ -- -- ion/share/ioncore-bindings.lua -- --- Copyright (c) Tuomo Valkonen 2004-2007. +-- Copyright (c) Tuomo Valkonen 2004-2009. -- --- Ion is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. +-- See the included file LICENSE for details. -- local ioncore=_G.ioncore @@ -49,7 +46,8 @@ function ioncore.compile_cmd(cmd, guard) end local gfncode="return function(_, _sub, _chld) "..guardcode.." return true end" - local gfn, gerr=loadstring(gfncode, guardcode) + local gerr + gfn, gerr=loadstring(gfncode, guardcode) if not gfn then ioncore.warn_traced(TR("Error compiling guard: %s", gerr)) end @@ -62,7 +60,7 @@ function ioncore.compile_cmd(cmd, guard) else return function(_, _sub, _chld) if gfn(_, _sub, _chld) then - cmd(_, _sub, _chld) + fn(_, _sub, _chld) end end end @@ -113,33 +111,52 @@ end -- Returns a function that creates a submap binding description table. -- When the key press action \var{keyspec} occurs, Ioncore will wait for -- a further key presse and act according to the submap. --- For details, see section \ref{sec:bindings}. -function ioncore.submap(kcb_, list) +-- For details, see Section \ref{sec:bindings}. +function ioncore.submap(keyspec, list) if not list then return function(lst) - return submap(kcb_, lst) + return submap(keyspec, lst) end end - return {action = "kpress", kcb = kcb_, submap = list} + return {action = "kpress", kcb = keyspec, submap = list} end --DOC -- Creates a binding description table for the action of pressing a key given --- by \var{keyspec} (with possible modifiers) to the function \var{func}. --- For more information on bindings, see section \ref{sec:bindings}. +-- by \var{keyspec} (with possible modifiers) to the function \var{cmd}. +-- The \var{guard} controls when the binding can be called. +-- For more informationp see Section \ref{sec:bindings}. function ioncore.kpress(keyspec, cmd, guard) return putcmd(cmd, guard, {action = "kpress", kcb = keyspec}) end --DOC --- This is similar to \fnref{kpress} but after calling \var{cmd}, +-- This is similar to \fnref{ioncore.kpress} but after calling \var{cmd}, -- Ioncore waits for all modifiers to be released before processing -- any further actions. --- For more information on bindings, see section \ref{sec:bindings}. +-- For more information on bindings, see Section \ref{sec:bindings}. function ioncore.kpress_wait(keyspec, cmd, guard) return putcmd(cmd, guard, {action = "kpress_wait", kcb = keyspec}) end +--DOC +-- Submap enter event for bindings. +function ioncore.submap_enter(cmd, guard) + return putcmd(cmd, guard, {action = "submap_enter"}) +end + +--DOC +-- Submap modifier release event for bindings. +function ioncore.submap_wait(cmd, guard) + return putcmd(cmd, guard, {action = "submap_wait"}) +end + +-- DOC +-- Submap leave event for bindings. +--function ioncore.submap_leave(cmd, guard) +-- return putcmd(cmd, guard, {action = "submap_leave"}) +--end + local function mact(act_, kcb_, cmd, guard) local st, en, kcb2_, area_=string.find(kcb_, "([^@]*)@(.*)") return putcmd(cmd, guard, { @@ -152,22 +169,22 @@ end --DOC -- Creates a binding description table for the action of clicking a mouse -- button while possible modifier keys are pressed, --- both given by \var{buttonspec}, to the function \var{func}. --- For more information, see section \ref{sec:bindings}. +-- both given by \var{buttonspec}, to the function \var{cmd}. +-- For more information, see Section \ref{sec:bindings}. function ioncore.mclick(buttonspec, cmd, guard) return mact("mclick", buttonspec, cmd, guard) end --DOC --- Similar to \fnref{mclick} but for double-click. --- Also see section \ref{sec:bindings}. +-- Similar to \fnref{ioncore.mclick} but for double-click. +-- Also see Section \ref{sec:bindings}. function ioncore.mdblclick(buttonspec, cmd, guard) return mact("mdblclick", buttonspec, cmd, guard) end --DOC --- Similar to \fnref{mclick} but for just pressing the mouse button. --- Also see section \ref{sec:bindings}. +-- Similar to \fnref{ioncore.mclick} but for just pressing the mouse button. +-- Also see Section \ref{sec:bindings}. function ioncore.mpress(buttonspec, cmd, guard) return mact("mpress", buttonspec, cmd, guard) end @@ -185,7 +202,7 @@ end --DOC -- Define bindings for context \var{context}. Here \var{binding} is -- a table composed of entries created with \fnref{ioncore.kpress}, --- etc.; see section \ref{sec:bindings} for details. +-- etc.; see Section \ref{sec:bindings} for details. function ioncore.defbindings(context, bindings) local function filterdoc(b) local t={}