2016-08-11 23:25:56 -04:00
|
|
|
local Widget = require 'Widget'
|
|
|
|
local Text = require 'Text'
|
|
|
|
local Line = require 'Line'
|
|
|
|
local TextColumn = require 'TextColumn'
|
|
|
|
local util = require 'util'
|
|
|
|
local schema = require 'default_patterns'
|
|
|
|
|
2017-07-17 02:42:53 -04:00
|
|
|
local PACMAN_TABLE = {
|
|
|
|
'pacman -Qq',
|
|
|
|
'pacman -Qeq',
|
|
|
|
'pacman -Quq',
|
|
|
|
'pacman -Qdtq',
|
|
|
|
'pacman -Qmq'
|
|
|
|
}
|
|
|
|
|
|
|
|
local _INITIAL_PGK_CNT_ = {}
|
|
|
|
for i, cmd in pairs(PACMAN_TABLE) do
|
|
|
|
_INITIAL_PGK_CNT_[i] = util.line_count(util.execute_cmd(cmd))
|
|
|
|
end
|
|
|
|
|
2017-07-17 02:21:22 -04:00
|
|
|
local _TEXT_SPACING_ = 20
|
2016-08-11 23:25:56 -04:00
|
|
|
|
|
|
|
local header = Widget.Header{
|
2017-07-16 14:50:33 -04:00
|
|
|
x = _G_INIT_DATA_.RIGHT_X,
|
|
|
|
y = _G_INIT_DATA_.TOP_Y,
|
|
|
|
width = _G_INIT_DATA_.SECTION_WIDTH,
|
2017-07-17 02:21:22 -04:00
|
|
|
header = 'PACMAN'
|
2016-08-11 23:25:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
local labels = Widget.TextColumn{
|
2017-07-16 14:50:33 -04:00
|
|
|
x = _G_INIT_DATA_.RIGHT_X,
|
2016-08-11 23:25:56 -04:00
|
|
|
y = header.bottom_y,
|
2017-07-17 02:21:22 -04:00
|
|
|
spacing = _TEXT_SPACING_,
|
2016-08-11 23:25:56 -04:00
|
|
|
'Total',
|
|
|
|
'Explicit',
|
|
|
|
'Outdated',
|
|
|
|
'Orphaned',
|
|
|
|
'Local'
|
|
|
|
}
|
|
|
|
local info = Widget.TextColumn{
|
2017-07-16 14:50:33 -04:00
|
|
|
x = _G_INIT_DATA_.RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH,
|
2016-08-11 23:25:56 -04:00
|
|
|
y = header.bottom_y,
|
2017-07-17 02:21:22 -04:00
|
|
|
spacing = _TEXT_SPACING_,
|
2016-08-11 23:25:56 -04:00
|
|
|
x_align = 'right',
|
|
|
|
text_color = schema.blue,
|
2017-07-17 02:42:53 -04:00
|
|
|
unpack(_INITIAL_PGK_CNT_)
|
2016-08-11 23:25:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Widget = nil
|
|
|
|
schema = nil
|
2017-07-17 02:21:22 -04:00
|
|
|
_TEXT_SPACING_ = nil
|
2017-07-17 02:42:53 -04:00
|
|
|
_INITIAL_PGK_CNT_ = nil
|
2016-08-11 23:25:56 -04:00
|
|
|
|
2017-07-17 02:21:22 -04:00
|
|
|
local update = function(cr)
|
2017-07-17 02:42:53 -04:00
|
|
|
for i, cmd in pairs(PACMAN_TABLE) do
|
|
|
|
TextColumn.set(info, cr, i, util.line_count(util.execute_cmd(cmd)))
|
|
|
|
end
|
2016-08-11 23:25:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
local draw = function(cr, current_interface, trigger)
|
2017-07-17 02:21:22 -04:00
|
|
|
if trigger == 0 then update(cr) end
|
2016-08-11 23:25:56 -04:00
|
|
|
|
|
|
|
if current_interface == 0 then
|
|
|
|
Text.draw(header.text, cr)
|
|
|
|
Line.draw(header.underline, cr)
|
|
|
|
TextColumn.draw(labels, cr)
|
|
|
|
TextColumn.draw(info, cr)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return draw
|