Misc flailing and cleanup.

This commit is contained in:
Bruce Hill 2018-03-20 15:57:21 -07:00
parent d4bb091d9d
commit 43b2266b4a
2 changed files with 8 additions and 33 deletions

View File

@ -71,9 +71,12 @@ do
for c = 1, #self.columns do
local attr = self.colors[c](self, i)
local chunk = self.columns[c][i]
chunk = chunk .. (" "):rep(self.column_widths[c] - #chunk)
chstr:set_str(x, chunk, attr)
x = x + #chunk
if #chunk < self.column_widths[c] then
chstr:set_str(x, " ", attr, self.column_widths[c] - #chunk)
x = x + (self.column_widths[c] - #chunk)
end
if c < #self.columns then
chstr:set_ch(x, C.ACS_VLINE, self.active and self.active_frame or self.inactive_frame)
x = x + 1
@ -151,27 +154,7 @@ do
if not force and not self.dirty then
return
end
self._frame:mvaddch(0, 0, C.ACS_ULCORNER)
for y = 1, self.height - 2 do
self._frame:mvaddch(y, 0, C.ACS_VLINE)
end
self._frame:mvaddch(self.height - 1, 0, C.ACS_LLCORNER)
for x = 1, self.width - 2 do
self._frame:mvaddch(self.height - 1, x, C.ACS_HLINE)
end
self._frame:mvaddch(self.height - 1, self.width - 1, C.ACS_LRCORNER)
for y = 1, self.height - 2 do
self._frame:mvaddch(y, self.width - 1, C.ACS_VLINE)
end
self._frame:mvaddch(0, self.width - 1, C.ACS_URCORNER)
for x = 1, self.width - 2 do
self._frame:mvaddch(0, x, C.ACS_HLINE)
end
local _ = [[ @_frame\border(C.ACS_VLINE, C.ACS_VLINE,
C.ACS_HLINE, C.ACS_HLINE,
C.ACS_ULCORNER, C.ACS_URCORNER,
C.ACS_LLCORNER, C.ACS_LRCORNER)
]]
self._frame:border(C.ACS_VLINE, C.ACS_VLINE, C.ACS_HLINE, C.ACS_HLINE, C.ACS_ULCORNER, C.ACS_URCORNER, C.ACS_LLCORNER, C.ACS_LRCORNER)
if self.label then
self._frame:mvaddstr(0, math.floor((self.width - #self.label - 2) / 2), " " .. tostring(self.label) .. " ")
end

View File

@ -87,9 +87,11 @@ class Pad
for c=1,#@columns
attr = @colors[c](@, i)
chunk = @columns[c][i]
chunk ..= (" ")\rep(@column_widths[c]-#chunk)
chstr\set_str(x, chunk, attr)
x += #chunk
if #chunk < @column_widths[c]
chstr\set_str(x, " ", attr, @column_widths[c]-#chunk)
x += @column_widths[c]-#chunk
if c < #@columns
chstr\set_ch(x, C.ACS_VLINE, @active and @active_frame or @inactive_frame)
x += 1
@ -148,20 +150,10 @@ class Pad
refresh: (force=false)=>
return if not force and not @dirty
@_frame\mvaddch(0,0,C.ACS_ULCORNER)
for y=1,@height-2 do @_frame\mvaddch(y,0,C.ACS_VLINE)
@_frame\mvaddch(@height-1,0,C.ACS_LLCORNER)
for x=1,@width-2 do @_frame\mvaddch(@height-1,x,C.ACS_HLINE)
@_frame\mvaddch(@height-1,@width-1,C.ACS_LRCORNER)
for y=1,@height-2 do @_frame\mvaddch(y,@width-1,C.ACS_VLINE)
@_frame\mvaddch(0,@width-1,C.ACS_URCORNER)
for x=1,@width-2 do @_frame\mvaddch(0,x,C.ACS_HLINE)
[[
@_frame\border(C.ACS_VLINE, C.ACS_VLINE,
C.ACS_HLINE, C.ACS_HLINE,
C.ACS_ULCORNER, C.ACS_URCORNER,
C.ACS_LLCORNER, C.ACS_LRCORNER)
]]
if @label
@_frame\mvaddstr(0, math.floor((@width-#@label-2)/2), " #{@label} ")
@_frame\refresh!