clean up Pacman.lua

This commit is contained in:
petrucci4prez 2017-07-17 02:21:22 -04:00
parent 14062c2cbd
commit 3cad0178d5
1 changed files with 15 additions and 16 deletions

View File

@ -6,20 +6,19 @@ local TextColumn = require 'TextColumn'
local util = require 'util' local util = require 'util'
local schema = require 'default_patterns' local schema = require 'default_patterns'
--construction params local _TEXT_SPACING_ = 20
local TEXT_SPACING = 20
local header = Widget.Header{ local header = Widget.Header{
x = _G_INIT_DATA_.RIGHT_X, x = _G_INIT_DATA_.RIGHT_X,
y = _G_INIT_DATA_.TOP_Y, y = _G_INIT_DATA_.TOP_Y,
width = _G_INIT_DATA_.SECTION_WIDTH, width = _G_INIT_DATA_.SECTION_WIDTH,
header = "PACMAN" header = 'PACMAN'
} }
local labels = Widget.TextColumn{ local labels = Widget.TextColumn{
x = _G_INIT_DATA_.RIGHT_X, x = _G_INIT_DATA_.RIGHT_X,
y = header.bottom_y, y = header.bottom_y,
spacing = TEXT_SPACING, spacing = _TEXT_SPACING_,
'Total', 'Total',
'Explicit', 'Explicit',
'Outdated', 'Outdated',
@ -29,7 +28,7 @@ local labels = Widget.TextColumn{
local info = Widget.TextColumn{ local info = Widget.TextColumn{
x = _G_INIT_DATA_.RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH, x = _G_INIT_DATA_.RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH,
y = header.bottom_y, y = header.bottom_y,
spacing = TEXT_SPACING, spacing = _TEXT_SPACING_,
x_align = 'right', x_align = 'right',
text_color = schema.blue, text_color = schema.blue,
num_rows = 5, num_rows = 5,
@ -37,25 +36,25 @@ local info = Widget.TextColumn{
Widget = nil Widget = nil
schema = nil schema = nil
TEXT_SPACING = nil _TEXT_SPACING_ = nil
local __update = function(cr) local update = function(cr)
local execute_cmd = util.execute_cmd local _execute_cmd = util.execute_cmd
local line_count = util.line_count local _line_count = util.line_count
TextColumn.set(info, cr, 1, line_count(execute_cmd('pacman -Q'))) 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, 2, _line_count(_execute_cmd('pacman -Qe')))
TextColumn.set(info, cr, 3, line_count(execute_cmd('pacman -Qu'))) 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, 4, _line_count(_execute_cmd('pacman -Qdt')))
TextColumn.set(info, cr, 5, line_count(execute_cmd('pacman -Qm'))) TextColumn.set(info, cr, 5, _line_count(_execute_cmd('pacman -Qm')))
end end
__update(_CR) update(_CR)
_CR = nil _CR = nil
local draw = function(cr, current_interface, trigger) local draw = function(cr, current_interface, trigger)
if trigger == 0 then __update(cr) end if trigger == 0 then update(cr) end
if current_interface == 0 then if current_interface == 0 then
Text.draw(header.text, cr) Text.draw(header.text, cr)