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