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[].
This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-08-28 11:31:42 +02:00
parent f6a4e17463
commit 2f62e20509
3 changed files with 44 additions and 53 deletions

View File

@ -4,9 +4,9 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<!-- {{{ HEAD --> <!-- {{{ HEAD -->
<head> <head>
<link charset="utf-8" href="assets/css/ak.css" rel="stylesheet" type="text/css" /> <link charset="utf-8" href="../css/ak.css" rel="stylesheet" type="text/css" />
<link charset="utf-8" href="assets/css/fonts.css" rel="stylesheet" type="text/css" /> <link charset="utf-8" href="../css/fonts.css" rel="stylesheet" type="text/css" />
<link charset="utf-8" href="assets/css/sally.css" rel="stylesheet" type="text/css" /> <link charset="utf-8" href="../css/sally.css" rel="stylesheet" type="text/css" />
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<meta content="width=device-width, maximum-scale=1.0, user-scalable=yes" name="viewport" /> <meta content="width=device-width, maximum-scale=1.0, user-scalable=yes" name="viewport" />
<title>MiRCART v1.1.5</title> <title>MiRCART v1.1.5</title>
@ -65,7 +65,7 @@
<span id="clear_el" class="tool">new</span> <span id="clear_el" class="tool">new</span>
<span id="save_el" class="tool">save</span> <span id="save_el" class="tool">save</span>
<span id="load_el" class="tool">load</span> <span id="load_el" class="tool">load</span>
<a id="doc_el" href="assets/html/help.html" target="_blank">help</a> <a id="doc_el" href="../html/help.html" target="_blank">help</a>
<br /> <br />
brush: <span id="brush_w_el" class="ed">5</span> x <span id="brush_h_el" class="ed">5</span><br /> brush: <span id="brush_w_el" class="ed">5</span> x <span id="brush_h_el" class="ed">5</span><br />
canvas: <span id="canvas_w_el" class="ed">100</span> x <span id="canvas_h_el" class="ed">30</span><br /> canvas: <span id="canvas_w_el" class="ed">100</span> x <span id="canvas_h_el" class="ed">30</span><br />
@ -90,27 +90,27 @@
</div> </div>
<!-- }}} --> <!-- }}} -->
<!-- }}} --> <!-- }}} -->
<!-- {{{ SCRIPTs: assets/js/* --> <!-- {{{ SCRIPTs: ../js/* -->
<script src="assets/js/util.js" type="text/javascript"></script> <script src="../js/util.js" type="text/javascript"></script>
<script src="assets/js/unicode.js" type="text/javascript"></script> <script src="../js/unicode.js" type="text/javascript"></script>
<script src="assets/js/color.js" type="text/javascript"></script> <script src="../js/color.js" type="text/javascript"></script>
<script src="assets/js/clipboard.js" type="text/javascript"></script> <script src="../js/clipboard.js" type="text/javascript"></script>
<script src="assets/js/lex.js" type="text/javascript"></script> <script src="../js/lex.js" type="text/javascript"></script>
<script src="assets/js/matrix.js" type="text/javascript"></script> <script src="../js/matrix.js" type="text/javascript"></script>
<script src="assets/js/gfx.js" type="text/javascript"></script> <script src="../js/gfx.js" type="text/javascript"></script>
<script src="assets/js/ui/tool.js" type="text/javascript"></script> <script src="../js/ui/tool.js" type="text/javascript"></script>
<script src="assets/js/gfx.js" type="text/javascript"></script> <script src="../js/gfx.js" type="text/javascript"></script>
<!-- }}} --> <!-- }}} -->
<!-- {{{ SCRIPTs: assets/js/ui/* --> <!-- {{{ SCRIPTs: ../js/ui/* -->
<script src="assets/js/ui/brush.js" type="text/javascript"></script> <script src="../js/ui/brush.js" type="text/javascript"></script>
<script src="assets/js/ui/canvas.js" type="text/javascript"></script> <script src="../js/ui/canvas.js" type="text/javascript"></script>
<script src="assets/js/ui/keys.js" type="text/javascript"></script> <script src="../js/ui/keys.js" type="text/javascript"></script>
<script src="assets/js/ui/controls.js" type="text/javascript"></script> <script src="../js/ui/controls.js" type="text/javascript"></script>
<script src="assets/js/ui/paletters.js" type="text/javascript"></script> <script src="../js/ui/paletters.js" type="text/javascript"></script>
<script src="assets/js/ui/selection.js" type="text/javascript"></script> <script src="../js/ui/selection.js" type="text/javascript"></script>
<script src="assets/js/ui/transform.js" type="text/javascript"></script> <script src="../js/ui/transform.js" type="text/javascript"></script>
<!-- }}} --> <!-- }}} -->
<script src="assets/js/app.js" type="text/javascript"></script> <script src="../js/app.js" type="text/javascript"></script>
</body> </body>
<!-- }}} --> <!-- }}} -->
</html> </html>

View File

@ -91,9 +91,9 @@ var clipboard = (function () {
var to_json = function(string, opts){ var to_json = function(string, opts){
var lines_in = string.split(/\r?\n/) var lines_in = string.split(/\r?\n/)
var lines_out = [] var lines_out = []
var bg = 1, bg_ansi = 30, bold = false, fg = 15, fg_ansi = 37
var w = 0, h = 0 var w = 0, h = 0
for (var y = 0; y < lines_in.length; y++) { for (var y = 0; y < lines_in.length; y++) {
var bg = 1, bold = false, fg = 15
var cells = [], line = lines_in[y] var cells = [], line = lines_in[y]
if (line.length === 0) { if (line.length === 0) {
continue continue
@ -104,29 +104,39 @@ var clipboard = (function () {
m[1].split(";").forEach(function(c){ m[1].split(";").forEach(function(c){
c = parseInt(c); c = parseInt(c);
if (c == 0) { 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) { } else if (c == 1) {
bold = true; bold = true; fg = ansi_fg_bold_import[fg_ansi];
} else if (c == 2) { } else if (c == 2) {
bold = false; bold = false; fg = ansi_fg_import[fg_ansi];
} else if (bold && (ansi_bg_bold_import[c] !== undefined)) { } else if (ansi_bg_import[c] !== undefined) {
bg = ansi_bg_bold_import[c]; bg = ansi_bg_import[c]; bg_ansi = c;
} else if (!bold && (ansi_bg_import[c] !== undefined)) {
bg = ansi_bg_import[c];
} else if (bold && (ansi_fg_bold_import[c] !== undefined)) { } 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)) { } 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); x += (m[0].length - 1);
} else { } 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 (cells.length > 0) {
if (w < cells.length) { if (w < cells.length) {
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++; lines_out.push(cells); h++;
} }

View File

@ -143,25 +143,6 @@ var ansi_bg = [
47, // Light Grey 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 = { var ansi_bg_import = {
107: 0, // Bright White 107: 0, // Bright White
40: 1, // Black 40: 1, // Black