##// END OF EJS Templates
add indexed-color in 256-color support
MinRK -
Show More
@@ -158,7 +158,7 IPython.utils = (function (IPython) {
158 //Map from terminal commands to CSS classes
158 //Map from terminal commands to CSS classes
159 var ansi_colormap = {
159 var ansi_colormap = {
160 "01":"ansibold",
160 "01":"ansibold",
161
161
162 "30":"ansiblack",
162 "30":"ansiblack",
163 "31":"ansired",
163 "31":"ansired",
164 "32":"ansigreen",
164 "32":"ansigreen",
@@ -167,7 +167,7 IPython.utils = (function (IPython) {
167 "35":"ansipurple",
167 "35":"ansipurple",
168 "36":"ansicyan",
168 "36":"ansicyan",
169 "37":"ansigray",
169 "37":"ansigray",
170
170
171 "40":"ansibgblack",
171 "40":"ansibgblack",
172 "41":"ansibgred",
172 "41":"ansibgred",
173 "42":"ansibggreen",
173 "42":"ansibggreen",
@@ -197,11 +197,21 IPython.utils = (function (IPython) {
197 var index_or_rgb = numbers.shift();
197 var index_or_rgb = numbers.shift();
198 var r,g,b;
198 var r,g,b;
199 if (index_or_rgb == "5") {
199 if (index_or_rgb == "5") {
200 // indexed 256 color
200 var idx = parseInt(numbers.shift());
201 var idx = parseInt(numbers.shift());
201 if (idx < 16) {
202 if (idx < 16) {
202 // indexed color, not supported
203 // indexed ANSI
204 // ignore bright / non-bright distinction
205 idx = idx % 8;
206 var ansiclass = ansi_colormap[n[0] + (idx % 8).toString()];
207 if ( ! attrs["class"] ) {
208 attrs["class"] = ansiclass;
209 } else {
210 attrs["class"] += " " + ansiclass;
211 }
212 return;
203 } else if (idx < 232) {
213 } else if (idx < 232) {
204 // 216 color 6x6x6
214 // 216 color 6x6x6 RGB
205 idx = idx - 16;
215 idx = idx - 16;
206 b = idx % 6;
216 b = idx % 6;
207 g = Math.floor(idx / 6) % 6;
217 g = Math.floor(idx / 6) % 6;
@@ -215,14 +225,14 IPython.utils = (function (IPython) {
215 idx = idx - 231;
225 idx = idx - 231;
216 // it's 1-24 and should *not* include black or white,
226 // it's 1-24 and should *not* include black or white,
217 // so a 26 point scale
227 // so a 26 point scale
218 r = g = b = idx * 256 / 26;
228 r = g = b = Math.floor(idx * 256 / 26);
219 }
229 }
220 } else if (index_or_rgb == "2") {
230 } else if (index_or_rgb == "2") {
231 // Simple 24 bit RGB
221 if (numbers.length > 3) {
232 if (numbers.length > 3) {
222 console.log("Not enough fields for RGB", numbers);
233 console.log("Not enough fields for RGB", numbers);
223 return;
234 return;
224 }
235 }
225 // simple rgb
226 r = numbers.shift();
236 r = numbers.shift();
227 g = numbers.shift();
237 g = numbers.shift();
228 b = numbers.shift();
238 b = numbers.shift();
General Comments 0
You need to be logged in to leave comments. Login now