wibox = require("wibox")
local infotab = {"window","name","skip_taskbar","type","class","instance","pid","role","machine","icon_name","icon","icon_sizes","screen","hidden","minimized","size_hints_honor","border_width","border_color","urgent","content","opacity","ontop","above","below","fullscreen","maximized","maximized_horizontal","maximized_vertical","transient_for","group_window","leader_window","size_hints","motif_wm_hints","sticky","modal","focusable","shape_bounding","shape_clip","shape_input","client_shape_bounding","client_shape_clip","startup_id","valid","first_tag","marked","is_fixed","immobilized","floating","x","y","width","height","dockable","requests_no_titlebar","shape"}
local function ellipsize(t)
    if t:len() < 80 then
        return t
    else
        return t:sub(1,80).."$"
    end
end
local function generate_text(c)
    if not global.debug then
        return "Debug mode is disabled!\nAdd \"global.debug = true\"\nto core/vars.lua to enable it."
    end
    local markup = ""
    for k,v in pairs(infotab) do
        markup = markup..tostring(v)..": "..ellipsize(tostring(c[v])).."\n"
    end
    return markup
end
return function()
    local widget = wibox.widget {
        {
            widget = wibox.widget.textbox,
            markup = "",
            id = "text"
        },
        layout = wibox.container.scroll.vertical,
        step_function = wibox.container.scroll.step_functions
                        .linear_back_and_forth,
        max_size = 300,
        speed = 100
    }
    widget:connect_signal("button::press",function(self,lx,ly,button)
        if button == 1 then
            widget:get_children_by_id("text")[1].markup = generate_text(client.focus)
        end
    end)
    widget:connect_signal("mouse::enter",function()
        widget:pause()
    end)
    widget:connect_signal("mouse::leave",function()
        widget:continue()
    end)
    client.connect_signal("focus",function()
        widget:get_children_by_id("text")[1].markup = generate_text(client.focus)
    end)
    return widget
end 


