diff --git a/source/_posts/oztex.md b/source/_posts/oztex.md index 81c7faa..a9470c7 100644 --- a/source/_posts/oztex.md +++ b/source/_posts/oztex.md @@ -23,31 +23,7 @@ It is still being developed, so the current functionality is very limited. You c   -
                                         -    -    -    -    -    A vBBS by ...deon                    -                                         -                                -                            -                          -                       -                    -                  Welcome to  -                   -                  OzTex  -                    -                     -                                  -                                    -                                     -                                         -                                         - Press Connect to begin.                 -                                         -
+
@@ -94,7 +70,8 @@ var telnet; $D('encrypt').checked = true; $D('url').value = '/ws/videotex/516'; - telnet = Telnet('terminal', connected, disconnected); + telnet = Telnet('terminal', connected, disconnected, + '#0:QIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECAis2Evmwp8WE1hdvr_o2bfWjaoECBAgQIECBAgQIECBAgQICP_WS_6ii_4T_l2ujegePUixqgQIECBAgQIECBAgQIECBAgIr1xJeqKLF5NeX68PXDj19cGqBAgQIECBAgQIECBAgQIECBBW05Mu_pl8IECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIEFfLsx79uVYg87-qDRh7ZUGPfu3ZcfTLkQdN6BAgQIECBAgAwQU4HTCSQ_TL4QYUEKFTQdNGHog080GLDzy5EG_cg6aMqBAxcuGCfmgracmXf0y-EHPLy7aceVcgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQRMvDLuyad2dBv3IO-jTj0IMe_ru6cvKDzv6oNmntlQadyBB00ZUFbTky7-mXwg55eXbTjyoO-Hmgx4dmzLkQVtOHpl2IECiDVUrEFDll59MuxAoqy1KxBN07tPTLsQKI1JSsQIECBAgQVMuzTk37kCiHBUrEEnFl5dMvhAop0FKxBl6Y0CBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIEFTegx7927Lj6IOm9B00ZUHPzz6ZdqxBl09NGXkg4csvPmgQQ586dFh1FiDfyQdeeVB539eSDtpy98mHphQdMvLbp3YdiBBj37t2XH0QdN4LDs6ZeWHd0XbMuXdv36-a7dl6OmrFsgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECBAgQIECA:PS=0:RE=0:zx=Tl0'); } diff --git a/themes/hueman/source/js/viewdata/vdata.js b/themes/hueman/source/js/viewdata/vdata.js index 4fe605e..028bd1c 100644 --- a/themes/hueman/source/js/viewdata/vdata.js +++ b/themes/hueman/source/js/viewdata/vdata.js @@ -1,7 +1,7 @@ // VD.js -- a viewdata terminal emulator // constructor -function VD(wd, ht, scr_id) +function VD(wd, ht, scr_id, initscr) { var r; var c; @@ -14,6 +14,7 @@ function VD(wd, ht, scr_id) } this.scr_ = scr; this.cursor_vis_ = true; + this.reveal_ = 0; this.getch_isr_ = undefined; this.grab_events_ = false; this.key_buf_ = []; @@ -21,8 +22,11 @@ function VD(wd, ht, scr_id) this.col_ = 0; this.row_ = 0; // Internal debug setting. - this.clear(); - //this.refresh(); + if (typeof initscr !== "undefined") { + this.write("\x0c" + this.txthash(initscr) + "\x14\x1e"); + } else { + this.write("\x0c\x11\x1e"); + } } VD.A_REVERSE = 2; @@ -33,6 +37,19 @@ VD.browser_opera_ = (navigator.appName.indexOf("Opera") != -1); // class variables VD.the_vt_ = undefined; + +// var blinks = document.getElementsById('blink'); +// var visibility = 'hidden'; + +// window.setInterval(function() { +// for (var i = blinks.length - 1; i >= 0; i--) { +// blinks[i].style.visibility = visibility; +// } +// visibility = (visibility === 'visible') ? 'hidden' : 'visible'; +// }, 250); + + + // object methods VD.prototype.html_colours_ = function(at_fg, at_bg, at_mode) @@ -57,6 +74,52 @@ VD.prototype.html_colours_ = function(at_fg, at_bg, at_mode) } +VD.prototype.txthash = function(hashstring) +{ + var currentcode = 0, stuff = ""; + + if ( hashstring.indexOf(":") > -1 ) + var hashstring = hashstring.split(":")[1]; + + hashstring = hashstring.substring(0, 1120); + + for ( var p = 0; p < hashstring.length; p++ ) { + var pc = hashstring.charAt(p); + var pc_dec = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" + .indexOf(hashstring.charAt(p)); + + // b is the bit in the 6-bit base-64 character. + for ( var b = 0; b < 6; b++ ) { + // The current bit posiiton in the character being + // written to. + var charbit = ( 6*p + b ) % 7; + + // The bit value (set or unset) of the bit we're + // reading from. + var b64bit = pc_dec & ( 1 << ( 5 - b ) ); + if ( b64bit > 0 ) { b64bit = 1; } + + // Update the current code. + currentcode |= b64bit << ( 6 - charbit ); + + // If we've reached the end of this character cell + // and it's the last bit in the character we're + // writing to, set the character code or place the + // code. + if ( charbit == 6 ) { + if (currentcode < 32) { + stuff += '\x1b'; + currentcode += 64; + } + stuff += String.fromCharCode(currentcode); + currentcode = 0; + } + } + } + + return stuff; +} + VD.prototype.clear = function() { this.row_ = this.col_ = 0; @@ -114,8 +177,8 @@ VD.prototype.move = function(r, c) VD.prototype.refresh = function() { - var r, c, stuff = "", start_tag = "", end_tag = "", ch, - pair, cr, cc, ht, wd, cv, n_fg, n_bg, n_mode, n_type, a_fg=-1, a_bg=-1, a_mode=-1; + var r, c, stuff = "", start_tag = "", end_tag = "", ch, chtype, + pair, cr, cc, ht, wd, cv, n_fg, n_bg, n_mode, n_type, a_fg=-1, a_bg=-1, a_mode=-1, n_dblnextline=-2, n_heldchar, n_heldtype; ht = this.ht_; wd = this.wd_; cr = this.row_; @@ -132,6 +195,10 @@ VD.prototype.refresh = function() n_bg = 0; n_mode = 0; n_type = 0; + n_heldchar = 32; + n_heldtype = 0; + if (n_dblnextline+1 < r) + n_dblnextline = -2; for (c = 0; c < wd; ++c) { if (cv && r == cr && c == cc) { // Draw the cursor here. @@ -140,97 +207,155 @@ VD.prototype.refresh = function() n_mode &= ~VD.A_REVERSE; } - ch = this.text_[r][c]; -//console.log('CH: %i (%s) [%i,%i]',ch.charCodeAt(0),ch,r,c); - if (ch.charCodeAt(0) >= 129 && ch.charCodeAt(0) <= 135) { - n_fg = ch.charCodeAt(0)-128; - n_type &= ~2; - n_type &= ~16; + if (r == n_dblnextline+1) { + ch = this.text_[r-1][c].charCodeAt(0); + } else { + ch = this.text_[r][c].charCodeAt(0); } - if (ch.charCodeAt(0) >= 145 && ch.charCodeAt(0) <= 151) { - n_fg = ch.charCodeAt(0)-144; - n_type |= 2; - n_type &= ~16; - } - if (ch == '\x88') - n_mode |= VD.A_BLINK; - if (ch == '\x89') + + ctrlch = ch; + +// set-at + if (ctrlch == 0x89) // steady n_mode &= ~VD.A_BLINK; - if (ch == '\x8c') + if (ctrlch == 0x8c) { // normal + if (n_type & 8) { + n_heldchar = 32; + n_heldtype = 0; + } n_type &= ~8; - if (ch == '\x8d') - n_type |= 8; - if (ch == '\x98') + } + if (ctrlch == 0x98 && this.reveal_ == false) // conceal n_type |= 16; - if (ch == '\x99') + if (ctrlch == 0x99) // contig n_type &= ~1; - if (ch == '\x9a') + if (ctrlch == 0x9a) // sep n_type |= 1; - if (ch == '\x9c') + if (ctrlch == 0x9c) // black n_bg = 0; - if (ch == '\x9d') + if (ctrlch == 0x9d) // newback n_bg = n_fg; - if (ch == '\x9e') + if (ctrlch == 0x9e) // hold n_type |= 32; - if (ch == '\x9f') - n_type &= ~32; +// // If the attributes changed, make a new span. if (n_mode != a_mode || n_fg != a_fg || n_bg != a_bg) { stuff += end_tag; pair = this.html_colours_(n_fg, n_bg, n_mode); - stuff += ''; - // + (n_mode & VD.A_BLINK ? ' class="blink"' : '') + '>'; + stuff += '' end_tag = ""; + if (n_mode & VD.A_BLINK) { + stuff += ''; + end_tag += ""; + } a_fg = n_fg; a_bg = n_bg; a_mode = n_mode; } - if (ch.charCodeAt(0) >= 128) - ch = ' '; + chtype = n_type; + + if (ch >= 128) { + if (n_type & 32) { + ch = n_heldchar; + chtype = n_heldtype; + } else { + ch = 32; + } + } + + if (ch == 127) { + if (n_type & 2) { + ch = 0xe23f+((chtype & 1)*0xc0); + n_heldchar = 127; + } else { + ch = 0xb6; + } + } if (n_type & 2) { - if ( ch.charCodeAt(0) >= 0x20 && ch.charCodeAt(0) <= 0x3f) { - ch = '&#x' + (ch.charCodeAt(0)+0xe1e0+((n_type & 1)*0xc0)).toString(16) +";"; - } else if ( ch.charCodeAt(0) >= 0x60 && ch.charCodeAt(0) <= 0x7f) { - ch = '&#x' + (ch.charCodeAt(0)+0xe1c0+((n_type & 1)*0xc0)).toString(16) +";"; + if ( ch >= 0x20 && ch <= 0x3f) { + n_heldchar = ch; + ch = ch+0xe1e0+((chtype & 1)*0xc0); + } else if ( ch >= 0x60 && ch <= 0x7e) { + n_heldchar = ch; + ch = ch+0xe1c0+((chtype & 1)*0xc0); } } + if (n_type & 16) + ch = 32; + + n_heldtype = chtype; + switch (ch) { - case '&': - stuff += '&'; break; - case '<': - stuff += '<'; break; - case '>': - stuff += '>'; break; - case ' ': - // stuff += ' '; break; - stuff += '\xa0'; break; - case '\x7e': - case '~': - stuff += '\xf7'; break; - case '\x7f': - stuff += ""; break - case '_': - stuff += '#'; break - case '{': - stuff += '\xbc'; break - case '\\': - stuff += '\xbd'; break - case '}': - stuff += '\xbe'; break - case '#': - stuff += '\xa3'; break - default: - stuff += ch; + case 32: + ch = 0xa0; break; + case 0x7e: + ch = 0xf7; break; + case 0x5f: // _ + ch = 0x23; break // # + case 123: // { + ch = 0xbc; break + case 92: // \ + ch = 0xbd; break + case 125: // } + ch = 0xbe; break + case 0x23: // # + ch = 0xa3; break } + + if (n_type & 8) { + if (ch < 0x100) { + ch = ch+0xe000+((r==n_dblnextline+1)*0x100); + } else { + ch = ch+0x40+((r==n_dblnextline+1)*0x40) + } + } else if (r==n_dblnextline+1) { + ch = 0xa0; + } + + stuff += "&#x" + ch.toString(16) + ";" + +// set-after + if (ctrlch >= 129 && ctrlch <= 135) { + if (n_type & 2) { + n_heldchar=32; + n_heldtype=0; + } + n_fg = ctrlch-128; + n_type &= ~2; + n_type &= ~16; + } + if (ctrlch >= 145 && ctrlch <= 151) { + if (n_type & 2 == 0) { + n_heldchar=32; + n_heldtype=0; + } + n_fg = ctrlch-144; + n_type |= 2; + n_type &= ~16; + } + if (ctrlch == 0x88) // flash + n_mode |= VD.A_BLINK; + if (ctrlch == 0x8d) { // double + if (n_type & 8 == 0) { + n_heldchar = 32; + n_heldtype = 0; + } + n_type |= 8; + if (n_dblnextline < 0) + n_dblnextline = r; + } + if (ctrlch == 0x9f) // release + n_type &= ~32; +// + } } stuff += end_tag - //this.scr_.innerHTML = "" + stuff + "\n"; - this.scr_.innerHTML = stuff + "\n"; + this.scr_.innerHTML = "" + stuff + "\n"; } @@ -284,6 +409,7 @@ VD.prototype.write = function(stuff) case 12: this.clear(); this.move(0, 0); + this.reveal_ = false; break; case 13: this.col_ = 0; diff --git a/themes/hueman/source/js/viewdata/wsvdata.js b/themes/hueman/source/js/viewdata/wsvdata.js index c279dd1..0aff2f5 100644 --- a/themes/hueman/source/js/viewdata/wsvdata.js +++ b/themes/hueman/source/js/viewdata/wsvdata.js @@ -1,4 +1,4 @@ -function Telnet(target, connect_callback, disconnect_callback) { +function Telnet(target, connect_callback, disconnect_callback, initscr) { var that = {}, // Public API interface vd, ws, sQ = []; @@ -45,14 +45,14 @@ that.connect = function(host, port, encrypt, url) { uri = scheme + host + ":" + port + url; ws.open(uri); + + vd.write("\x1e\x11Connecting ..."); } that.disconnect = function() { if (ws) { ws.close(); } - vd.curs_set(true, false); - disconnect_callback(); } @@ -75,7 +75,7 @@ function constructor() { /* Initialize the terminal emulator/renderer */ - vd = new VD(40, 24, target); + vd = new VD(40, 24, target, initscr); /* * Override VD I/O routines @@ -174,6 +174,10 @@ function constructor() { str = '\x09'; break; case 65364: // Down arrow str = '\x0a'; break; + case 0xffc0: // f3 + vd.reveal_ ^= 1; vd.refresh(); break; + case 0xffc4: // f7 + str = '\x1b'; break } }