From 95832e74cda3f0496a7fcb2ed0e972ce5b63542b Mon Sep 17 00:00:00 2001 From: Michael Specht Date: Thu, 15 Feb 2018 12:20:22 +0100 Subject: [PATCH] specify highlight color via 'highlight' key in config in HTML notation --- champ.rb | 32 +++++++++++++++++++------------- plot3d.yaml | 1 + 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/champ.rb b/champ.rb index 17f1c5e..c80a017 100755 --- a/champ.rb +++ b/champ.rb @@ -73,6 +73,10 @@ class Champ @config['load'].each_pair do |address, path| @source_files << {:path => File.absolute_path(path), :address => address} end + @highlight_color = '#fce98d' + if @config['highlight'] + @highlight_color = @config['highlight'] + end @keywords = Set.new(KEYWORDS.split(/\s/).map { |x| x.strip }.reject { |x| x.empty? }) @global_variables = {} @@ -427,21 +431,27 @@ class Champ end end end - if component_index == 0 - print_s(pixels, width, height, - (canvas_left + canvas_width * 0.5 - component[:name].size * 3).to_i, - canvas_top + canvas_height + 18, - component[:name], 63) - else - print_s_r(pixels, width, height, - canvas_left - 22, - (canvas_top + canvas_height * 0.5 - component[:name].size * 3).to_i, + (0..1).each do |offset| + if component_index == 0 + print_s(pixels, width, height, + (canvas_left + canvas_width * 0.5 - component[:name].size * 3 + offset).to_i, + canvas_top + canvas_height + 18, component[:name], 63) + else + print_s_r(pixels, width, height, + canvas_left - 22, + (canvas_top + canvas_height * 0.5 - component[:name].size * 3 + offset).to_i, + component[:name], 63) + end end end label = "#{watch[:path]}:#{watch[:line_number]}" print_s(pixels, width, height, width - 6 * label.size - 3, height - 10, label, 63) + tr = @highlight_color[1, 2].to_i(16) + tg = @highlight_color[3, 2].to_i(16) + tb = @highlight_color[5, 2].to_i(16) + if pixels gi, go, gt = Open3.popen2("./pgif #{width} #{height} 128") palette = [''] * 128 @@ -452,10 +462,6 @@ class Champ b = 0xff else l = (((63 - i) + 1) << 2) - 1 - # fce98d - tr = 0xfc - tg = 0xe9 - tb = 0x8d r = l * tr / 255 g = l * tg / 255 b = l * tb / 255 diff --git a/plot3d.yaml b/plot3d.yaml index 8fc61fb..dbf56a7 100644 --- a/plot3d.yaml +++ b/plot3d.yaml @@ -8,5 +8,6 @@ load: 0x9500: plot3d/FONT 0xb600: plot3d/projtab.s entry: ENTRY +# highlight: '#c3def1' instant_rts: - LOAD1