Perf improvements.

This commit is contained in:
Bruce Hill 2018-03-25 15:14:18 -07:00
parent db872e8606
commit 7192506ed5
2 changed files with 51 additions and 3 deletions

33
ldt.lua
View File

@ -472,7 +472,29 @@ ldb = {
local show_src
show_src = function(filename, line_no)
if pads.src then
pads.src:erase()
if pads.src.filename == filename then
pads.src:select(line_no)
pads.src.colors[2] = function(self, i)
if i == line_no and i == self.selected then
return color("yellow on red bold")
elseif i == line_no then
return color("yellow on red")
elseif err_lines[tostring(filename) .. ":" .. tostring(i)] == true then
return color("red on black bold")
elseif i == self.selected then
return color("reverse")
else
return color()
end
end
for line, _ in pairs(err_lines) do
pads.src:setup_chstr(tonumber(line:match("[^:]*:(%d*).*")))
end
pads.src:select(line_no)
return
else
pads.src:erase()
end
end
local file = file_cache[filename]
if file then
@ -493,7 +515,7 @@ ldb = {
return color()
end
end)
return pads.src:select(line_no)
pads.src:select(line_no)
else
local lines = { }
for i = 1, math.floor(pads.stack.height / 2) - 1 do
@ -506,6 +528,7 @@ ldb = {
return color("red")
end)
end
pads.src.filename = filename
end
local show_vars
show_vars = function(stack_index)
@ -687,6 +710,12 @@ ldb = {
for _, pad in pairs(pads) do
pad:refresh()
end
elseif C.KEY_RESIZE == _exp_0 then
stdscr:clear()
stdscr:refresh()
for _, pad in pairs(pads) do
pad:refresh()
end
elseif ('q'):byte() == _exp_0 or ("Q"):byte() == _exp_0 then
pads = { }
C.endwin()

View File

@ -323,7 +323,20 @@ ldb = {
show_src = (filename, line_no)->
if pads.src
pads.src\erase!
if pads.src.filename == filename
pads.src\select(line_no)
pads.src.colors[2] = (i)=>
return if i == line_no and i == @selected then color("yellow on red bold")
elseif i == line_no then color("yellow on red")
elseif err_lines["#{filename}:#{i}"] == true then color("red on black bold")
elseif i == @selected then color("reverse")
else color()
for line,_ in pairs(err_lines)
pads.src\setup_chstr(tonumber(line\match("[^:]*:(%d*).*")))
pads.src\select(line_no)
return
else
pads.src\erase!
file = file_cache[filename]
if file
src_lines = {}
@ -344,6 +357,7 @@ ldb = {
s = (" ")\rep(math.floor((pads.stack.x-2-#s)/2))..s
table.insert(lines, s)
pads.src = Pad "(S)ource Code", pads.err.height,0,pads.stack.height,pads.stack.x,lines, ->color("red")
pads.src.filename = filename
show_vars = (stack_index)->
if pads.vars
@ -502,6 +516,11 @@ ldb = {
stdscr\clear!
stdscr\refresh!
for _,pad in pairs(pads) do pad\refresh!
when C.KEY_RESIZE
stdscr\clear!
stdscr\refresh!
for _,pad in pairs(pads) do pad\refresh!
when ('q')\byte!, ("Q")\byte!
pads = {}