From aab07bb330172fad4bdbc9dc763e2e519da3265a Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 11 Jul 2015 16:39:42 -0600 Subject: [PATCH] * Fix crash with JuiceSSH * Lots of WIP on FSE * Various notes & fixes --- core/client_term.js | 4 ++ core/mci_view_factory.js | 3 +- core/message.js | 6 ++ core/multi_line_edit_text_view.js | 7 +- core/servers/telnet.js | 4 +- core/view.js | 1 + core/view_controller.js | 28 +------- mods/art/demo_fse_netmail_help.ans | Bin 0 -> 900 bytes mods/fse.js | 108 +++++++++++++++++++++++++++-- mods/menu.json | 14 +++- 10 files changed, 136 insertions(+), 39 deletions(-) create mode 100644 core/message.js create mode 100644 mods/art/demo_fse_netmail_help.ans diff --git a/core/client_term.js b/core/client_term.js index 67259ef2..445b5d35 100644 --- a/core/client_term.js +++ b/core/client_term.js @@ -67,6 +67,7 @@ function ClientTerminal(output) { // XTERM // * PuTTY // LINUX + // * JuiceSSH - also via TERM= // QNX // SCREEN // * ConnectBot @@ -134,6 +135,9 @@ ClientTerminal.prototype.write = function(s, convertLineFeeds) { this.output.write(this.iconv.encode(s, this.outputEncoding)); }; */ + +// :TODO: probably need to update these to convert IAC (0xff) -> IACIAC (escape it) + ClientTerminal.prototype.write = function(s, convertLineFeeds) { this.output.write(this.encode(s, convertLineFeeds)); }; diff --git a/core/mci_view_factory.js b/core/mci_view_factory.js index 3e1c4725..4a3cf3b8 100644 --- a/core/mci_view_factory.js +++ b/core/mci_view_factory.js @@ -10,7 +10,6 @@ var SpinnerMenuView = require('./spinner_menu_view.js').SpinnerMenuView; var ToggleMenuView = require('./toggle_menu_view.js').ToggleMenuView; var MaskEditTextView = require('./mask_edit_text_view.js').MaskEditTextView; var StatusBarView = require('./status_bar_view.js').StatusBarView; - var MultiLineEditTextView = require('./multi_line_edit_text_view.js').MultiLineEditTextView; var Config = require('./config.js').config; @@ -210,7 +209,7 @@ MCIViewFactory.prototype.createFromMCI = function(mci) { default : options.text = this.getPredefinedViewLabel(mci.code); - if(options.text) { + if(_.isString(options.text)) { view = new TextView(options); } break; diff --git a/core/message.js b/core/message.js new file mode 100644 index 00000000..bfd605f1 --- /dev/null +++ b/core/message.js @@ -0,0 +1,6 @@ +/* jslint node: true */ +'use strict'; + +function Message(options) { + +} \ No newline at end of file diff --git a/core/multi_line_edit_text_view.js b/core/multi_line_edit_text_view.js index 92411a90..0e80e7c9 100644 --- a/core/multi_line_edit_text_view.js +++ b/core/multi_line_edit_text_view.js @@ -100,12 +100,13 @@ function MultiLineEditTextView(options) { // * http://www.bbsdocumentary.com/library/PROGRAMS/GRAPHICS/ANSI/bansi.txt // // This seems overkill though, so let's default to 4 :) + // :TODO: what shoudl this really be? Maybe 8 is OK // - this.tabWidth = _.isNumber(options.tabWidth) ? options.tabWidth : 4; + this.tabWidth = _.isNumber(options.tabWidth) ? options.tabWidth : 4; this.textLines = []; this.topVisibleIndex = 0; - this.mode = options.mode || 'edit'; // edit | preview + this.mode = options.mode || 'edit'; // edit | preview | read-only // // cursorPos represents zero-based row, col positions @@ -1052,7 +1053,7 @@ MultiLineEditTextView.prototype.setText = function(text) { //this.textLines = [ { text : '' } ]; //this.insertRawText(''); //text = "Tab:\r\n\tA\tB\tC\tD\tE\tF\tG\r\n reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally long word!!!"; - text = require('fs').readFileSync('/home/bashby/Downloads/test_text.txt', { encoding : 'utf-8'}); + text = require('fs').readFileSync('/home/nuskooler/Downloads/test_text.txt', { encoding : 'utf-8'}); this.insertRawText(text);//, 0, 0); this.cursorEndOfDocument(); diff --git a/core/servers/telnet.js b/core/servers/telnet.js index b7efcb80..79a31ebc 100644 --- a/core/servers/telnet.js +++ b/core/servers/telnet.js @@ -598,7 +598,9 @@ TelnetClient.prototype.handleSbCommand = function(evt) { Log.debug({ termHeight : self.term.termHeight, source : 'NEW-ENVIRON'}, 'Window height updated'); } else { if(name in self.term.env) { - assert(evt.type === SB_COMMANDS.INFO); + assert( + SB_COMMANDS.INFO === evt.type || SB_COMMANDS.IS === evt.type, + 'Unexpected type: ' + evt.type); Log.warn( { varName : name, value : evt.envVars[name], existingValue : self.term.env[name] }, diff --git a/core/view.js b/core/view.js index 1cfa46dd..b7216f9f 100644 --- a/core/view.js +++ b/core/view.js @@ -70,6 +70,7 @@ function View(options) { this.dimens = { width : 0, height : 0 }; } + // :TODO: Just use styleSGRx for these, e.g. styleSGR0, styleSGR1 = norm/focus this.ansiSGR = options.ansiSGR || ansi.getSGRFromGraphicRendition( { fg : 39, bg : 49 }, true); this.ansiFocusSGR = options.ansiFocusSGR || this.ansiSGR; diff --git a/core/view_controller.js b/core/view_controller.js index 054d051f..d7ba71ba 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -32,8 +32,7 @@ function ViewController(options) { this.client = options.client; this.views = {}; // map of ID -> view this.formId = options.formId || 0; - this.mciViewFactory = new MCIViewFactory(this.client); - //this.submitKeyMap = {}; + this.mciViewFactory = new MCIViewFactory(this.client); // :TODO: can this not be a singleton? this.actionKeyMap = {}; @@ -60,15 +59,6 @@ function ViewController(options) { return; } - - /* - var submitViewId = self.submitKeyMap[key.name]; - if(submitViewId) { - self.switchFocus(submitViewId); - self.submitForm(); - return; - } - */ } if(self.focusedView && self.focusedView.acceptsInput) { @@ -83,7 +73,7 @@ function ViewController(options) { self.nextFocus(); break; - case 'accept' : // :TODO: consider naming this 'done' + case 'accept' : if(self.focusedView && self.focusedView.submit) { self.submitForm(); } else { @@ -146,7 +136,7 @@ function ViewController(options) { if(propAsset) { switch(propAsset.type) { case 'config' : - propValue = asset.resolveConfigAsset(config[propName]); + propValue = asset.resolveConfigAsset(conf[propName]); break; // :TODO: handle @art (e.g. text : @art ...) @@ -196,18 +186,6 @@ function ViewController(options) { initialFocusId = viewId; } - /* - if(view.submit) { - submitId = viewId; - - if(_.isArray(mciConf.submit)) { - for(var i = 0; i < mciConf.submit.length; i++) { - self.submitKeyMap[mciConf.submit[i]] = viewId; - } - } - } - */ - nextItem(null); }, function complete(err) { diff --git a/mods/art/demo_fse_netmail_help.ans b/mods/art/demo_fse_netmail_help.ans new file mode 100644 index 0000000000000000000000000000000000000000..f24025f8487f44f90c2ebfc63600e68e43c4efe4 GIT binary patch literal 900 zcmb_aO-sW-5KZY#(2F;7*?Wj?nydkXhnTEYXlgN5kerHLC6Es(5ik8m{z+$clcrs& zpg4!k&di&6Z)Rg=H1KHP`Xw3qy=3M9h* zt67H!&`XJ1gEU$Ki5p3g1gs4)72(r-oP=iPF`VcVE>Z@$elH4=KCgtR2w&z+y~3tu zHu9kkW?)DFz1KY(27wS!{<%W^Caq>6! z60Y@1o5iZpyZt!Vw@Yr>w(}R;kF+O$s^xcGts1~5X*iEKrT9DjlZ~jusP8z#p