From 2f62e20509375be37df86ffb208546a46bcdfb8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Wed, 28 Aug 2019 11:31:42 +0200 Subject: [PATCH] assets/html/index.html: fix asset pathnames. assets/js/clipboard.js:import_ansi(): correctly handle {bold,faint,reset} SGR parameters. assets/js/clipboard.js:import_ansi(): don't apply {bold,faint} to background colours. assets/js/clipboard.js:import_ansi(): don't reset {background,foreground} colour & {bold,faint} flags on new row. assets/js/clipboard.js:import_ansi(): emit missing cells if necessary. assets/js/clipboard.js:import_ansi(): handle CUrsor Forward control sequence. assets/js/color.js: removes ansi_bg_bold_import[]. --- assets/html/index.html | 46 +++++++++++++++++++++--------------------- assets/js/clipboard.js | 32 +++++++++++++++++++---------- assets/js/color.js | 19 ----------------- 3 files changed, 44 insertions(+), 53 deletions(-) diff --git a/assets/html/index.html b/assets/html/index.html index 4f4e804..a58059d 100644 --- a/assets/html/index.html +++ b/assets/html/index.html @@ -4,9 +4,9 @@ - - - + + + MiRCART v1.1.5 @@ -65,7 +65,7 @@ new save load - help + help
brush: 5 x 5
canvas: 100 x 30
@@ -90,27 +90,27 @@ - - - - - - - - - - + + + + + + + + + + - - - - - - - - + + + + + + + + - + diff --git a/assets/js/clipboard.js b/assets/js/clipboard.js index 6e42ea1..4c8c891 100644 --- a/assets/js/clipboard.js +++ b/assets/js/clipboard.js @@ -91,9 +91,9 @@ var clipboard = (function () { var to_json = function(string, opts){ var lines_in = string.split(/\r?\n/) var lines_out = [] + var bg = 1, bg_ansi = 30, bold = false, fg = 15, fg_ansi = 37 var w = 0, h = 0 for (var y = 0; y < lines_in.length; y++) { - var bg = 1, bold = false, fg = 15 var cells = [], line = lines_in[y] if (line.length === 0) { continue @@ -104,29 +104,39 @@ var clipboard = (function () { m[1].split(";").forEach(function(c){ c = parseInt(c); if (c == 0) { - bg = 1; bold = false; fg = 15; + bg = 1; bg_ansi = 30; bold = false; fg = 15; fg_ansi = 37; } else if (c == 1) { - bold = true; + bold = true; fg = ansi_fg_bold_import[fg_ansi]; } else if (c == 2) { - bold = false; - } else if (bold && (ansi_bg_bold_import[c] !== undefined)) { - bg = ansi_bg_bold_import[c]; - } else if (!bold && (ansi_bg_import[c] !== undefined)) { - bg = ansi_bg_import[c]; + bold = false; fg = ansi_fg_import[fg_ansi]; + } else if (ansi_bg_import[c] !== undefined) { + bg = ansi_bg_import[c]; bg_ansi = c; } else if (bold && (ansi_fg_bold_import[c] !== undefined)) { - fg = ansi_fg_bold_import[c]; + fg = ansi_fg_bold_import[c]; fg_ansi = c; } else if (!bold && (ansi_fg_import[c] !== undefined)) { - fg = ansi_fg_import[c]; + fg = ansi_fg_import[c]; fg_ansi = c; } }); x += (m[0].length - 1); } else { - cells.push({bg: bg, fg: fg, value: line[x]}) + m = line.substring(x).match(/^\x1b\[(\d+)C/) + if (m !== null) { + for (var n = 0, nmax = parseInt(m[1]); n < nmax; n++) { + cells.push({bg: bg, fg: fg, value: " "}) + } + x += (m[0].length - 1); + } else { + cells.push({bg: bg, fg: fg, value: line[x]}) + } } } if (cells.length > 0) { if (w < cells.length) { w = cells.length + } else if (w > cells.length) { + for (var n = cells.length, nmax = w; n < nmax; n++) { + cells.push({bg: bg, fg: fg, value: " "}) + } } lines_out.push(cells); h++; } diff --git a/assets/js/color.js b/assets/js/color.js index 2d14828..78fefac 100644 --- a/assets/js/color.js +++ b/assets/js/color.js @@ -143,25 +143,6 @@ var ansi_bg = [ 47, // Light Grey ] -var ansi_bg_bold_import = { - 107: 0, // Bright White - 40: 14, // Black - 104: 12, // Light Blue - 42: 9, // Light Green - 101: 4, // Light Red - 41: 4, // Light Red - 45: 13, // Light Pink - 43: 8, // Light Yellow - 103: 8, // Light Yellow - 102: 9, // Light Green - 46: 11, // Light Cyan - 106: 11, // Light Cyan - 44: 12, // Light Blue - 105: 13, // Light Pink - 100: 14, // Grey - 47: 0, // Bright White -} - var ansi_bg_import = { 107: 0, // Bright White 40: 1, // Black