[tabulous] First import
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
aa6bfc560a
commit
43fee02a5b
|
@ -11,8 +11,8 @@ iconsdir = $(pkgdatadir)/icons
|
|||
dist_icons_DATA =
|
||||
iconslayoutsdir = $(iconsdir)/layouts
|
||||
dist_iconslayouts_DATA =
|
||||
awfuldir = $(pkgdatadir)/lib
|
||||
dist_awful_DATA =
|
||||
awesomelibdir = $(pkgdatadir)/lib
|
||||
dist_awesomelib_DATA =
|
||||
|
||||
LAYOUTS =
|
||||
|
||||
|
@ -50,7 +50,9 @@ doc_DATA += STYLE
|
|||
EXTRA_DIST += build-utils/gendoc.lua
|
||||
|
||||
EXTRA_DIST += awful.lua
|
||||
dist_awful_DATA += awful.lua
|
||||
EXTRA_DIST += tabulous.lua
|
||||
dist_awesomelib_DATA += awful.lua
|
||||
dist_awesomelib_DATA += tabulous.lua
|
||||
|
||||
EXTRA_DIST += awesomerc.lua.in
|
||||
CLEANFILES += awesomerc.lua
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
-- Include awesome library, with lots of useful function!
|
||||
require("awful")
|
||||
-- Include another library, which defines useful tabular system
|
||||
require("tabulous")
|
||||
|
||||
-- {{{ Colors and fonts
|
||||
awesome.font_set("sans 8")
|
||||
|
@ -169,6 +171,11 @@ keybinding.new({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end)
|
|||
keybinding.new({ modkey, "Control" }, "l", function () awful.tag.incncol(1) end):add()
|
||||
keybinding.new({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
|
||||
keybinding.new({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
|
||||
|
||||
-- Tabulous, tab manipulation
|
||||
keybinding.new({ modkey, "Control" }, "y", function () tabulous.tab(awful.client.next(1)) end):add()
|
||||
keybinding.new({ modkey, "Shift" }, "y", tabulous.untab):add()
|
||||
keybinding.new({ modkey }, "y", tabulous.focusnext):add()
|
||||
-- }}}
|
||||
|
||||
-- {{{ Hooks
|
||||
|
|
|
@ -50,7 +50,7 @@ function client_next(i)
|
|||
-- Loop upon each client
|
||||
for idx, c in ipairs(cls) do
|
||||
if c == sel then
|
||||
return cls[array_boundandcycle(cls, idx +i)]
|
||||
return cls[array_boundandcycle(cls, idx + i)]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
-----------------------------------------------
|
||||
-- tabulous: Fabulous tabs for awesome --
|
||||
-- --
|
||||
-- © 2008 Julien Danjou <julien@danjou.info> --
|
||||
-----------------------------------------------
|
||||
|
||||
--------------------
|
||||
-- Module loading --
|
||||
--------------------
|
||||
local P = {}
|
||||
if _REQUIREDNAME == nil then
|
||||
tabulous = P
|
||||
else
|
||||
_G[_REQUIREDNAME] = P
|
||||
end
|
||||
|
||||
-- Grab environment we need
|
||||
local client = client
|
||||
local table = table
|
||||
local pairs = pairs
|
||||
local rawset = rawset
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Reset env
|
||||
setfenv(1, P)
|
||||
|
||||
-- The tab datastructure.
|
||||
-- It contains keys which are clients. If a c1 is a client,
|
||||
-- then if tabbed[c1] exists it must contains a client c2.
|
||||
-- And if so, tabbed[c2] must contain c1.
|
||||
-- It's cycling i.e. tabbed[c1] = c2, tabbed[c2] = c3, tabbed[c3] = c1
|
||||
local tabbed = {}
|
||||
|
||||
-- Define a special index method.
|
||||
-- This is useful because we need to compare clients with __eq() to be sure
|
||||
-- that the key are identical. Otherwise Lua assume that each object is different.
|
||||
local function tabbed_index(table, key)
|
||||
for k, v in pairs(table) do
|
||||
if k == key then
|
||||
return v
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Same as tabbed_index, cheat!
|
||||
local function tabbed_newindex(table, key, value)
|
||||
for k, v in pairs(table) do
|
||||
if k == key then
|
||||
rawset(table, k, value)
|
||||
return
|
||||
end
|
||||
end
|
||||
rawset(table, key, value)
|
||||
end
|
||||
|
||||
-- Set the metatable for tabbed
|
||||
setmetatable(tabbed, { __index = tabbed_index, __newindex = tabbed_newindex })
|
||||
|
||||
---------------
|
||||
-- Functions --
|
||||
---------------
|
||||
|
||||
-- Get the next tab
|
||||
local function client_nexttab(s)
|
||||
local sel = s or client.focus_get()
|
||||
if sel and tabbed[sel] then
|
||||
return tabbed[sel]
|
||||
end
|
||||
end
|
||||
|
||||
-- Get the previous tab
|
||||
local function client_prevtab(c, stopc)
|
||||
local sel = c or client.focus_get()
|
||||
local stop = stopc or sel
|
||||
if sel and tabbed[sel] then
|
||||
if stop == tabbed[sel] then
|
||||
return sel
|
||||
else
|
||||
return client_prevtab(tabbed[sel], stop)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Tab a client with another one
|
||||
local function client_tab(c1, s)
|
||||
local sel = s or client.focus_get()
|
||||
if c1 and sel and c1 ~= sel then
|
||||
if tabbed[c1] then
|
||||
tabbed[sel] = tabbed[c1]
|
||||
tabbed[c1] = sel
|
||||
elseif tabbed[sel] then
|
||||
tabbed[c1] = tabbed[sel]
|
||||
tabbed[sel] = c1
|
||||
else
|
||||
tabbed[c1] = sel
|
||||
tabbed[sel] = c1
|
||||
end
|
||||
c1:hide()
|
||||
end
|
||||
end
|
||||
|
||||
-- Untab a client
|
||||
local function client_untab(c)
|
||||
local sel = c or client.focus_get()
|
||||
if sel and tabbed[sel] then
|
||||
local p = client_prevtab(sel)
|
||||
tabbed[p] = tabbed[sel]
|
||||
tabbed[sel] = nil
|
||||
p:unhide()
|
||||
end
|
||||
end
|
||||
|
||||
-- Focus the next tab
|
||||
local function client_focusnexttab(s)
|
||||
local sel = s or client.focus_get()
|
||||
local n = client_nexttab(sel)
|
||||
if n then
|
||||
sel:hide()
|
||||
n:unhide()
|
||||
n:focus_set()
|
||||
end
|
||||
end
|
||||
|
||||
-- Focus the previous tab
|
||||
local function client_focusprevtab(s)
|
||||
local sel = s or client.focus_get()
|
||||
local p = client_prevtab(sel)
|
||||
if p then
|
||||
sel:hide()
|
||||
p:unhide()
|
||||
p:focus_set()
|
||||
end
|
||||
end
|
||||
|
||||
P.tab = client_tab
|
||||
P.untab = client_untab
|
||||
P.focusnext = client_focusnexttab
|
||||
P.focusprev = client_focusprevtab
|
||||
P.next = client_nexttab
|
||||
P.prev = client_prevtab
|
||||
return P
|
Loading…
Reference in New Issue