mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 07:16:38 +00:00
assets/js/clipboard.js:import_ansi(): correctly support sequence of comma-separated SGR parameters.
assets/js/clipboard.js:import_ansi(): support {bold,faint,reset} SGR parameters. assets/js/color.js: adds ansi_[bf]g_bold_import[].
This commit is contained in:
parent
2578c80819
commit
6639336a25
@ -93,42 +93,37 @@ var clipboard = (function () {
|
||||
var lines_out = []
|
||||
var w = 0, h = 0
|
||||
for (var y = 0; y < lines_in.length; y++) {
|
||||
var bg = 1, fg = 15
|
||||
var bg = 1, bold = false, fg = 15
|
||||
var cells = [], line = lines_in[y]
|
||||
if (line.length === 0) {
|
||||
continue
|
||||
} else {
|
||||
for (var x = 0; x < line.length; x++) {
|
||||
var m = line.substring(x).match(/^\x1b\[(\d{1,3});(\d{1,3})m/);
|
||||
var m = line.substring(x).match(/^\x1b\[((?:\d{1,3};?)+)m/)
|
||||
if (m !== null) {
|
||||
if (ansi_bg_import[parseInt(m[1])] !== undefined) {
|
||||
bg = ansi_bg_import[parseInt(m[1])];
|
||||
m[1].split(";").forEach(function(c){
|
||||
c = parseInt(c);
|
||||
if (c == 0) {
|
||||
bg = 1; bold = false; fg = 15;
|
||||
} else if (c == 1) {
|
||||
bold = true;
|
||||
} 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];
|
||||
} else if (bold && (ansi_fg_bold_import[c] !== undefined)) {
|
||||
fg = ansi_fg_bold_import[c];
|
||||
} else if (!bold && (ansi_fg_import[c] !== undefined)) {
|
||||
fg = ansi_fg_import[c];
|
||||
}
|
||||
if (ansi_fg_import[parseInt(m[1])] !== undefined) {
|
||||
fg = ansi_fg_import[parseInt(m[1])];
|
||||
}
|
||||
if (ansi_bg_import[parseInt(m[2])] !== undefined) {
|
||||
bg = ansi_bg_import[parseInt(m[2])];
|
||||
}
|
||||
if (ansi_fg_import[parseInt(m[2])] !== undefined) {
|
||||
fg = ansi_fg_import[parseInt(m[2])];
|
||||
}
|
||||
x += (m[0].length - 1)
|
||||
} else {
|
||||
var m = line.substring(x).match(/^\x1b\[(\d{1,3})m/);
|
||||
if (m !== null) {
|
||||
if (ansi_bg_import[parseInt(m[1])] !== undefined) {
|
||||
bg = ansi_bg_import[parseInt(m[1])];
|
||||
}
|
||||
if (ansi_fg_import[parseInt(m[1])] !== undefined) {
|
||||
fg = ansi_fg_import[parseInt(m[1])];
|
||||
}
|
||||
x += (m[0].length - 1)
|
||||
});
|
||||
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
|
||||
|
@ -70,7 +70,7 @@ Object.keys(css_lookup).forEach(function(color){
|
||||
var ansi_fg = [
|
||||
97, // Bright White
|
||||
30, // Black
|
||||
94, // Light Blue
|
||||
94, // Blue
|
||||
32, // Green
|
||||
91, // Red
|
||||
31, // Light Red
|
||||
@ -80,7 +80,7 @@ var ansi_fg = [
|
||||
92, // Light Green
|
||||
36, // Cyan
|
||||
96, // Light Cyan
|
||||
34, // Blue
|
||||
34, // Light Blue
|
||||
95, // Light Pink
|
||||
90, // Grey
|
||||
37, // Light Grey
|
||||
@ -89,7 +89,7 @@ var ansi_fg = [
|
||||
var ansi_fg_import = {
|
||||
97: 0, // Bright White
|
||||
30: 1, // Black
|
||||
94: 2, // Light Blue
|
||||
94: 2, // Blue
|
||||
32: 3, // Green
|
||||
91: 4, // Red
|
||||
31: 5, // Light Red
|
||||
@ -99,16 +99,35 @@ var ansi_fg_import = {
|
||||
92: 9, // Light Green
|
||||
36: 10, // Cyan
|
||||
96: 11, // Light Cyan
|
||||
34: 12, // Blue
|
||||
34: 12, // Light Blue
|
||||
95: 13, // Light Pink
|
||||
90: 14, // Grey
|
||||
37: 15, // Light Grey
|
||||
}
|
||||
|
||||
var ansi_fg_bold_import = {
|
||||
97: 0, // Bright White
|
||||
30: 14, // Grey
|
||||
94: 12, // Light Blue
|
||||
32: 9, // Light Green
|
||||
91: 4, // Light Red
|
||||
31: 4, // Light Red
|
||||
35: 13, // Light Pink
|
||||
33: 8, // Light Yellow
|
||||
93: 8, // Light Yellow
|
||||
92: 9, // Light Green
|
||||
36: 11, // Light Cyan
|
||||
96: 11, // Light Cyan
|
||||
34: 12, // Light Blue
|
||||
95: 13, // Light Pink
|
||||
90: 14, // Grey
|
||||
37: 0, // Bright White
|
||||
}
|
||||
|
||||
var ansi_bg = [
|
||||
107, // Bright White
|
||||
40, // Black
|
||||
104, // Light Blue
|
||||
104, // Blue
|
||||
42, // Green
|
||||
101, // Red
|
||||
41, // Light Red
|
||||
@ -118,16 +137,35 @@ var ansi_bg = [
|
||||
102, // Light Green
|
||||
46, // Cyan
|
||||
106, // Light Cyan
|
||||
44, // Blue
|
||||
44, // Light Blue
|
||||
105, // Light Pink
|
||||
100, // 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 = {
|
||||
107: 0, // Bright White
|
||||
40: 1, // Black
|
||||
104: 2, // Light Blue
|
||||
104: 2, // Blue
|
||||
42: 3, // Green
|
||||
101: 4, // Red
|
||||
41: 5, // Light Red
|
||||
@ -137,7 +175,7 @@ var ansi_bg_import = {
|
||||
102: 9, // Light Green
|
||||
46: 10, // Cyan
|
||||
106: 11, // Light Cyan
|
||||
44: 12, // Blue
|
||||
44: 12, // Light Blue
|
||||
105: 13, // Light Pink
|
||||
100: 14, // Grey
|
||||
47: 15, // Light Grey
|
||||
|
Loading…
Reference in New Issue
Block a user