Fixed bug.
This commit is contained in:
parent
90e480cecd
commit
09f6ab22ef
18
cursed.lua
18
cursed.lua
@ -56,7 +56,7 @@ do
|
|||||||
local _base_0 = {
|
local _base_0 = {
|
||||||
select = function(self, i)
|
select = function(self, i)
|
||||||
if i == self.selected or #self.lines == 0 then
|
if i == self.selected or #self.lines == 0 then
|
||||||
return
|
return self.selected
|
||||||
end
|
end
|
||||||
if i ~= nil then
|
if i ~= nil then
|
||||||
i = math.max(1, math.min(#self.lines, i))
|
i = math.max(1, math.min(#self.lines, i))
|
||||||
@ -124,7 +124,7 @@ do
|
|||||||
self.offset = 0
|
self.offset = 0
|
||||||
self.selected = nil
|
self.selected = nil
|
||||||
self._height = #self.lines + 2
|
self._height = #self.lines + 2
|
||||||
self._width = 2
|
self._width = self.width == AUTO and 2 or self.width
|
||||||
local _list_0 = self.lines
|
local _list_0 = self.lines
|
||||||
for _index_0 = 1, #_list_0 do
|
for _index_0 = 1, #_list_0 do
|
||||||
local x = _list_0[_index_0]
|
local x = _list_0[_index_0]
|
||||||
@ -185,6 +185,9 @@ local file_cache = setmetatable({ }, {
|
|||||||
local line_tables = setmetatable({ }, {
|
local line_tables = setmetatable({ }, {
|
||||||
__index = function(self, filename)
|
__index = function(self, filename)
|
||||||
local file = file_cache[filename]
|
local file = file_cache[filename]
|
||||||
|
if not file then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
local line_table
|
local line_table
|
||||||
ok, line_table = to_lua(file)
|
ok, line_table = to_lua(file)
|
||||||
if ok then
|
if ok then
|
||||||
@ -195,9 +198,6 @@ local line_tables = setmetatable({ }, {
|
|||||||
})
|
})
|
||||||
local err_pad, stack_pad, var_names, var_values = nil, nil, nil, nil
|
local err_pad, stack_pad, var_names, var_values = nil, nil, nil, nil
|
||||||
main_loop = function(err_msg, stack_index, var_index, value_index)
|
main_loop = function(err_msg, stack_index, var_index, value_index)
|
||||||
if stack_index == nil then
|
|
||||||
stack_index = 1
|
|
||||||
end
|
|
||||||
local stack_names = { }
|
local stack_names = { }
|
||||||
local stack_locations = { }
|
local stack_locations = { }
|
||||||
local max_filename = 0
|
local max_filename = 0
|
||||||
@ -248,9 +248,9 @@ main_loop = function(err_msg, stack_index, var_index, value_index)
|
|||||||
}), RED)
|
}), RED)
|
||||||
end
|
end
|
||||||
if not stack_pad then
|
if not stack_pad then
|
||||||
stack_pad = Pad(err_pad.height, 0, AUTO, AUTO, callstack, nil, BLUE)
|
stack_pad = Pad(err_pad.height, 0, AUTO, SCREEN_W, callstack, nil, BLUE)
|
||||||
stack_index = stack_pad:select(stack_index)
|
|
||||||
end
|
end
|
||||||
|
stack_index = stack_pad:select(stack_index)
|
||||||
if var_names then
|
if var_names then
|
||||||
var_names:erase()
|
var_names:erase()
|
||||||
end
|
end
|
||||||
@ -279,7 +279,7 @@ main_loop = function(err_msg, stack_index, var_index, value_index)
|
|||||||
var_index = var_names:select(var_index)
|
var_index = var_names:select(var_index)
|
||||||
end
|
end
|
||||||
local value_x = var_names.x + var_names.width
|
local value_x = var_names.x + var_names.width
|
||||||
local value_w = SCREEN_W - (value_x + 1)
|
local value_w = SCREEN_W - (value_x)
|
||||||
if value_index then
|
if value_index then
|
||||||
var_values = Pad(var_y, value_x, AUTO, value_w, wrap_text(_var_values[var_index], value_w - 2), nil, BLUE)
|
var_values = Pad(var_y, value_x, AUTO, value_w, wrap_text(_var_values[var_index], value_w - 2), nil, BLUE)
|
||||||
value_index = var_values:select(value_index)
|
value_index = var_values:select(value_index)
|
||||||
@ -369,7 +369,7 @@ run_debugger = function(err_msg)
|
|||||||
_, BLUE = C.init_pair(5, C.COLOR_BLUE, -1), C.color_pair(5) | C.A_BOLD
|
_, BLUE = C.init_pair(5, C.COLOR_BLUE, -1), C.color_pair(5) | C.A_BOLD
|
||||||
stdscr:clear()
|
stdscr:clear()
|
||||||
stdscr:refresh()
|
stdscr:refresh()
|
||||||
return main_loop(err_msg)
|
return main_loop(err_msg, 1)
|
||||||
end
|
end
|
||||||
guard = function(fn, ...)
|
guard = function(fn, ...)
|
||||||
local err_hand
|
local err_hand
|
||||||
|
16
cursed.moon
16
cursed.moon
@ -42,7 +42,7 @@ class Pad
|
|||||||
@selected = nil
|
@selected = nil
|
||||||
|
|
||||||
@_height = #@lines + 2
|
@_height = #@lines + 2
|
||||||
@_width = 2
|
@_width = @width == AUTO and 2 or @width
|
||||||
for x in *@lines do @_width = math.max(@_width, #x+2)
|
for x in *@lines do @_width = math.max(@_width, #x+2)
|
||||||
|
|
||||||
if @height == AUTO
|
if @height == AUTO
|
||||||
@ -66,7 +66,7 @@ class Pad
|
|||||||
@refresh!
|
@refresh!
|
||||||
|
|
||||||
select: (i)=>
|
select: (i)=>
|
||||||
if i == @selected or #@lines == 0 then return
|
if i == @selected or #@lines == 0 then return @selected
|
||||||
if i != nil
|
if i != nil
|
||||||
i = math.max(1, math.min(#@lines, i))
|
i = math.max(1, math.min(#@lines, i))
|
||||||
if @selected
|
if @selected
|
||||||
@ -128,6 +128,8 @@ file_cache = setmetatable({}, {__index:(filename)=>
|
|||||||
})
|
})
|
||||||
line_tables = setmetatable({}, {__index:(filename)=>
|
line_tables = setmetatable({}, {__index:(filename)=>
|
||||||
file = file_cache[filename]
|
file = file_cache[filename]
|
||||||
|
if not file
|
||||||
|
return nil
|
||||||
ok, line_table = to_lua(file)
|
ok, line_table = to_lua(file)
|
||||||
if ok
|
if ok
|
||||||
@[filename] = line_table
|
@[filename] = line_table
|
||||||
@ -136,7 +138,7 @@ line_tables = setmetatable({}, {__index:(filename)=>
|
|||||||
|
|
||||||
err_pad, stack_pad, var_names, var_values = nil, nil, nil, nil
|
err_pad, stack_pad, var_names, var_values = nil, nil, nil, nil
|
||||||
|
|
||||||
main_loop = (err_msg, stack_index=1, var_index, value_index)->
|
main_loop = (err_msg, stack_index, var_index, value_index)->
|
||||||
export err_pad, stack_pad, var_names, var_values
|
export err_pad, stack_pad, var_names, var_values
|
||||||
stack_names = {}
|
stack_names = {}
|
||||||
stack_locations = {}
|
stack_locations = {}
|
||||||
@ -168,8 +170,8 @@ main_loop = (err_msg, stack_index=1, var_index, value_index)->
|
|||||||
err_pad = Pad(0,0,AUTO,SCREEN_W, err_msg_lines,setmetatable({}, __index:->RED), RED)
|
err_pad = Pad(0,0,AUTO,SCREEN_W, err_msg_lines,setmetatable({}, __index:->RED), RED)
|
||||||
|
|
||||||
if not stack_pad
|
if not stack_pad
|
||||||
stack_pad = Pad(err_pad.height,0,AUTO,AUTO, callstack, nil, BLUE)
|
stack_pad = Pad(err_pad.height,0,AUTO,SCREEN_W, callstack, nil, BLUE)
|
||||||
stack_index = stack_pad\select(stack_index)
|
stack_index = stack_pad\select(stack_index)
|
||||||
|
|
||||||
if var_names
|
if var_names
|
||||||
var_names\erase!
|
var_names\erase!
|
||||||
@ -196,7 +198,7 @@ main_loop = (err_msg, stack_index=1, var_index, value_index)->
|
|||||||
var_index = var_names\select(var_index)
|
var_index = var_names\select(var_index)
|
||||||
|
|
||||||
value_x = var_names.x+var_names.width
|
value_x = var_names.x+var_names.width
|
||||||
value_w = SCREEN_W-(value_x+1)
|
value_w = SCREEN_W-(value_x)
|
||||||
if value_index
|
if value_index
|
||||||
var_values = Pad(var_y,value_x,AUTO,value_w,wrap_text(_var_values[var_index], value_w-2), nil, BLUE)
|
var_values = Pad(var_y,value_x,AUTO,value_w,wrap_text(_var_values[var_index], value_w-2), nil, BLUE)
|
||||||
value_index = var_values\select(value_index)
|
value_index = var_values\select(value_index)
|
||||||
@ -291,7 +293,7 @@ run_debugger = (err_msg)->
|
|||||||
stdscr\clear!
|
stdscr\clear!
|
||||||
stdscr\refresh!
|
stdscr\refresh!
|
||||||
|
|
||||||
return main_loop(err_msg)
|
return main_loop(err_msg, 1)
|
||||||
|
|
||||||
|
|
||||||
guard = (fn, ...)->
|
guard = (fn, ...)->
|
||||||
|
Loading…
Reference in New Issue
Block a user