From f083b78aad9b7998f59742960e1a3bd7a9c55920 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 21 Mar 2018 19:47:46 -0700 Subject: [PATCH] Cleaning up colors. --- ldt.lua | 24 ++++++++++-------------- ldt.moon | 21 ++++++++++----------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/ldt.lua b/ldt.lua index 1f8498c..b7dcf46 100644 --- a/ldt.lua +++ b/ldt.lua @@ -231,7 +231,7 @@ do self.selected = nil self.columns = { } self.column_widths = { } - self.active_frame = color("white bold") + self.active_frame = color("yellow bold") self.inactive_frame = color("blue dim") self.colors = { } for i = 1, select('#', ...) - 1, 2 do @@ -301,7 +301,7 @@ do local cols = { line_nums, (function(self, i) - return i == self.selected and color("white bold") or color("yellow") + return i == self.selected and color() or color("yellow") end), ... } @@ -456,19 +456,13 @@ ldb = { max_filename = math.max(max_filename, #line) max_fn_name = math.max(max_fn_name, #fn_name) end - local callstack = { } max_fn_name, max_filename = 0, 0 for i = 1, #stack_names do - local fn_name = stack_names[i] - callstack[i] = { - fn_name, - stack_locations[i] - } - max_fn_name = math.max(max_fn_name, #fn_name) + max_fn_name = math.max(max_fn_name, #stack_names[i]) max_filename = math.max(max_filename, #stack_locations[i]) end - local stack_h = math.max(#callstack + 2, math.floor(2 / 3 * SCREEN_H)) - local stack_w = max_fn_name + 1 + max_filename + local stack_h = math.max(#stack_names + 2, math.floor(2 / 3 * SCREEN_H)) + local stack_w = max_fn_name + 3 + max_filename pads.stack = Pad("(C)allstack", pads.err.height, SCREEN_W - stack_w, stack_h, stack_w, stack_names, (function(self, i) return (i == self.selected) and color("black on green") or color("green bold") end), stack_locations, (function(self, i) @@ -494,9 +488,9 @@ ldb = { elseif err_lines[tostring(filename) .. ":" .. tostring(i)] == true then return color("red on black bold") elseif i == self.selected then - return color("black on white") + return color("reverse") else - return color("white") + return color() end end) return pads.src:select(line_no) @@ -554,7 +548,7 @@ ldb = { local _exp_0 = type(value) if "string" == _exp_0 then pads.values = Pad("(D)ata [string]", var_y, value_x, pads.vars.height, value_w, wrap_text(value, value_w - 2), function(self, i) - return color("white bold") + return color() end) elseif "table" == _exp_0 then local type_str, value_str = 'table', repr(value) @@ -625,6 +619,8 @@ ldb = { p:refresh() end end + local s = " press 'q' to quit " + stdscr:mvaddstr(math.floor(SCREEN_H - 1), math.floor((SCREEN_W - #s)), s) C.doupdate() local c = stdscr:getch() local _exp_0 = c diff --git a/ldt.moon b/ldt.moon index 06d446f..f361bb3 100644 --- a/ldt.moon +++ b/ldt.moon @@ -74,7 +74,7 @@ class Pad @columns = {} @column_widths = {} - @active_frame = color("white bold") + @active_frame = color("yellow bold") @inactive_frame = color("blue dim") @colors = {} for i=1,select('#',...)-1,2 @@ -209,7 +209,7 @@ class NumberedPad extends Pad col1 = select(1, ...) fmt = "%#{#tostring(#col1)}d" line_nums = [fmt\format(i) for i=1,#col1] - cols = {line_nums, ((i)=> i == @selected and color("white bold") or color("yellow")), ...} + cols = {line_nums, ((i)=> i == @selected and color() or color("yellow")), ...} super @label, @y, @x, height, width, unpack(cols) ok, to_lua = pcall -> require('moonscript.base').to_lua @@ -310,16 +310,13 @@ ldb = { table.insert(stack_locations, line) max_filename = math.max(max_filename, #line) max_fn_name = math.max(max_fn_name, #fn_name) - callstack = {} max_fn_name, max_filename = 0, 0 for i=1,#stack_names do - fn_name = stack_names[i] - callstack[i] = {fn_name, stack_locations[i]} - max_fn_name = math.max(max_fn_name, #fn_name) + max_fn_name = math.max(max_fn_name, #stack_names[i]) max_filename = math.max(max_filename, #stack_locations[i]) - stack_h = math.max(#callstack+2, math.floor(2/3*SCREEN_H)) - stack_w = max_fn_name + 1 + max_filename + stack_h = math.max(#stack_names+2, math.floor(2/3*SCREEN_H)) + stack_w = max_fn_name + 3 + max_filename pads.stack = Pad "(C)allstack",pads.err.height,SCREEN_W-stack_w,stack_h,stack_w, stack_names, ((i)=> (i == @selected) and color("black on green") or color("green bold")), stack_locations, ((i)=> (i == @selected) and color("black on cyan") or color("cyan bold")) @@ -337,8 +334,8 @@ ldb = { 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("black on white") - else color("white") + elseif i == @selected then color("reverse") + else color() pads.src\select(line_no) else lines = {} @@ -384,7 +381,7 @@ ldb = { switch type(value) when "string" pads.values = Pad "(D)ata [string]",var_y,value_x,pads.vars.height,value_w, - wrap_text(value, value_w-2), (i)=>color("white bold") + wrap_text(value, value_w-2), (i)=>color() when "table" type_str, value_str = 'table', repr(value) if mt = getmetatable(value) @@ -440,6 +437,8 @@ ldb = { for _,p in pairs(pads) if p.dirty p\refresh! + s = " press 'q' to quit " + stdscr\mvaddstr(math.floor(SCREEN_H - 1), math.floor((SCREEN_W-#s)), s) C.doupdate! c = stdscr\getch! switch c