| 1 | // todo: vt102 printing (vt102 user guide, chapter 5, "printing")
|
|---|
| 2 | /**
|
|---|
| 3 | * @constructor
|
|---|
| 4 | */
|
|---|
| 5 | function TTVParser(term_cb, dbg)
|
|---|
| 6 | {
|
|---|
| 7 | var parser = this;
|
|---|
| 8 |
|
|---|
| 9 | parser.debug = function(txt)
|
|---|
| 10 | {
|
|---|
| 11 | dbg ? dbg("parse.js: "+txt) : alert("parse.js: "+txt);
|
|---|
| 12 | }
|
|---|
| 13 | parser.emu = term_cb;
|
|---|
| 14 | parser.buffer = '';
|
|---|
| 15 |
|
|---|
| 16 | return parser;
|
|---|
| 17 | };
|
|---|
| 18 |
|
|---|
| 19 | TTVParser.prototype.parse = function(str)
|
|---|
| 20 | {
|
|---|
| 21 | /*
|
|---|
| 22 | // This version would work very nicely if browswers would
|
|---|
| 23 | // already support the y-modifier
|
|---|
| 24 | if (!this.pos)
|
|---|
| 25 | this.pos = 0;
|
|---|
| 26 |
|
|---|
| 27 | while (this.pos<pos)
|
|---|
| 28 | {
|
|---|
| 29 | for (var i=0; i<this.handlables.length; i++)
|
|---|
| 30 | {
|
|---|
| 31 | // Check regex
|
|---|
| 32 | this.handlables[i][0].lastIndex = this.pos;
|
|---|
| 33 | var match = this.handlables[i][0].exec(str);
|
|---|
| 34 | if (match && match[0].length>0)
|
|---|
| 35 | {
|
|---|
| 36 | // Call corresponding (callback-)function to process the match
|
|---|
| 37 | this.handlables[i][1].call(this, match);
|
|---|
| 38 |
|
|---|
| 39 | // Remove match from buffer
|
|---|
| 40 | //this.buffer = this.buffer.substr(match[0].length);
|
|---|
| 41 |
|
|---|
| 42 | //alert("i="+this.handlables[i][0].lastIndex+" "+match[0].length);
|
|---|
| 43 |
|
|---|
| 44 | this.pos += match[0].length;//this.handlables[i][0].lastIndex;
|
|---|
| 45 | break;
|
|---|
| 46 | }
|
|---|
| 47 | }
|
|---|
| 48 | }
|
|---|
| 49 | */
|
|---|
| 50 |
|
|---|
| 51 | this.buffer += str;
|
|---|
| 52 | while (this.handleBuffer()) { };
|
|---|
| 53 | };
|
|---|
| 54 |
|
|---|
| 55 | TTVParser.prototype.getBuffer = function()
|
|---|
| 56 | {
|
|---|
| 57 | return this.buffer;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | TTVParser.prototype.setBuffer = function(obj)
|
|---|
| 61 | {
|
|---|
| 62 | this.buffer = obj;
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | TTVParser.prototype.handleBuffer = function()
|
|---|
| 66 | {
|
|---|
| 67 | for (var i=0; i<this.handlables.length; i++)
|
|---|
| 68 | {
|
|---|
| 69 | // Check regex
|
|---|
| 70 | var match = this.handlables[i][0].exec(this.buffer);
|
|---|
| 71 | if (!match || match[0].length==0)
|
|---|
| 72 | continue;
|
|---|
| 73 |
|
|---|
| 74 | // FIXME: It is most probably much more efficient to
|
|---|
| 75 | // check for the first character and in case of an escape
|
|---|
| 76 | // sequence only compare the remaining string.
|
|---|
| 77 |
|
|---|
| 78 | // Call corresponding (callback-)function to process the match
|
|---|
| 79 | this.handlables[i][1].call(this, match);
|
|---|
| 80 |
|
|---|
| 81 | // Remove match from buffer
|
|---|
| 82 | this.buffer = this.buffer.substr(match[0].length);
|
|---|
| 83 |
|
|---|
| 84 | return true;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | // If we have not yet found the right escape sequence and
|
|---|
| 88 | // the first character is an escape character, remove it.
|
|---|
| 89 | // Otherwise we get stuck. We could do that as last check
|
|---|
| 90 | // in the loop over the handlabels, but maybe a sequence
|
|---|
| 91 | // ot split into to chunks.
|
|---|
| 92 | if (this.buffer.length>50 && this.buffer[0]=='\033')
|
|---|
| 93 | {
|
|---|
| 94 | this.debug("Unknown escape sequence: "+
|
|---|
| 95 | this.buffer[1].charCodeAt(0).toString(16)+" "+
|
|---|
| 96 | this.buffer[2].charCodeAt(0).toString(16)+" "+
|
|---|
| 97 | this.buffer[3].charCodeAt(0).toString(16)+" "+
|
|---|
| 98 | this.buffer[4].charCodeAt(0).toString(16)+" "+
|
|---|
| 99 | this.buffer[5].charCodeAt(0).toString(16)+" "+
|
|---|
| 100 | this.buffer[6].charCodeAt(0).toString(16)+" "+
|
|---|
| 101 | this.buffer[7].charCodeAt(0).toString(16)+" "+
|
|---|
| 102 | this.buffer[8].charCodeAt(0).toString(16)+" "+
|
|---|
| 103 | this.buffer[9].charCodeAt(0).toString(16)+" ["+this.buffer+"]");
|
|---|
| 104 | this.emu.ev_normalString('\0');
|
|---|
| 105 |
|
|---|
| 106 | this.buffer = this.buffer.substr(1);
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | return false;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | // Should be ordered by frequency of occurance
|
|---|
| 113 | TTVParser.prototype.handlables =
|
|---|
| 114 | [
|
|---|
| 115 | ////////////////////////////////////////////////////////////////////////////////
|
|---|
| 116 | // UTF-8
|
|---|
| 117 | // 1 byte: 0xxxxxxx // standard ascii
|
|---|
| 118 | // 2 byte: 110xxxxx 10xxxxxx // c0-c1
|
|---|
| 119 | // 3 byte: 1110xxxx 10xxxxxx 10xxxxxx // f5-ff
|
|---|
| 120 | // 4 byte: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
|---|
| 121 |
|
|---|
| 122 | // ascii // Everything except escape, special chars and 1xxxx xxxx
|
|---|
| 123 | // was: [/^[^\033\007\010\011\012\013\014\015\016\017\x80-\xFF]?/,
|
|---|
| 124 | [/^[\x20-\x7F]+/, function (m) {
|
|---|
| 125 | this.emu.ev_normalString(m[0]);
|
|---|
| 126 | }],
|
|---|
| 127 | //[/^([\x80-\xC1]|[\xF5-\xFF])/, function (m) {
|
|---|
| 128 | // this.debug("Malformed unicode[1]: "+m[0].charCodeAt(0).toString(16));
|
|---|
| 129 | // this.cb('normalString', '\0');
|
|---|
| 130 | //}],
|
|---|
| 131 |
|
|---|
| 132 | // was: [/^[\xC2\xDF][\x80-\xBF]/
|
|---|
| 133 | [/^[\xC2-\xDF][\x80-\xBF]/, function (m) {
|
|---|
| 134 | var p1 = m[0].charCodeAt(0) & 0x1f; // 0001 1111
|
|---|
| 135 | var p2 = m[0].charCodeAt(1) & 0x3f; // 0011 1111
|
|---|
| 136 | var code = (p1<<6) | p2;
|
|---|
| 137 | this.emu.ev_normalString(String.fromCharCode(code));
|
|---|
| 138 | }],
|
|---|
| 139 | //[/^[\xC2-\xDF][\x00-\xFF]/, function (m) {
|
|---|
| 140 | // this.debug("Malformed unicode[2]: "+m[0].charCodeAt(0).toString(16)+" "+m[0].charCodeAt(1).toString(16));
|
|---|
| 141 | // this.cb('normalString', '\0');
|
|---|
| 142 | //}],
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 | ////////////////////////////////////////////////////////////////////////////////
|
|---|
| 146 | // attributes (colors)
|
|---|
| 147 | [/^\033\[([0-9;]*)m/, function (m) {
|
|---|
| 148 | this.emu.ev_setAttribute(m[1].split(';'));
|
|---|
| 149 | }],
|
|---|
| 150 | ////////////////////////////////////////////////////////////////////////////////
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 | // was: [/^(\xE0[\xA0-\xBF]|[\xE1-\xEC][\x80-\xBF]|\xED[\x80-\x9F]|[\xEE-\xEF][\x80-\xBF])[\x80-\xBF]/
|
|---|
| 154 | [/^[\xE0-\xEF][\x80-\xBF][\x80-\xBF]/, function (m) {
|
|---|
| 155 | var p1 = m[0].charCodeAt(0) & 0x0f; // 0000 1111
|
|---|
| 156 | var p2 = m[0].charCodeAt(1) & 0x3f; // 1000 0000
|
|---|
| 157 | var p3 = m[0].charCodeAt(2) & 0x3f; // 1000 0000
|
|---|
| 158 | var code = (p1<<12) | (p2<<6) | p3;
|
|---|
| 159 | this.emu.ev_normalString(String.fromCharCode(code));
|
|---|
| 160 | }],
|
|---|
| 161 | //[/^[\xE0-\xEF][\x00-\xFF][\x00-\xFF]/, function (m) {
|
|---|
| 162 | // this.debug("Malformed unicode[3]: "+m[0].charCodeAt(0).toString(16)+" "+m[0].charCodeAt(1).toString(16)+" "+m[0].charCodeAt(2).toString(16));
|
|---|
| 163 | // this.cb('normalString', '\0');
|
|---|
| 164 | //}],
|
|---|
| 165 |
|
|---|
| 166 | // was: [/^(\xF0[\x90-\xBF]|[\xF1-\xF3][\x80-\xBF]|\xF4[\x80-\x8F])[\x80-\xBF][\x80-\xBF]/
|
|---|
| 167 | [/^[\xF0-\xF4][\x80-\xBF][\x80-\xBF][\x80-\xBF]/, function (m) {
|
|---|
| 168 | var p1 = m[0].charCodeAt(0) & 0x07; // 0000 0111
|
|---|
| 169 | var p2 = m[0].charCodeAt(1) & 0x3f; // 0011 1111
|
|---|
| 170 | var p3 = m[0].charCodeAt(2) & 0x3f; // 0011 1111
|
|---|
| 171 | var p4 = m[0].charCodeAt(3) & 0x3f; // 0011 1111
|
|---|
| 172 | var code = (p1<<18) | (p2<<12) | (p3<<6) | p4;
|
|---|
| 173 | this.emu.ev_normalString(String.fromCharCode(code));
|
|---|
| 174 | }],
|
|---|
| 175 | //[/^[\xF0-\xF4][\x00-\xFF][\x00-\xFF][\x00-\xFF]/, function (m) {
|
|---|
| 176 | // this.debug("Malformed unicode[4]: "+m[0].charCodeAt(0).toString(16)+" "+m[0].charCodeAt(1).toString(16)+" "+m[0].charCodeAt(3).toString(16)+" "+m[0].charCodeAt(4).toString(16));
|
|---|
| 177 | // this.cb('normalString', '\0');
|
|---|
| 178 | //}],
|
|---|
| 179 |
|
|---|
| 180 | // This is how my shell processed unknown characters... if no proper unicode character
|
|---|
| 181 | // is detected, the characters are interpreted one-by-one
|
|---|
| 182 | [/^([\x80-\xFF])/, function (m) {
|
|---|
| 183 | // The best thing we can do is to assume that this is
|
|---|
| 184 | // 8bit ascii
|
|---|
| 185 | this.emu.ev_normalString(m[0]);
|
|---|
| 186 | // this.debug("Invalid code: "+m[0].charCodeAt(0).toString(16)+" ["+m[0]+"]");
|
|---|
| 187 | // this.cb('normalString', '\0');
|
|---|
| 188 | }],
|
|---|
| 189 |
|
|---|
| 190 | ////////////////////////////////////////////////////////////////////////////////
|
|---|
| 191 | // control characters
|
|---|
| 192 | [/^\007/, function (m) {
|
|---|
| 193 | this.emu.ev_specialChar('bell');
|
|---|
| 194 | }],
|
|---|
| 195 | [/^\010/, function (m) {
|
|---|
| 196 | this.emu.ev_specialChar('backspace');
|
|---|
| 197 | }],
|
|---|
| 198 | [/^\011/, function (m) {
|
|---|
| 199 | this.emu.ev_specialChar('horizontalTab');
|
|---|
| 200 | }],
|
|---|
| 201 | [/^\012/, function (m) {
|
|---|
| 202 | this.emu.ev_specialChar('lineFeed');
|
|---|
| 203 | }],
|
|---|
| 204 | [/^\013/, function (m) {
|
|---|
| 205 | this.emu.ev_specialChar('verticalTab');
|
|---|
| 206 | }],
|
|---|
| 207 | [/^\014/, function (m) {
|
|---|
| 208 | this.emu.ev_specialChar('formFeed');
|
|---|
| 209 | }],
|
|---|
| 210 | [/^\015/, function (m) {
|
|---|
| 211 | this.emu.ev_specialChar('carriageReturn');
|
|---|
| 212 | }],
|
|---|
| 213 | [/^\016/, function (m) {
|
|---|
| 214 | this.emu.ev_switchCharset('g1');
|
|---|
| 215 | }],
|
|---|
| 216 | [/^\017/, function (m) {
|
|---|
| 217 | this.emu.ev_switchCharset('g0');
|
|---|
| 218 | }],
|
|---|
| 219 |
|
|---|
| 220 | [/^\033F/, function (m) { // vt52: enter graphics mode
|
|---|
| 221 | //this.emu.ev_switchCharset('g0', 'line');
|
|---|
| 222 | }],
|
|---|
| 223 | [/^\033G/, function (m) { // vt52: exit graphics mode
|
|---|
| 224 | //this.emu.ev_switchCharset('g0', 'us');
|
|---|
| 225 | }],
|
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 | ////////////////////////////////////////////////////////////////////////////////
|
|---|
| 229 | // very often used: home and goto
|
|---|
| 230 |
|
|---|
| 231 | [/^\033\[[Hf]/, function (m) {
|
|---|
| 232 | this.emu.ev_goto( 1, 1 );
|
|---|
| 233 | }],
|
|---|
| 234 | [/^\033\[([0-9]*)G/, function (m) {
|
|---|
| 235 | this.emu.ev_goto(parseInt(m[1] || '1', 10), -1); // y=-1 (keep line)
|
|---|
| 236 | }],
|
|---|
| 237 |
|
|---|
| 238 | // cursor set position
|
|---|
| 239 | [/^\033\[([0-9]*);([0-9]*)[Hf]/, function (m) {
|
|---|
| 240 | this.emu.ev_goto(parseInt(m[2] || '1', 10), parseInt(m[1] || '1', 10));
|
|---|
| 241 | }],
|
|---|
| 242 | [/^\033\[([0-9]*)d/, function (m) {
|
|---|
| 243 | this.emu.ev_goto(1, parseInt(m[1] || '1', 10));
|
|---|
| 244 |
|
|---|
| 245 | }],
|
|---|
| 246 |
|
|---|
| 247 | ////////////////////////////////////////////////////////////////////////////////
|
|---|
| 248 | // obsolete control characters
|
|---|
| 249 |
|
|---|
| 250 | [/^[\000-\006]/, function() { } ],
|
|---|
| 251 | [/^[\020-\032]/, function() { } ],
|
|---|
| 252 | [/^[\034-\037]/, function() { } ],
|
|---|
| 253 | /*
|
|---|
| 254 | [/^\000/, function (m) {
|
|---|
| 255 | this.cb('specialChar', 'null');
|
|---|
| 256 | }],
|
|---|
| 257 | [/^\001/, function (m) {
|
|---|
| 258 | this.cb('specialChar', 'startOfHeading');
|
|---|
| 259 | }],
|
|---|
| 260 | [/^\002/, function (m) {
|
|---|
| 261 | this.cb('specialChar', 'startOfText');
|
|---|
| 262 | }],
|
|---|
| 263 | [/^\003/, function (m) {
|
|---|
| 264 | this.cb('specialChar', 'endOfText');
|
|---|
| 265 | }],
|
|---|
| 266 | [/^\004/, function (m) {
|
|---|
| 267 | this.cb('specialChar', 'endOfTransmission');
|
|---|
| 268 | }],
|
|---|
| 269 | [/^\005/, function (m) {
|
|---|
| 270 | this.cb('specialChar', 'enquiry');
|
|---|
| 271 | }],
|
|---|
| 272 | [/^\006/, function (m) {
|
|---|
| 273 | this.cb('specialChar', 'acknoledge');
|
|---|
| 274 | }],
|
|---|
| 275 |
|
|---|
| 276 | [/^\020/, function (m) {
|
|---|
| 277 | this.cb('specialChar', 'dataLinkEscape');
|
|---|
| 278 | }],
|
|---|
| 279 | [/^\021/, function (m) {
|
|---|
| 280 | this.cb('specialChar', 'deviceControl1');
|
|---|
| 281 | }],
|
|---|
| 282 | [/^\022/, function (m) {
|
|---|
| 283 | this.cb('specialChar', 'deviceControl2');
|
|---|
| 284 | }],
|
|---|
| 285 | [/^\023/, function (m) {
|
|---|
| 286 | this.cb('specialChar', 'deviceControl3');
|
|---|
| 287 | }],
|
|---|
| 288 | [/^\024/, function (m) {
|
|---|
| 289 | this.cb('specialChar', 'deviceControl4');
|
|---|
| 290 | }],
|
|---|
| 291 | [/^\025/, function (m) {
|
|---|
| 292 | this.cb('specialChar', 'negativeAcknowledge');
|
|---|
| 293 | }],
|
|---|
| 294 | [/^\026/, function (m) {
|
|---|
| 295 | this.cb('specialChar', 'synchronousIdle');
|
|---|
| 296 | }],
|
|---|
| 297 | [/^\027/, function (m) {
|
|---|
| 298 | this.cb('specialChar', 'endOfTransmissionBlok');
|
|---|
| 299 | }],
|
|---|
| 300 | [/^\030/, function (m) {
|
|---|
| 301 | this.cb('specialChar', 'cancel');
|
|---|
| 302 | }],
|
|---|
| 303 | [/^\031/, function (m) {
|
|---|
| 304 | this.cb('specialChar', 'endOfMedium');
|
|---|
| 305 | }],
|
|---|
| 306 | [/^\032/, function (m) {
|
|---|
| 307 | this.cb('specialChar', 'substitute');
|
|---|
| 308 | }],
|
|---|
| 309 | [/^\034/, function (m) {
|
|---|
| 310 | this.cb('specialChar', 'fileSeparator');
|
|---|
| 311 | }],
|
|---|
| 312 | [/^\035/, function (m) {
|
|---|
| 313 | this.cb('specialChar', 'groupSeparator');
|
|---|
| 314 | }],
|
|---|
| 315 | [/^\036/, function (m) {
|
|---|
| 316 | this.cb('specialChar', 'recordSeparator');
|
|---|
| 317 | }],
|
|---|
| 318 | [/^\037/, function (m) {
|
|---|
| 319 | this.cb('specialChar', 'unitSeparator');
|
|---|
| 320 | }],
|
|---|
| 321 | */
|
|---|
| 322 |
|
|---|
| 323 | ////////////////////////////////////////////////////////////////////////////////
|
|---|
| 324 |
|
|---|
| 325 | // erase in line
|
|---|
| 326 | [/^\033\[0?K/, function (m) {
|
|---|
| 327 | this.emu.ev_eraseInLine('toEnd');
|
|---|
| 328 | }],
|
|---|
| 329 | [/^\033\[1K/, function (m) {
|
|---|
| 330 | this.emu.ev_eraseInLine('toStart');
|
|---|
| 331 | }],
|
|---|
| 332 | [/^\033\[2K/, function (m) {
|
|---|
| 333 | this.emu.ev_eraseInLine('whole');
|
|---|
| 334 | }],
|
|---|
| 335 | [/^\033K/, function (m) { // vt52
|
|---|
| 336 | this.emu.ev_eraseInLine('toEnd');
|
|---|
| 337 | }],
|
|---|
| 338 |
|
|---|
| 339 | // erase in display
|
|---|
| 340 | [/^\033\[0?J/, function (m) {
|
|---|
| 341 | this.emu.ev_eraseInDisplay('toEnd');
|
|---|
| 342 | }],
|
|---|
| 343 | [/^\033\[1J/, function (m) {
|
|---|
| 344 | this.emu.ev_eraseInDisplay('toStart');
|
|---|
| 345 | }],
|
|---|
| 346 | [/^\033\[2J/, function (m) {
|
|---|
| 347 | this.emu.ev_eraseInDisplay('whole');
|
|---|
| 348 | }],
|
|---|
| 349 | [/^\033J/, function (m) { // vt52
|
|---|
| 350 | this.emu.ev_eraseInDisplay('toEnd');
|
|---|
| 351 | }],
|
|---|
| 352 |
|
|---|
| 353 | // insertion and deletion
|
|---|
| 354 | [/^\033\[([0-9]*)P/, function (m) {
|
|---|
| 355 | this.emu.ev_deleteChars(parseInt(m[1] || '1', 10));
|
|---|
| 356 | }],
|
|---|
| 357 | [/^\033\[([0-9]*)X/, function (m) {
|
|---|
| 358 | this.emu.ev_deleteChars(parseInt(m[1] || '1', 10));
|
|---|
| 359 | }],
|
|---|
| 360 | [/^\033\[([0-9]*)L/, function (m) {
|
|---|
| 361 | this.emu.ev_insertLines(parseInt(m[1] ||'1', 10));
|
|---|
| 362 | }],
|
|---|
| 363 | [/^\033\[([0-9]*)M/, function (m) {
|
|---|
| 364 | this.emu.ev_deleteLines(parseInt(m[1] || '1', 10));
|
|---|
| 365 | }],
|
|---|
| 366 | [/^\033\[([0-9])*@/, function (m) { // insert N characters
|
|---|
| 367 | this.emu.ev_insertChars(parseInt(m[1] || '1', 10));
|
|---|
| 368 | //this.emu.ev_mode('insertLimited', parseInt(m[1] || '1', 10));
|
|---|
| 369 | }],
|
|---|
| 370 |
|
|---|
| 371 | // margins
|
|---|
| 372 | [/^\033\[([0-9]+);([0-9]+)r/, function (m) {
|
|---|
| 373 | this.emu.ev_setMargins(parseInt(m[1], 10), parseInt(m[2], 10));
|
|---|
| 374 | }],
|
|---|
| 375 | [/^\033\[r/, function (m) {
|
|---|
| 376 | this.emu.ev_resetMargins();
|
|---|
| 377 | }],
|
|---|
| 378 |
|
|---|
| 379 | ////////////////////////////////////////////////////////////////////////////////
|
|---|
| 380 | // control sequences
|
|---|
| 381 |
|
|---|
| 382 | // 3: italic (rxvt)
|
|---|
| 383 | // 6: overline (eterm)
|
|---|
| 384 | // 9: strikeout (gnome, guake, nautilus, terminator, xfce4, vte)
|
|---|
| 385 | [/^\033\[\[([0-9;]*)m/, function (m) {
|
|---|
| 386 | }],
|
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 | // arrow keys
|
|---|
| 390 | [/^\033\[([0-9]*)A/, function (m) {
|
|---|
| 391 | this.emu.ev_arrow('up', parseInt(m[1] || '1', 10));
|
|---|
| 392 | }],
|
|---|
| 393 | [/^\033\[([0-9]*)B/, function (m) {
|
|---|
| 394 | this.emu.ev_arrow('down', parseInt(m[1] || '1', 10));
|
|---|
| 395 | }],
|
|---|
| 396 | [/^\033\[([0-9]*)C/, function (m) {
|
|---|
| 397 | this.emu.ev_arrow('right', parseInt(m[1] || '1', 10));
|
|---|
| 398 | }],
|
|---|
| 399 | [/^\033\[([0-9]*)D/, function (m) {
|
|---|
| 400 | this.emu.ev_arrow('left', parseInt(m[1] || '1', 10));
|
|---|
| 401 | }],
|
|---|
| 402 | [/^\033\[([0-9]*)E/, function (m) {
|
|---|
| 403 | this.emu.ev_index('nextLine', parseInt(m[1] || '1', 10));
|
|---|
| 404 | }],
|
|---|
| 405 | [/^\033\[([0-9]*)F/, function (m) {
|
|---|
| 406 | this.emu.ev_index('prevLine', parseInt(m[1] || '1', 10));
|
|---|
| 407 | }],
|
|---|
| 408 |
|
|---|
| 409 | [/^\033A([\x20-\x7F]?)/, function (m) { // vt52
|
|---|
| 410 | this.emu.ev_arrow('up', m[1] ? m[1].charCodeAt(0)-32+1 : 1);
|
|---|
| 411 | }],
|
|---|
| 412 | [/^\033B([\x20-\x7F]?)/, function (m) { // vt52
|
|---|
| 413 | this.emu.ev_arrow('down', m[1] ? m[1].charCodeAt(0)-32+1 : 1);
|
|---|
| 414 | }],
|
|---|
| 415 | [/^\033C([\x20-\x7F]?)/, function (m) { // vt52
|
|---|
| 416 | this.emu.ev_arrow('right', m[1] ? m[1].charCodeAt(0)-32+1 : 1);
|
|---|
| 417 | }],
|
|---|
| 418 | [/^\033D/, function (m) { // vt52
|
|---|
| 419 | this.emu.ev_arrow('left', 1);
|
|---|
| 420 | }],
|
|---|
| 421 | [/^\033Y(..)/, function (m) { // vt52
|
|---|
| 422 | this.emu.ev_goto(m[1].charCodeAt(1)-32+1, m[1].charCodeAt(0)-32+1);
|
|---|
| 423 | }],
|
|---|
| 424 |
|
|---|
| 425 | // vt52: \033I reverse line feed
|
|---|
| 426 | // \033l move to first line (keep x)
|
|---|
| 427 |
|
|---|
| 428 | // cursor to lower left corner (vt100)
|
|---|
| 429 | //[/^\033F/, function (m) {
|
|---|
| 430 | //}],
|
|---|
| 431 |
|
|---|
| 432 | // \033[{n}Z cursor back tab
|
|---|
| 433 | // \033[{n}I cursor horizontal tab
|
|---|
| 434 | // \033[{n}W cursor tab stop control
|
|---|
| 435 | // \033[{n}Y cursor vertical tab
|
|---|
| 436 | // \033[{n}P delete character
|
|---|
| 437 | // \033#8 screen alignment display
|
|---|
| 438 | // \033[H horizontal tab stop
|
|---|
| 439 |
|
|---|
| 440 |
|
|---|
| 441 | // index and friends
|
|---|
| 442 | [/^\033D/, function (m) {
|
|---|
| 443 | this.emu.ev_index('down', 1);
|
|---|
| 444 | }],
|
|---|
| 445 | [/^\033M/, function (m) {
|
|---|
| 446 | this.emu.ev_index('up', 1);
|
|---|
| 447 | }],
|
|---|
| 448 | [/^\033E/, function (m) {
|
|---|
| 449 | this.emu.ev_index('nextLine', 1);
|
|---|
| 450 | }],
|
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 | // \033[6] back index
|
|---|
| 454 | // \033[9] forward index
|
|---|
| 455 |
|
|---|
| 456 | // cursor save/restore
|
|---|
| 457 | // Saves in terminal memory the:
|
|---|
| 458 | // cursor position
|
|---|
| 459 | // graphic rendition
|
|---|
| 460 | // character set shift state
|
|---|
| 461 | // state of wrap flag
|
|---|
| 462 | // state of origin mode
|
|---|
| 463 | // state of selective erase
|
|---|
| 464 | [/^\033[7]/, function (m) {
|
|---|
| 465 | this.emu.ev_cursorStack('push', true);
|
|---|
| 466 | }],
|
|---|
| 467 | [/^\033[8]/, function (m) {
|
|---|
| 468 | this.emu.ev_cursorStack('pop', true);
|
|---|
| 469 | }],
|
|---|
| 470 | // cursor save/restore position only
|
|---|
| 471 | [/^\033\[s/, function (m) {
|
|---|
| 472 | this.emu.ev_cursorStack('push', false);
|
|---|
| 473 | }],
|
|---|
| 474 | [/^\033\[u/, function (m) {
|
|---|
| 475 | this.emu.ev_cursorStack('pop', false);
|
|---|
| 476 | }],
|
|---|
| 477 |
|
|---|
| 478 | // keypad
|
|---|
| 479 | [/^\033=/, function (m) {
|
|---|
| 480 | this.emu.ev_mode('keypad', 'cursor');
|
|---|
| 481 | }],
|
|---|
| 482 | [/^\033>/, function (m) {
|
|---|
| 483 | this.emu.ev_mode('keypad', 'numeric');
|
|---|
| 484 | }],
|
|---|
| 485 |
|
|---|
| 486 | // mode set/reset
|
|---|
| 487 | //[/^\033\[(\??)([^\033]*?)h/, function (m) {
|
|---|
| 488 | [/^\033\[(\??)([0-9;]+)h/, function (m) {
|
|---|
| 489 | var me = this;
|
|---|
| 490 | m[2].split(';').forEach(function (sub) {
|
|---|
| 491 | me.setMode(m[1] + sub);
|
|---|
| 492 | });
|
|---|
| 493 | }],
|
|---|
| 494 | //[/^\033\[(\??)([^\033]*?)l/, function (m) {
|
|---|
| 495 | [/^\033\[(\??)([0-9;]+)l/, function (m) {
|
|---|
| 496 | var me = this;
|
|---|
| 497 | m[2].split(';').forEach(function (sub) {
|
|---|
| 498 | me.resetMode(m[1] + sub);
|
|---|
| 499 | });
|
|---|
| 500 | }],
|
|---|
| 501 |
|
|---|
| 502 | // curser layout; '\033[?17;0;0c' hide cursor
|
|---|
| 503 | [/^\033\[\?([0-9;]*)c/, function (m) {
|
|---|
| 504 | this.debug("cursor layout"+m[1]);
|
|---|
| 505 | }],
|
|---|
| 506 |
|
|---|
| 507 | // horizontal tab stops
|
|---|
| 508 | [/^\033H/, function (m) {
|
|---|
| 509 | //this.emu.ev_tabStop('add'); // set a tab stop at the current position
|
|---|
| 510 | this.emu.ev_goto( 1, 1); // vt52: home
|
|---|
| 511 | }],
|
|---|
| 512 | [/^\033\[0?g/, function (m) {
|
|---|
| 513 | this.emu.ev_tabStop('remove'); // clear tabs at the current position
|
|---|
| 514 | }],
|
|---|
| 515 | [/^\033\[3g/, function (m) {
|
|---|
| 516 | this.emu.ev_tabStop('clear'); // clear all tab stops
|
|---|
| 517 | }],
|
|---|
| 518 |
|
|---|
| 519 | // line attributes
|
|---|
| 520 | [/^\033#3/, function (m) {
|
|---|
| 521 | this.emu.ev_lineAttr('dwdhTopHalf');
|
|---|
| 522 | }],
|
|---|
| 523 | [/^\033#4/, function (m) {
|
|---|
| 524 | this.emu.ev_lineAttr('dwdhBottomHalf');
|
|---|
| 525 | }],
|
|---|
| 526 | [/^\033#5/, function (m) {
|
|---|
| 527 | this.emu.ev_lineAttr('swsh');
|
|---|
| 528 | }],
|
|---|
| 529 | [/^\033#6/, function (m) {
|
|---|
| 530 | this.emu.ev_lineAttr('dwsh');
|
|---|
| 531 | }],
|
|---|
| 532 |
|
|---|
| 533 | // erase in area
|
|---|
| 534 | // \033\[0?K toEnd
|
|---|
| 535 | // \033\[1K toStart
|
|---|
| 536 | // \033\[2K whole
|
|---|
| 537 |
|
|---|
| 538 | // erase in field
|
|---|
| 539 | // \033\[0?N toEnd
|
|---|
| 540 | // \033\[1N toStart
|
|---|
| 541 | // \033\[2N whole
|
|---|
| 542 |
|
|---|
| 543 | // erase character
|
|---|
| 544 | // \033[{N}X
|
|---|
| 545 |
|
|---|
| 546 | // \033[{N}T scroll down
|
|---|
| 547 | // \033[{N}S scroll up
|
|---|
| 548 |
|
|---|
| 549 |
|
|---|
| 550 | // There is \033[?...J as well (erase "selective" in display)
|
|---|
| 551 | // There is \033[?...K as well (erase "selective" in line)
|
|---|
| 552 |
|
|---|
| 553 | // \033V Start of guarded area
|
|---|
| 554 | // \033W End of guarded area
|
|---|
| 555 |
|
|---|
| 556 | // \033l Lock memory above cursor
|
|---|
| 557 | // \033m Unlock memory above cursor
|
|---|
| 558 |
|
|---|
| 559 | // reset
|
|---|
| 560 | [/^\033\[!p/, function (m) {
|
|---|
| 561 | this.emu.ev_softReset();
|
|---|
| 562 | }],
|
|---|
| 563 | [/^\033c/, function (m) {
|
|---|
| 564 | this.emu.ev_reset();
|
|---|
| 565 | }],
|
|---|
| 566 |
|
|---|
| 567 | // resize terminal: \e[8;{height};{width}t
|
|---|
| 568 | [/^\033\[([0-9;]*)t/, function (m) {
|
|---|
| 569 | }],
|
|---|
| 570 |
|
|---|
| 571 | // xterm-style titles
|
|---|
| 572 | [/^\033\]2;([^\033\007]*)\007/, function (m) {
|
|---|
| 573 | this.emu.ev_setWindowTitle(m[1]);
|
|---|
| 574 | }],
|
|---|
| 575 | [/^\033\]1;([^\033\007]*)\007/, function (m) {
|
|---|
| 576 | this.emu.ev_setIconTitle(m[1]);
|
|---|
| 577 | }],
|
|---|
| 578 | [/^\033\]0;([^\033\007]*)\007/, function (m) {
|
|---|
| 579 | this.emu.ev_setWindowIconTitle(m[1]);
|
|---|
| 580 | }],
|
|---|
| 581 |
|
|---|
| 582 | // character set selection
|
|---|
| 583 | // United kingdom: (A, )A, *A, +A [g0, g1, g2, g3]
|
|---|
| 584 | // USASCII: (B, )B, *B, +B [g0, g1, g2, g3]
|
|---|
| 585 | // graphics: (0, )0, *0, +0 [g0, g1, g2, g3]
|
|---|
| 586 | // graphics: (1, )1, *1, +1 [g0, g1, g2, g3]
|
|---|
| 587 | // graphics: (2, )2, *2, +2 [g0, g1, g2, g3]
|
|---|
| 588 | [/^\033\$?([()*+-./])([ABCEHKQRYZ0124567=])/, function (m) {
|
|---|
| 589 | this.emu.ev_setCharset(m[1], m[2]);
|
|---|
| 590 | }],
|
|---|
| 591 |
|
|---|
| 592 | // temporary character set
|
|---|
| 593 | [/^\033N(a|[^a])/, function (m) {
|
|---|
| 594 | this.emu.ev_g2char(m[1]);
|
|---|
| 595 | }],
|
|---|
| 596 | [/^\033O(a|[^a])/, function (m) {
|
|---|
| 597 | this.emu.ev_g3char(m[1]);
|
|---|
| 598 | }],
|
|---|
| 599 |
|
|---|
| 600 | // reports (skipped, we are not emulating an interactive terminal)
|
|---|
| 601 | [/^\033([0-9;?]*)n/, function (m) {
|
|---|
| 602 | /*var me = this;
|
|---|
| 603 | m[1].split(';').forEach(function (r) {
|
|---|
| 604 | me.handleReportRequest(r);
|
|---|
| 605 | });*/
|
|---|
| 606 | }],
|
|---|
| 607 | [/^\033(\[0?c|Z)/, function (m) {
|
|---|
| 608 | //this.emu.ev_report('deviceAttributes');
|
|---|
| 609 | }],
|
|---|
| 610 | [/^\033\[>c/, function (m) {
|
|---|
| 611 | //this.emu.ev_report('versionString');
|
|---|
| 612 | }],
|
|---|
| 613 |
|
|---|
| 614 | // LEDs
|
|---|
| 615 | [/^\033\[([0-9;]*)q/, function (m) {
|
|---|
| 616 | var me = this;
|
|---|
| 617 | (m[1].length ? m[1] : '0').split(';').forEach(function (l) {
|
|---|
| 618 | me.handleLED(l);
|
|---|
| 619 | });
|
|---|
| 620 | }],
|
|---|
| 621 |
|
|---|
| 622 | // printing (we son't have to support that
|
|---|
| 623 | // Print current screen, 1: print current line,
|
|---|
| 624 | // 4: disable log, 5: enable log (echo to printer)
|
|---|
| 625 | [/^\033\[[145]?i/, function (m) {
|
|---|
| 626 | }],
|
|---|
| 627 |
|
|---|
| 628 | //
|
|---|
| 629 | [/^\033\[([0-9;]*)y/, function (m) {
|
|---|
| 630 | this.emu.ev_hardware('selfTestRaw', m[1]);
|
|---|
| 631 | }],
|
|---|
| 632 | [/^\033#8/, function (m) {
|
|---|
| 633 | this.emu.ev_hardware('screenAlignment');
|
|---|
| 634 | }],
|
|---|
| 635 |
|
|---|
| 636 | // xterm: select default character set (ISO8859-1)
|
|---|
| 637 | [/^\033%@/, function (m) {
|
|---|
| 638 | //enable utf8?
|
|---|
| 639 | //this.cb('mode', 'utf8');
|
|---|
| 640 | }],
|
|---|
| 641 | // xterm: select default character set (ISO2022)
|
|---|
| 642 | [/^\033%G/, function (m) {
|
|---|
| 643 | //enable utf8?
|
|---|
| 644 | //this.cb('mode', 'utf8');
|
|---|
| 645 | }],
|
|---|
| 646 |
|
|---|
| 647 | // screensaver control
|
|---|
| 648 | [/^\033\[9;([0-9]+)\]/, function (m) {
|
|---|
| 649 | //this.emu.ev_mode('borderColor', [ m[1], m[2] ]);
|
|---|
| 650 | // \033[9;X] X in minutes (0 off)
|
|---|
| 651 | }],
|
|---|
| 652 |
|
|---|
| 653 | // My extension to control the 'border color'
|
|---|
| 654 | [/^\033\[([0-9]+)(;[0-9]+)?\xb0/, function (m) {
|
|---|
| 655 | this.emu.ev_mode('borderColor', [ m[1], m[2] ? m[2].substr(1) : null ]);
|
|---|
| 656 | }]
|
|---|
| 657 | ];
|
|---|
| 658 |
|
|---|
| 659 | TTVParser.prototype.setMode = function (mode)
|
|---|
| 660 | {
|
|---|
| 661 | switch (mode)
|
|---|
| 662 | {
|
|---|
| 663 | // cursor keys in applications mode
|
|---|
| 664 | case '?1':
|
|---|
| 665 | this.emu.ev_mode('cursorKeyANSI', false);
|
|---|
| 666 | break;
|
|---|
| 667 |
|
|---|
| 668 | case '?3':
|
|---|
| 669 | this.emu.ev_mode('width', 132);
|
|---|
| 670 | break;
|
|---|
| 671 |
|
|---|
| 672 | case '?4':
|
|---|
| 673 | this.emu.ev_mode('scroll', 'smooth');
|
|---|
| 674 | break;
|
|---|
| 675 |
|
|---|
| 676 | case '?5':
|
|---|
| 677 | this.emu.ev_mode('reverseScreen', true);
|
|---|
| 678 | break;
|
|---|
| 679 |
|
|---|
| 680 | case '?6':
|
|---|
| 681 | this.emu.ev_mode('originMode', 'margin');
|
|---|
| 682 | break;
|
|---|
| 683 |
|
|---|
| 684 | case '?7':
|
|---|
| 685 | this.emu.ev_mode('autoWrap', true);
|
|---|
| 686 | break;
|
|---|
| 687 |
|
|---|
| 688 | case '?8':
|
|---|
| 689 | this.emu.ev_mode('autoRepeat', true);
|
|---|
| 690 | break;
|
|---|
| 691 |
|
|---|
| 692 | case '?9':
|
|---|
| 693 | this.emu.ev_mode('mouseTrackingDown', true);
|
|---|
| 694 | break;
|
|---|
| 695 |
|
|---|
| 696 | case '?12':
|
|---|
| 697 | this.emu.ev_mode('cursorBlink', true);
|
|---|
| 698 | break;
|
|---|
| 699 |
|
|---|
| 700 | case '?25':
|
|---|
| 701 | this.emu.ev_mode('cursor', true);
|
|---|
| 702 | break;
|
|---|
| 703 |
|
|---|
| 704 | // xterm
|
|---|
| 705 | // case '?34': // right to left mode
|
|---|
| 706 | // case '?42': // hide/show scroll bar
|
|---|
| 707 | // case '?43': // history on/off
|
|---|
| 708 | // case '?44': // margin bell on/off
|
|---|
| 709 | // case '?45': // reverse wrap around on/off
|
|---|
| 710 | // case '?48': // reverse/normal status line
|
|---|
| 711 | // case '?49': // page/normal scroll mode
|
|---|
| 712 | // case '?E': // erase status line
|
|---|
| 713 | // case '?F': // return from status line
|
|---|
| 714 | // case '?H': // hide status line
|
|---|
| 715 | // case '?S': // show status line
|
|---|
| 716 | // case '?{N}T': // goto column {N} of status line
|
|---|
| 717 |
|
|---|
| 718 |
|
|---|
| 719 | case '?47':
|
|---|
| 720 | this.emu.ev_mode('currentScreen', 0);
|
|---|
| 721 | break;
|
|---|
| 722 |
|
|---|
| 723 | case '?69':
|
|---|
| 724 | // Left right margin mode
|
|---|
| 725 | //this.cb('mode', 'currentScreen', 1);
|
|---|
| 726 | break;
|
|---|
| 727 |
|
|---|
| 728 | case '?1000':
|
|---|
| 729 | this.emu.ev_mode('mouseTrackingUp', true);
|
|---|
| 730 | break;
|
|---|
| 731 |
|
|---|
| 732 | case '?1034':
|
|---|
| 733 | this.emu.ev_mode('metaKey', true);
|
|---|
| 734 | break;
|
|---|
| 735 |
|
|---|
| 736 | case '?1047':
|
|---|
| 737 | this.emu.ev_mode('currentScreen', 0);
|
|---|
| 738 | break;
|
|---|
| 739 |
|
|---|
| 740 | case '?1048':
|
|---|
| 741 | this.emu.ev_cursorStack('push', true);
|
|---|
| 742 | break;
|
|---|
| 743 |
|
|---|
| 744 | case '?1049':
|
|---|
| 745 | this.emu.ev_cursorStack('push', true);
|
|---|
| 746 | this.emu.ev_mode('currentScreen', 0);
|
|---|
| 747 | this.emu.ev_eraseInLine('whole');
|
|---|
| 748 | break;
|
|---|
| 749 |
|
|---|
| 750 | case '2':
|
|---|
| 751 | this.emu.ev_mode('keyboardLocked', true);
|
|---|
| 752 | break;
|
|---|
| 753 |
|
|---|
| 754 | case '4':
|
|---|
| 755 | this.emu.ev_mode('insert', true);
|
|---|
| 756 | break;
|
|---|
| 757 |
|
|---|
| 758 | case '12':
|
|---|
| 759 | this.emu.ev_mode('localEcho', false);
|
|---|
| 760 | break;
|
|---|
| 761 |
|
|---|
| 762 | case '20':
|
|---|
| 763 | this.emu.ev_mode('newLineMode', 'crlf');
|
|---|
| 764 | break;
|
|---|
| 765 |
|
|---|
| 766 | default:
|
|---|
| 767 | this.debug('Unhandled set mode: "' + mode + '"');
|
|---|
| 768 | }
|
|---|
| 769 | };
|
|---|
| 770 |
|
|---|
| 771 | TTVParser.prototype.resetMode = function (mode)
|
|---|
| 772 | {
|
|---|
| 773 | switch (mode)
|
|---|
| 774 | {
|
|---|
| 775 | // cursor keys in cursor positioning mode
|
|---|
| 776 | case '?1':
|
|---|
| 777 | this.emu.ev_mode('cursorKeyANSI', true);
|
|---|
| 778 | break;
|
|---|
| 779 |
|
|---|
| 780 | case '?2':
|
|---|
| 781 | this.emu.ev_mode('vt52', true);
|
|---|
| 782 | break;
|
|---|
| 783 |
|
|---|
| 784 | case '?3':
|
|---|
| 785 | this.emu.ev_mode('width', 80);
|
|---|
| 786 | break;
|
|---|
| 787 |
|
|---|
| 788 | case '?4':
|
|---|
| 789 | this.emu.ev_mode('scroll', 'jump');
|
|---|
| 790 | break;
|
|---|
| 791 |
|
|---|
| 792 | case '?5':
|
|---|
| 793 | this.emu.ev_mode('reverseScreen', false);
|
|---|
| 794 | break;
|
|---|
| 795 |
|
|---|
| 796 | case '?6':
|
|---|
| 797 | this.emu.ev_mode('originMode', 'screen');
|
|---|
| 798 | break;
|
|---|
| 799 |
|
|---|
| 800 | case '?7':
|
|---|
| 801 | this.emu.ev_mode('autoWrap', false);
|
|---|
| 802 | break;
|
|---|
| 803 |
|
|---|
| 804 | case '?8':
|
|---|
| 805 | this.emu.ev_mode('autoRepeat', false);
|
|---|
| 806 | break;
|
|---|
| 807 |
|
|---|
| 808 | case '?9':
|
|---|
| 809 | this.emu.ev_mode('mouseTrackingDown', false);
|
|---|
| 810 | break;
|
|---|
| 811 |
|
|---|
| 812 | case '?12':
|
|---|
| 813 | this.emu.ev_mode('cursorBlink', false);
|
|---|
| 814 | break;
|
|---|
| 815 |
|
|---|
| 816 | case '?25':
|
|---|
| 817 | this.emu.ev_mode('cursor', false);
|
|---|
| 818 | break;
|
|---|
| 819 |
|
|---|
| 820 | case '?47':
|
|---|
| 821 | this.emu.ev_mode('currentScreen', 1);
|
|---|
| 822 | break;
|
|---|
| 823 |
|
|---|
| 824 | case '?69':
|
|---|
| 825 | // Left right amrgin mode
|
|---|
| 826 | //this.cb('mode', 'currentScreen', 1);
|
|---|
| 827 | break;
|
|---|
| 828 |
|
|---|
| 829 | case '?1000':
|
|---|
| 830 | this.emu.ev_mode('mouseTrackingUp', false);
|
|---|
| 831 | break;
|
|---|
| 832 |
|
|---|
| 833 | case '?1034':
|
|---|
| 834 | this.emu.ev_mode('metaKey', false);
|
|---|
| 835 | break;
|
|---|
| 836 |
|
|---|
| 837 | case '?1047':
|
|---|
| 838 | this.emu.ev_eraseInLine('whole');
|
|---|
| 839 | this.emu.ev_mode('currentScreen', 1);
|
|---|
| 840 | break;
|
|---|
| 841 |
|
|---|
| 842 | case '?1048':
|
|---|
| 843 | this.emu.ev_cursorStack('pop', true);
|
|---|
| 844 | break;
|
|---|
| 845 |
|
|---|
| 846 | case '?1049':
|
|---|
| 847 | this.emu.ev_mode('currentScreen', 1);
|
|---|
| 848 | this.emu.ev_cursorStack('pop', true);
|
|---|
| 849 | break;
|
|---|
| 850 |
|
|---|
| 851 | case '2':
|
|---|
| 852 | this.emu.ev_mode('keyboardLocked', false);
|
|---|
| 853 | break;
|
|---|
| 854 |
|
|---|
| 855 | case '4':
|
|---|
| 856 | this.emu.ev_mode('insert', false);
|
|---|
| 857 | break;
|
|---|
| 858 |
|
|---|
| 859 | case '12':
|
|---|
| 860 | this.emu.ev_mode('localEcho', true);
|
|---|
| 861 | break;
|
|---|
| 862 |
|
|---|
| 863 | case '20':
|
|---|
| 864 | this.emu.ev_mode('newLineMode', 'cr');
|
|---|
| 865 | break;
|
|---|
| 866 |
|
|---|
| 867 | default:
|
|---|
| 868 | this.debug('Unhandled reset mode: "' + mode + '"');
|
|---|
| 869 | }
|
|---|
| 870 | };
|
|---|
| 871 |
|
|---|
| 872 | /*
|
|---|
| 873 | TTVParser.prototype.handleReportRequest = function (req)
|
|---|
| 874 | {
|
|---|
| 875 | switch (req)
|
|---|
| 876 | {
|
|---|
| 877 | case '5':
|
|---|
| 878 | this.emu.ev_report('status');
|
|---|
| 879 | break;
|
|---|
| 880 |
|
|---|
| 881 | case '?15':
|
|---|
| 882 | this.emu.ev_report('printer');
|
|---|
| 883 | break;
|
|---|
| 884 |
|
|---|
| 885 | case '6':
|
|---|
| 886 | this.emu.ev_report('cursorPosition');
|
|---|
| 887 | break;
|
|---|
| 888 |
|
|---|
| 889 | default:
|
|---|
| 890 | this.debug('Unhandled report request: "' + req + '"');
|
|---|
| 891 | }
|
|---|
| 892 | };*/
|
|---|
| 893 |
|
|---|
| 894 | TTVParser.prototype.handleLED = function (led)
|
|---|
| 895 | {
|
|---|
| 896 | led = parseInt(led, 10);
|
|---|
| 897 | if ( led == 0 ) {
|
|---|
| 898 | this.emu.ev_led('off', 'all');
|
|---|
| 899 | } else {
|
|---|
| 900 | this.emu.ev_led('on', led);
|
|---|
| 901 | }
|
|---|
| 902 | }
|
|---|