2 -- ion/share/ioncore_winprops.lua
4 -- Copyright (c) Tuomo Valkonen 2004-2007.
6 -- Ion is free software; you can redistribute it and/or modify it under
7 -- the terms of the GNU Lesser General Public License as published by
8 -- the Free Software Foundation; either version 2.1 of the License, or
9 -- (at your option) any later version.
12 local ioncore=_G.ioncore
16 local function ifnil(...)
18 local function nxt(_, i)
35 local function ipairs_r(tab)
36 local function nxt(_, n)
43 return nxt, nil, #tab+1
47 -- Find winprop table for \var{cwin}.
48 function ioncore.getwinprop(cwin)
49 local id=cwin:get_ident()
52 for _, c in ifnil(id.class, "*") do
53 for _, r in ifnil(id.role, "*") do
54 for _, i in ifnil(id.instance, "*") do
57 pcall(function() props=winprops[c][r][i] or {} end)
58 for idx, prop in ipairs_r(props) do
59 if prop:match(cwin) then
61 table.remove(props, idx)
71 ioncore.set{_get_winprop=ioncore.getwinprop}
73 local function ensure_winproptab(class, role, instance)
74 if not winprops[class] then
77 if not winprops[class][role] then
78 winprops[class][role]={}
80 if not winprops[class][role][instance] then
81 winprops[class][role][instance]={}
85 local function do_add_winprop(class, role, instance, name, prop)
86 ensure_winproptab(class, role, instance)
87 table.insert(winprops[class][role][instance], prop)
92 -- The basic name-based winprop matching criteria.
93 function ioncore.match_winprop_name(prop, cwin)
99 local st, en=string.find(nm, prop.name)
109 -- Define a winprop. For more information, see section \ref{sec:winprops}.
110 function ioncore.defwinprop(list)
112 local class, role, instance = "*", "*", "*"
114 for k, v in pairs(list) do
117 elseif k == "role" then
119 elseif k == "instance" then
125 if not list2.match then
126 list2.match=ioncore.match_winprop_name
129 do_add_winprop(class, role, instance, name, list2)