2016-08-11 23:25:56 -04:00
|
|
|
local _CR = require 'CR'
|
|
|
|
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'
|
|
|
|
|
|
|
|
--construction params
|
|
|
|
local TEXT_SPACING = 20
|
|
|
|
|
|
|
|
local header = Widget.Header{
|
|
|
|
x = CONSTRUCTION_GLOBAL.RIGHT_X,
|
|
|
|
y = CONSTRUCTION_GLOBAL.TOP_Y,
|
2017-07-15 20:08:39 -04:00
|
|
|
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
|
2016-08-11 23:25:56 -04:00
|
|
|
header = "PACMAN"
|
|
|
|
}
|
|
|
|
|
|
|
|
local labels = Widget.TextColumn{
|
|
|
|
x = CONSTRUCTION_GLOBAL.RIGHT_X,
|
|
|
|
y = header.bottom_y,
|
|
|
|
spacing = TEXT_SPACING,
|
|
|
|
'Total',
|
|
|
|
'Explicit',
|
|
|
|
'Outdated',
|
|
|
|
'Orphaned',
|
|
|
|
'Local'
|
|
|
|
}
|
|
|
|
local info = Widget.TextColumn{
|
2017-07-15 20:08:39 -04:00
|
|
|
x = CONSTRUCTION_GLOBAL.RIGHT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH,
|
2016-08-11 23:25:56 -04:00
|
|
|
y = header.bottom_y,
|
|
|
|
spacing = TEXT_SPACING,
|
|
|
|
x_align = 'right',
|
|
|
|
text_color = schema.blue,
|
|
|
|
num_rows = 5,
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget = nil
|
|
|
|
schema = nil
|
|
|
|
TEXT_SPACING = nil
|
|
|
|
|
|
|
|
local __update = function(cr)
|
|
|
|
local execute_cmd = util.execute_cmd
|
|
|
|
local line_count = util.line_count
|
|
|
|
|
|
|
|
TextColumn.set(info, cr, 1, line_count(execute_cmd('pacman -Q')))
|
|
|
|
TextColumn.set(info, cr, 2, line_count(execute_cmd('pacman -Qe')))
|
|
|
|
TextColumn.set(info, cr, 3, line_count(execute_cmd('pacman -Qu')))
|
|
|
|
TextColumn.set(info, cr, 4, line_count(execute_cmd('pacman -Qdt')))
|
|
|
|
TextColumn.set(info, cr, 5, line_count(execute_cmd('pacman -Qm')))
|
|
|
|
end
|
|
|
|
|
|
|
|
__update(_CR)
|
|
|
|
|
|
|
|
_CR = nil
|
|
|
|
|
|
|
|
local draw = function(cr, current_interface, trigger)
|
|
|
|
if trigger == 0 then __update(cr) end
|
|
|
|
|
|
|
|
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
|