diff --git a/core/ansi_term.js b/core/ansi_term.js index e8472761..58bb7c26 100644 --- a/core/ansi_term.js +++ b/core/ansi_term.js @@ -267,96 +267,6 @@ function setCursorStyle(cursorStyle) { } - -/* -var FONT_MAP = { - // Codepage 437 English - 'cp437' : 0, - 'ibmpc' : 0, - 'ibm_pc' : 0, - 'ibm_vga' : 0, - 'pc' : 0, - 'cp437_art' : 0, - 'ibmpcart' : 0, - 'ibmpc_art' : 0, - 'ibm_pc_art' : 0, - 'msdos_art' : 0, - 'msdosart' : 0, - 'pc_art' : 0, - 'pcart' : 0, - - // Codepage 1251 Cyrillic, (swiss) - 'cp1251-swiss' : 1, - - // Russian koi8-r - 'koi8_r' : 2, - 'koi8-r' : 2, - 'koi8r' : 2, - - // ISO-8859-2 Central European - 'iso8859_2' : 3, - 'iso8859-2' : 3, - - // ISO-8859-4 Baltic wide (VGA 9bit mapped) - 'iso8859_4-baltic9b' : 4, - - // Codepage 866 (c) Russian - 'cp866-c' : 5, - - 'iso8859_9' : 6, - 'haik8' : 7, - 'iso8859_8' : 8, - 'koi8_u' : 9, - 'iso8859_15-thin' : 10, - 'iso8859_4' : 11, - 'koi8_r_b' : 12, - 'iso8859_4-baltic-wide' : 13, - 'iso8859_5' : 14, - 'ARMSCII_8' : 15, - 'iso8859_15' : 16, - 'cp850' : 17, - 'cp850-thin' : 18, - 'cp885-thin' : 19, - 'cp1251' : 20, - 'iso8859_7' : 21, - 'koi8-r_c' : 22, - 'iso8859_4-baltic' : 23, - 'iso8859_1' : 24, - 'cp866' : 25, - 'cp437-thin' : 26, - 'cp866-b' : 27, - 'cp885' : 28, - 'cp866_u' : 29, - 'iso8859_1-thin' : 30, - 'cp1131' : 31, - 'c64_upper' : 32, - 'c64_lower' : 33, - 'c128_upper' : 34, - 'c128_lower' : 35, - - 'atari' : 36, - 'atarist' : 36, - - 'pot_noodle' : 37, - 'p0tnoodle' : 37, - - 'mo_soul' : 38, - 'mosoul' : 38, - 'mO\'sOul' : 38, - - 'microknight_plus' : 39, - - 'topaz_plus' : 40, - 'topazplus' : 40, - 'amiga_topaz_2+' : 40, - 'topaz2plus' : 40, - - 'microknight' : 41, - 'topaz' : 42, - -}; -*/ - // Create methods such as up(), nextLine(),... Object.keys(CONTROL).forEach(function onControlName(name) { var code = CONTROL[name]; @@ -422,7 +332,7 @@ function clearScreen() { } function resetScreen() { - return exports.goHome() + exports.reset() + exports.eraseData(2); + return exports.reset() + exports.eraseData(2) + exports.goHome(); } function normal() { @@ -440,26 +350,6 @@ function disableVT100LineWrapping() { return ESC_CSI + '7l'; } -// -// See http://cvs.synchro.net/cgi-bin/viewcvs.cgi/*checkout*/src/conio/cterm.txt -// -/* -function setFont(name, fontPage) { - name = name.toLowerCase().replace(/ /g, '_'); // conform to map - - var p1 = miscUtil.valueWithDefault(fontPage, 0); - - assert(p1 >= 0 && p1 <= 3); - - var p2 = FONT_MAP[name]; - if(_.isNumber(p2)) { - return ESC_CSI + p1 + ';' + p2 + ' D'; - } - - return ''; -} -*/ - // Also add: // * fromRenegade(): |<0-23> // * fromCelerity(): | diff --git a/core/client.js b/core/client.js index 390d417e..bbe768d6 100644 --- a/core/client.js +++ b/core/client.js @@ -100,8 +100,6 @@ function Client(input, output) { var c; var name; - console.log(data) - if(1 === len) { c = data[0]; diff --git a/core/text_view.js b/core/text_view.js index b7818455..10628537 100644 --- a/core/text_view.js +++ b/core/text_view.js @@ -42,7 +42,6 @@ function TextView(options) { // |ABCDEFG| ^_ this.text.length // ^-- this.dimens.width // - console.log(this.position.x) var textToDraw = _.isString(this.textMaskChar) ? new Array(s.length + 1).join(this.textMaskChar) : strUtil.stylizeString(s, this.hasFocus ? this.focusTextStyle : this.textStyle); diff --git a/core/view_controller.js b/core/view_controller.js index 9a1d7385..92c7e6d4 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -7,6 +7,7 @@ var menuUtil = require('./menu_util.js'); var Log = require('./logger.js').log; var Config = require('./config.js').config; var asset = require('./asset.js'); +var ansi = require('./ansi_term.js'); var events = require('events'); var util = require('util'); @@ -160,65 +161,55 @@ function ViewController(options) { }); }; + // :TODO: move this elsewhere this.setViewPropertiesFromMCIConf = function(view, conf) { - function getViewProp(propName) { + function setViewProp(propName, setter) { if(conf[propName]) { - return asset.resolveConfigAsset(conf[propName]); + var propValue = asset.resolveConfigAsset(conf[propName]); + if(propValue) { + if(setter) { + setter(propValue); + } else { + view[propName] = propValue; + } + } } } - function setSimpleViewProp(propName) { - var propValue = getViewProp(propName); - if(propValue) { - view[propName] = propValue; + setViewProp('items', function(v) { view.setItems(v); }); + setViewProp('text', function(v) { view.setText(v); }); + setViewProp('textStyle'); + setViewProp('focusTextStyle'); + setViewProp('maxLength'); + setViewProp('width', function(v) { view.dimens.width = parseInt(v, 10); }); + + setViewProp('fillChar', function(v) { + if(_.isNumber(v)) { + view.fillChar = String.fromCharCode(v); + } else if(_.isString(v)) { + view.fillChar = v.substr(0, 1); } - } + }); - var value; + setViewProp('password', function(v) { + if(true === v) { + view.textMaskChar = self.client.currentThemeInfo.getPasswordChar(); + } + }); - value = getViewProp('items'); - if(value) { - view.setItems(value); - } + setViewProp('textMaskChar', function(v) { view.textMaskChar = v.substr(0, 1); }); + setViewProp('hotKeys', function(v) { view.setHotKeys(v); }); - value = getViewProp('text'); - if(value) { - view.setText(value); - } + setViewProp('submit', function(v) { + if(_.isBoolean(v)) { + view.submit = v; + } else { + view.submit = _.isArray(v) && v.length > 0; + } + }); - setSimpleViewProp('textStyle'); - setSimpleViewProp('focusTextStyle'); - setSimpleViewProp('fillChar'); - setSimpleViewProp('maxLength'); - - value = getViewProp('textMaskChar'); - if(_.isString(value)) { - view.textMaskChar = value.substr(0, 1); - } else if(value && true === value) { - // - // Option that should normally be used in order to - // get the password character from Config/theme - // - view.textMaskChar = self.client.currentThemeInfo.getPasswordChar(); - } - - value = getViewProp('hotkeys'); - if(_.isObject(value)) { - view.setHotKeys(value); - } - - - value = getViewProp('submit'); - if(_.isBoolean(value)) { - view.submit = value; - } else { - view.submit = _.isArray(value) && value.length > 0; - } - - if(_.isString(conf.argName)) { - view.submitArgName = conf.argName; - } + setViewProp('argName', function(v) { view.submitArgName = v; }); }; this.applyViewConfig = function(config, cb) { @@ -372,24 +363,6 @@ ViewController.prototype.setViewOrder = function(order) { } }; -/* -ViewController.prototype.loadFromMCIMap = function(mciMap) { - var factory = new MCIViewFactory(this.client); - var self = this; - - Object.keys(mciMap).forEach(function onMciEntry(name) { - var mci = mciMap[name]; - var view = factory.createFromMCI(mci); - - if(view) { - view.on('action', self.viewActionListener); - self.addView(view); - view.redraw(); // :TODO: This can result in double redraw() if we set focus on this item after - } - }); -}; -*/ - ViewController.prototype.loadFromPromptConfig = function(options, cb) { assert(_.isObject(options)); assert(_.isObject(options.mciMap)); @@ -422,6 +395,8 @@ ViewController.prototype.loadFromPromptConfig = function(options, cb) { callback(null); }, function drawAllViews(callback) { + self.client.term.write(ansi.hideCursor()); + for(var id in self.views) { if(initialFocusId === id) { continue; // will draw @ focus @@ -557,6 +532,8 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) { callback(null); }, function drawAllViews(callback) { + self.client.term.write(ansi.hideCursor()); + for(var id in self.views) { if(initialFocusId === id) { continue; // will draw @ focus diff --git a/mods/art/demo_edit_text_view1.ans b/mods/art/demo_edit_text_view1.ans index 6307d29e..8d380b90 100644 Binary files a/mods/art/demo_edit_text_view1.ans and b/mods/art/demo_edit_text_view1.ans differ diff --git a/mods/menu.json b/mods/menu.json index 83969d24..5a221dff 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -204,19 +204,29 @@ "options" : { "cls" : true }, "form" : { "0" : { - "BT4ET1ET2ET3" : { + "BT5ET1ET2ET3ET4" : { "mci" : { "ET1" : { + "width" : 20, "maxLength" : 20 }, "ET2" : { - "maxLength" : 20 + "width" : 20, + "maxLength" : 40 }, "ET3" : { - "fillChar" : " ", + "width" : 20, + "fillChar" : "-", + // :TODO: fillColor "maxLength" : 20 }, - "BT4" : { + "ET4" : { + "width" : 20, + "maxLength" : 20, + "password" : true + }, + "BT5" : { + "width" : 8, "text" : "Back", "submit" : true } @@ -234,6 +244,16 @@ } } /* + :TODO: conceptual simplified menus -- actions/etc. without forms + "thing" : { + "mci" : { + "ET1" : { + "action" : "@menu:stuff" + } + } + } + */ + /* "demoEditTextView" : { "art" : "demo_edit_text_view.ans", "options" : { "cls" : true },