From 3d5d21bcb5e1dc12d6d5806679dff6ad886da7c4 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 5 Jul 2015 19:05:55 -0600 Subject: [PATCH] * Lots of WIP on FSE demo * WIP emit position from MutliLineEditTextView * ansi.rawWrite() when no iconv/lfs to be processed --- README.md | 6 ++ core/ansi_term.js | 5 -- core/art.js | 9 ++- core/client_term.js | 22 ++++- core/color_codes.js | 54 +++++++++++-- core/connect.js | 1 - core/menu_module.js | 1 + core/multi_line_edit_text_view.js | 76 ++++++++++++----- core/text_view.js | 2 +- core/theme.js | 2 +- core/vertical_menu_view.js | 9 +-- core/view.js | 4 +- core/view_controller.js | 4 +- mods/art/demo_edit_text_view1.ans | Bin 781 -> 781 bytes mods/art/demo_fse_netmail_footer_edit.ans | Bin 0 -> 300 bytes mods/fse.js | 94 +++++++++++++++------- mods/menu.json | 14 +++- 17 files changed, 223 insertions(+), 80 deletions(-) create mode 100644 README.md create mode 100644 mods/art/demo_fse_netmail_footer_edit.ans diff --git a/README.md b/README.md new file mode 100644 index 00000000..07d815e4 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ + + +Special Thanks + * M. Brutman, author of mTCP (http://www.brutman.com/mTCP/mTCP.html) + * M. Griffin, author of Enthral BBS (https://github.com/M-griffin/Enthral) + \ No newline at end of file diff --git a/core/ansi_term.js b/core/ansi_term.js index 23c5d5d6..a4409245 100644 --- a/core/ansi_term.js +++ b/core/ansi_term.js @@ -77,11 +77,6 @@ var CONTROL = { // apparently some terms can report screen size and text area via 18t and 19t }; -/* - DECTERM stuff. Probably never need - hide : '?25l', - show : '?25h',*/ - // // Select Graphics Rendition // See http://cvs.synchro.net/cgi-bin/viewcvs.cgi/*checkout*/src/conio/cterm.txt diff --git a/core/art.js b/core/art.js index 59dfef1f..8e7ec768 100644 --- a/core/art.js +++ b/core/art.js @@ -426,6 +426,7 @@ function display(options, cb) { var generatedId = 100; var cprListener = function(pos) { + console.log(pos) if(mciPosQueue.length > 0) { var forMapItem = mciPosQueue.shift(); mciMap[forMapItem].position = pos; @@ -437,6 +438,7 @@ function display(options, cb) { }; function completed() { + console.log('completed') options.client.removeListener('cursor position report', cprListener); parser.removeAllListeners(); // :TODO: Necessary??? @@ -507,7 +509,8 @@ function display(options, cb) { mciPosQueue.push(mapKey); - options.client.term.write(ansi.queryPos(), false); // :TODO: don't convert LF's + console.log('querying pos...') + options.client.term.rawWrite(ansi.queryPos()); } }); @@ -542,12 +545,12 @@ function display(options, cb) { } if(ansiFont.length > 1) { - options.client.term.write(ansiFont); + options.client.term.rawWrite(ansiFont); } if(iceColors) { - options.client.term.write(ansi.blinkToBrightIntensity()); + options.client.term.rawWrite(ansi.blinkToBrightIntensity()); } parser.reset(options.art); diff --git a/core/client_term.js b/core/client_term.js index cbeb3639..2e07ce50 100644 --- a/core/client_term.js +++ b/core/client_term.js @@ -107,10 +107,28 @@ ClientTerminal.prototype.isANSI = function() { return [ 'ansi', 'pc-ansi', 'qansi', 'scoansi' ].indexOf(this.termType) > -1; }; +/* ClientTerminal.prototype.write = function(s, convertLineFeeds) { convertLineFeeds = _.isUndefined(convertLineFeeds) ? this.convertLF : convertLineFeeds; if(convertLineFeeds && _.isString(s)) { s = s.replace(/\n/g, '\r\n'); } - this.output.write(iconv.encode(s, this.outputEncoding)); -}; \ No newline at end of file + this.output.write(this.iconv.encode(s, this.outputEncoding)); +}; +*/ +ClientTerminal.prototype.write = function(s, convertLineFeeds) { + this.output.write(this.encode(s, convertLineFeeds)); +}; + +ClientTerminal.prototype.rawWrite = function(s) { + this.output.write(s); +}; + +ClientTerminal.prototype.encode = function(s, convertLineFeeds) { + convertLineFeeds = _.isUndefined(convertLineFeeds) ? this.convertLF : convertLineFeeds; + if(convertLineFeeds && _.isString(s)) { + s = s.replace(/\n/g, '\r\n'); + } + return iconv.encode(s, this.outputEncoding); +}; + diff --git a/core/color_codes.js b/core/color_codes.js index a3fe5070..129c1a74 100644 --- a/core/color_codes.js +++ b/core/color_codes.js @@ -5,8 +5,8 @@ var ansi = require('./ansi_term.js'); var assert = require('assert'); -exports.pipeToAnsi = exports.renegadeToAnsi = renegadeToAnsi; -exports.stripPipeCodes = exports.stripRenegadeCodes = stripRenegadeCodes; +exports.pipeToAnsi = exports.enigmaToAnsi = enigmaToAnsi; +exports.stripPipeCodes = exports.stripEnigmaCodes = stripEnigmaCodes; // :TODO: Not really happy with the module name of "color_codes". Would like something better @@ -19,7 +19,7 @@ exports.stripPipeCodes = exports.stripRenegadeCodes = stripRenegadeCodes; // * fromWWIV(): <0-7> // * fromSyncronet(): // See http://wiki.synchro.net/custom:colors -function renegadeToAnsi(s) { +function enigmaToAnsi(s) { if(-1 == s.indexOf('|')) { return s; // no pipe codes present } @@ -42,7 +42,7 @@ function renegadeToAnsi(s) { val = 0; } - assert(val >= 0 && val <= 256); // :TODO: should be <= 23 I believe + assert(val >= 0 && val <= 47); var attr = ''; if(7 == val) { @@ -62,7 +62,51 @@ function renegadeToAnsi(s) { return result; } -function stripRenegadeCodes(s) { +// :TODO: NYI +function renegadeToAnsi(s) { +if(-1 == s.indexOf('|')) { + return s; // no pipe codes present + } + + var result = ''; + var re = /\|(\d{2}|\|)/g; + var m; + var lastIndex = 0; + while((m = re.exec(s))) { + var val = m[1]; + + if('|' == val) { + result += '|'; + continue; + } + + // convert to number + val = parseInt(val, 10); + if(isNaN(val)) { + val = 0; + } + + assert(val >= 0 && val <= 23); + + var attr = ''; + if(7 == val) { + attr = ansi.sgr('normal'); + } else if (val < 7 || val >= 16) { + attr = ansi.sgr(['normal', val]); + } else if (val <= 15) { + attr = ansi.sgr(['normal', val - 8, 'bold']); + } + + result += s.substr(lastIndex, m.index - lastIndex) + attr; + lastIndex = re.lastIndex; + } + + result = (0 === result.length ? s : result + s.substr(lastIndex)); + + return result; +} + +function stripEnigmaCodes(s) { return s.replace(/\|[\d]{2}/g, ''); } diff --git a/core/connect.js b/core/connect.js index 0b14bfab..79322df0 100644 --- a/core/connect.js +++ b/core/connect.js @@ -5,7 +5,6 @@ var ansi = require('./ansi_term.js'); var colorCodes = require('./color_codes.js'); var theme = require('./theme.js'); var moduleUtil = require('./module_util.js'); -//var Log = require('./logger.js').log; var Config = require('./config.js').config; diff --git a/core/menu_module.js b/core/menu_module.js index 608ff105..39e84af2 100644 --- a/core/menu_module.js +++ b/core/menu_module.js @@ -117,6 +117,7 @@ function MenuModule(options) { ], function complete(err) { if(err) { + console.log(err) // :TODO: what to do exactly????? } diff --git a/core/multi_line_edit_text_view.js b/core/multi_line_edit_text_view.js index bddb0b13..89f05876 100644 --- a/core/multi_line_edit_text_view.js +++ b/core/multi_line_edit_text_view.js @@ -142,35 +142,37 @@ function MultiLineEditTextView(options) { }; this.redrawRows = function(startRow, endRow) { - self.client.term.write(self.getSGRFor('text') + ansi.hideCursor()); + self.client.term.rawWrite(self.getSGRFor('text') + ansi.hideCursor()); var startIndex = self.getTextLinesIndex(startRow); var endIndex = Math.min(self.getTextLinesIndex(endRow), self.textLines.length); var absPos = self.getAbsolutePosition(startRow, 0); for(var i = startIndex; i < endIndex; ++i) { - self.client.term.write(ansi.goto(absPos.row++, absPos.col)); - self.client.term.write(self.getRenderText(i)); + self.client.term.write( + ansi.goto(absPos.row++, absPos.col) + + self.getRenderText(i), false); } - self.client.term.write(ansi.showCursor()); + self.client.term.rawWrite(ansi.showCursor()); return absPos.row - self.position.row; // row we ended on }; this.eraseRows = function(startRow, endRow) { - self.client.term.write(self.getSGRFor('text') + ansi.hideCursor()); + self.client.term.rawWrite(self.getSGRFor('text') + ansi.hideCursor()); var absPos = self.getAbsolutePosition(startRow, 0); var absPosEnd = self.getAbsolutePosition(endRow, 0); var eraseFiller = new Array(self.dimens.width).join(' '); while(absPos.row < absPosEnd.row) { - self.client.term.write(ansi.goto(absPos.row++, absPos.col)); - self.client.term.write(eraseFiller); + self.client.term.write( + ansi.goto(absPos.row++, absPos.col) + + eraseFiller, false); } - self.client.term.write(ansi.showCursor()); + self.client.term.rawWrite(ansi.showCursor()); }; this.redrawVisibleArea = function() { @@ -409,13 +411,13 @@ function MultiLineEditTextView(options) { console.log('cursorOffset=' + cursorOffset) self.cursorBeginOfNextLine(); self.cursorPos.col += cursorOffset; - self.client.term.write(ansi.right(cursorOffset)); + self.client.term.rawWrite(ansi.right(cursorOffset)); } else { self.cursorPos.row++; self.cursorPos.col = 1; // we just added 1 char absPos = self.getAbsolutePosition(self.cursorPos.row, self.cursorPos.col); console.log('absPos=' + JSON.stringify(absPos)) - self.client.term.write(ansi.goto(absPos.row, absPos.col)); + self.client.term.rawWrite(ansi.goto(absPos.row, absPos.col)); } } else { // @@ -428,7 +430,7 @@ function MultiLineEditTextView(options) { self.getSGRFor('text') + self.getRenderText(index).slice(self.cursorPos.col - c.length) + ansi.goto(absPos.row, absPos.col) + - ansi.showCursor() + ansi.showCursor(), false ); } }; @@ -602,7 +604,7 @@ function MultiLineEditTextView(options) { this.moveClientCusorToCursorPos = function() { var absPos = self.getAbsolutePosition(self.cursorPos.row, self.cursorPos.col); - self.client.term.write(ansi.goto(absPos.row, absPos.col)); + self.client.term.rawWrite(ansi.goto(absPos.row, absPos.col)); }; @@ -633,12 +635,13 @@ function MultiLineEditTextView(options) { }*/ } + self.emitPosition(); }; this.keyPressUp = function() { if(self.cursorPos.row > 0) { self.cursorPos.row--; - self.client.term.write(ansi.up()); + self.client.term.rawWrite(ansi.up()); if(!self.adjustCursorToNextTab('up')) { self.adjustCursorIfPastEndOfLine(false); @@ -647,6 +650,8 @@ function MultiLineEditTextView(options) { self.scrollDocumentDown(); self.adjustCursorIfPastEndOfLine(true); } + + self.emitPosition(); }; this.keyPressDown = function() { @@ -656,7 +661,7 @@ function MultiLineEditTextView(options) { if(self.cursorPos.row < lastVisibleRow) { self.cursorPos.row++; - self.client.term.write(ansi.down()); + self.client.term.rawWrite(ansi.down()); if(!self.adjustCursorToNextTab('down')) { self.adjustCursorIfPastEndOfLine(false); @@ -665,6 +670,8 @@ function MultiLineEditTextView(options) { self.scrollDocumentUp(); self.adjustCursorIfPastEndOfLine(true); } + + self.emitPosition(); }; this.keyPressLeft = function() { @@ -672,7 +679,7 @@ function MultiLineEditTextView(options) { var prevCharIsTab = self.isTab(); self.cursorPos.col--; - self.client.term.write(ansi.left()); + self.client.term.rawWrite(ansi.left()); if(prevCharIsTab) { self.adjustCursorToNextTab('left'); @@ -680,6 +687,8 @@ function MultiLineEditTextView(options) { } else { self.cursorEndOfPreviousLine(); } + + self.emitPosition(); }; this.keyPressRight = function() { @@ -688,7 +697,7 @@ function MultiLineEditTextView(options) { var prevCharIsTab = self.isTab(); self.cursorPos.col++; - self.client.term.write(ansi.right()); + self.client.term.rawWrite(ansi.right()); if(prevCharIsTab) { self.adjustCursorToNextTab('right'); @@ -696,6 +705,8 @@ function MultiLineEditTextView(options) { } else { self.cursorBeginOfNextLine(); } + + self.emitPosition(); }; this.keyPressHome = function() { @@ -707,11 +718,14 @@ function MultiLineEditTextView(options) { } console.log('"' + self.getVisibleText() + '"') self.moveClientCusorToCursorPos(); + + self.emitPosition(); }; this.keyPressEnd = function() { self.cursorPos.col = self.getTextEndOfLineColumn(); self.moveClientCusorToCursorPos(); + self.emitPosition(); }; this.keyPressPageUp = function() { @@ -723,6 +737,8 @@ function MultiLineEditTextView(options) { self.cursorPos.row = 0; self.moveClientCusorToCursorPos(); // :TODO: ajust if eol, etc. } + + self.emitPosition(); }; this.keyPressPageDown = function() { @@ -732,6 +748,8 @@ function MultiLineEditTextView(options) { self.redraw(); self.adjustCursorIfPastEndOfLine(true); } + + self.emitPosition(); }; this.keyPressLineFeed = function() { @@ -757,6 +775,8 @@ function MultiLineEditTextView(options) { // redraw from current row to end of visible area self.redrawRows(self.cursorPos.row, self.dimens.height); self.cursorBeginOfNextLine(); + + self.emitPosition(); }; this.keyPressInsert = function() { @@ -767,6 +787,8 @@ function MultiLineEditTextView(options) { this.keyPressTab = function() { var index = self.getTextLinesIndex(); self.insertCharactersInText(self.expandTab(self.cursorPos.col, '\t') + '\t', index, self.cursorPos.col); + + self.emitPosition(); }; this.keyPressBackspace = function() { @@ -810,6 +832,8 @@ function MultiLineEditTextView(options) { self.keyPressLeft(); // same as hitting left - jump to previous line //self.keyPressBackspace(); } + + self.emitPosition(); }; this.keyPressDelete = function() { @@ -818,6 +842,8 @@ function MultiLineEditTextView(options) { self.cursorPos.col, 'right', 1); + + self.emitPosition(); }; //this.keyPressClearLine = function() { @@ -828,6 +854,8 @@ function MultiLineEditTextView(options) { 0, 'delete line'); } + + self.emitPosition(); }; this.adjustCursorIfPastEndOfLine = function(forceUpdate) { @@ -852,7 +880,7 @@ function MultiLineEditTextView(options) { case 'right' : move = self.getNextTabStop(self.cursorPos.col) - self.cursorPos.col; self.cursorPos.col += move; - self.client.term.write(ansi.right(move)); + self.client.term.rawWrite(ansi.right(move)); break; // @@ -861,7 +889,7 @@ function MultiLineEditTextView(options) { case 'left' : move = self.cursorPos.col - self.getPrevTabStop(self.cursorPos.col); self.cursorPos.col -= move; - self.client.term.write(ansi.left(move)); + self.client.term.rawWrite(ansi.left(move)); break; case 'up' : @@ -876,11 +904,11 @@ function MultiLineEditTextView(options) { if(newCol > self.cursorPos.col) { move = newCol - self.cursorPos.col; self.cursorPos.col += move; - self.client.term.write(ansi.right(move)); + self.client.term.rawWrite(ansi.right(move)); } else if(newCol < self.cursorPos.col) { move = self.cursorPos.col - newCol; self.cursorPos.col -= move; - self.client.term.write(ansi.left(move)); + self.client.term.rawWrite(ansi.left(move)); } break; } @@ -977,6 +1005,12 @@ function MultiLineEditTextView(options) { } }; + this.emitPosition = function() { + self.emit( + 'cursor position', + { row : self.getTextLinesIndex(self.cursorPos.row), col : self.cursorPos.col }); + }; + } require('util').inherits(MultiLineEditTextView, View); @@ -994,7 +1028,7 @@ MultiLineEditTextView.prototype.redraw = function() { }; MultiLineEditTextView.prototype.setFocus = function(focused) { - this.client.term.write(this.getSGRFor('text')); + this.client.term.rawWrite(this.getSGRFor('text')); this.moveClientCusorToCursorPos(); MultiLineEditTextView.super_.prototype.setFocus.call(this, focused); diff --git a/core/text_view.js b/core/text_view.js index aedea9d4..c58ee86f 100644 --- a/core/text_view.js +++ b/core/text_view.js @@ -81,7 +81,7 @@ function TextView(options) { this.justify, this.hasFocus ? this.getFocusSGR() : this.getSGR(), this.getStyleSGR(1) || this.getSGR() - )); + ), false); }; this.getEndOfTextColumn = function() { diff --git a/core/theme.js b/core/theme.js index 021ce471..fba90307 100644 --- a/core/theme.js +++ b/core/theme.js @@ -163,4 +163,4 @@ function displayThemeArt(options, cb) { }); } }); -} \ No newline at end of file +} diff --git a/core/vertical_menu_view.js b/core/vertical_menu_view.js index 836ec048..38c3f246 100644 --- a/core/vertical_menu_view.js +++ b/core/vertical_menu_view.js @@ -54,13 +54,12 @@ function VerticalMenuView(options) { return; } - self.client.term.write(ansi.goto(item.row, self.position.col)); - self.client.term.write(index === self.focusedItemIndex ? self.getFocusSGR() : self.getSGR()); - var text = strUtil.stylizeString(item.text, item.focused ? self.focusTextStyle : self.textStyle); - self.client.term.write( - strUtil.pad(text, this.dimens.width, this.fillChar, this.justify)); + ansi.goto(item.row, self.position.col) + + (index === self.focusedItemIndex ? self.getFocusSGR() : self.getSGR()) + + strUtil.pad(text, this.dimens.width, this.fillChar, this.justify) + ); }; } diff --git a/core/view.js b/core/view.js index 9f433703..25b4f064 100644 --- a/core/view.js +++ b/core/view.js @@ -93,12 +93,12 @@ function View(options) { }; this.hideCusor = function() { - self.client.term.write(ansi.hideCursor()); + self.client.term.rawWrite(ansi.hideCursor()); }; this.restoreCursor = function() { //this.client.term.write(ansi.setCursorStyle(this.cursorStyle)); - this.client.term.write('show' === this.cursor ? ansi.showCursor() : ansi.hideCursor()); + this.client.term.rawWrite('show' === this.cursor ? ansi.showCursor() : ansi.hideCursor()); }; } diff --git a/core/view_controller.js b/core/view_controller.js index 682f2006..91adab1f 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -305,7 +305,7 @@ ViewController.prototype.setViewOrder = function(order) { }; ViewController.prototype.redrawAll = function(initialFocusId) { - this.client.term.write(ansi.hideCursor()); + this.client.term.rawWrite(ansi.hideCursor()); for(var id in this.views) { if(initialFocusId === id) { @@ -314,7 +314,7 @@ ViewController.prototype.redrawAll = function(initialFocusId) { this.views[id].redraw(); } - this.client.term.write(ansi.showCursor()); + this.client.term.rawWrite(ansi.showCursor()); }; ViewController.prototype.loadFromPromptConfig = function(options, cb) { diff --git a/mods/art/demo_edit_text_view1.ans b/mods/art/demo_edit_text_view1.ans index 8053f31521e8a3dc3aae4c3b7e41e7eb736c7f60..12f111e0dcaab3ae1239e34dcee8234676478b12 100644 GIT binary patch delta 22 dcmeBW>t)*@!pLdnEFEoVZETRcS(fnwBLG1~1>yhz delta 22 dcmeBW>t)*@!pLc8ZETP$9c|{kS(fnwBLG2!1>yhz diff --git a/mods/art/demo_fse_netmail_footer_edit.ans b/mods/art/demo_fse_netmail_footer_edit.ans new file mode 100644 index 0000000000000000000000000000000000000000..50d90cbdbec32e3f59c1c979dccadc5b153ff15d GIT binary patch literal 300 zcmb1+Hn29dHZia^Hptc1r6$nk<&usz$W@SzHncW2&5Z^!fVP8rR|5kD>H#AILsJ8D1Jl(E3=E8n0Srt)8VH0v OoqQF-+#Ml2I0*oBF*4== literal 0 HcmV?d00001 diff --git a/mods/fse.js b/mods/fse.js index c9df0b27..cb9de123 100644 --- a/mods/fse.js +++ b/mods/fse.js @@ -3,6 +3,7 @@ var MenuModule = require('../core/menu_module.js').MenuModule; var ViewController = require('../core/view_controller.js').ViewController; +var ansi = require('../core/ansi_term.js'); var async = require('async'); var assert = require('assert'); @@ -25,30 +26,25 @@ function FullScreenEditorModule(options) { this.artNames = [ 'header', 'body', 'footerEdit', 'footerEditMenu', 'footerView' ]; this.editorMode = 'edit'; // :TODO: This needs to be passed in via args + this.getFooterName = function(menu) { + return true === menu ? + 'footerEditMenu' : { + edit : 'footerEdit', + view : 'footerView', + }[self.editorMode]; + }; + this.initSequence = function() { var mciData = { }; var art = self.menuConfig.config.art; assert(_.isObject(art)); - // :TODO: async.series here? - async.waterfall( + async.series( [ function beforeDisplayArt(callback) { self.beforeArt(); callback(null); }, - /* - function displayMainArt(callback) { - if(_.isString(self.menuConfig.art)) { - self.displayArtAsset(self.menuConfig.art, function frameDisplayed(err, artData) { - mciData.main = artData; - callback(err); - }); - } else { - callback(null); // :TODO: should probably throw error... can't do much without this - } - }, - */ function displayArtHeaderAndBody(callback) { assert(_.isString(art.header)); assert(_.isString(art.body)); @@ -62,9 +58,27 @@ function FullScreenEditorModule(options) { callback(err); }); }, - function displayArtFooter(callback) { + function moveToFooterPosition(callback) { + // + // Calculate footer staring position + // + // row = (header height + body height) + // + // Header: mciData.body.height + // Body : We must find this in the config / theme + // + // :TODO: don't hard code this -- allow footer to be themed/etc. + self.client.term.rawWrite(ansi.goto(23, 1)); callback(null); }, + function displayArtFooter(callback) { + var footerName = self.getFooterName(false); + + self.displayArtAsset(art[footerName], function artDisplayed(err, artData) { + mciData[footerName] = artData; + callback(err); + }); + }, function afterArtDisplayed(callback) { self.mciReady(mciData); callback(null); @@ -88,7 +102,7 @@ function FullScreenEditorModule(options) { self.addViewController( 'header', - new ViewController( { client : self.client } ) + new ViewController( { client : self.client, formId : 0 } ) ).loadFromMenuConfig(menuLoadOpts, function headerReady(err) { callback(err); }); @@ -99,10 +113,23 @@ function FullScreenEditorModule(options) { self.addViewController( 'body', - new ViewController( { client : self.client } ) + new ViewController( { client : self.client, formId : 1 } ) ).loadFromMenuConfig(menuLoadOpts, function bodyReady(err) { callback(err); }); + }, + function footer(callback) { + var footerName = self.getFooterName(false); + + menuLoadOpts.formId = 2; + menuLoadOpts.mciMap = mciData[footerName].mciMap; + + self.addViewController( + footerName, + new ViewController( { client : self.client, formId : 2 } ) + ).loadFromMenuConfig(menuLoadOpts, function footerReady(err) { + callback(err); + }); } ], function complete(err) { @@ -112,25 +139,30 @@ function FullScreenEditorModule(options) { ); }; - /* - this.mciReadyHandlerNetMail = function(mciData) { - var mainVc = self.addViewController('main', new ViewController( { client : self.client } )); - - var menuLoadOpts = { - callingMenu : self, - mciMap : mciData.main.mciMap, - formId : 0, - }; - - mainVc.loadFromMenuConfig(menuLoadOpts, function viewsReady(err) { - }); + this.getBodyView = function() { + return self.viewControllers.body.getView(1); }; - */ + + this.updateEditModePosition = function(pos) { + if('edit' === this.editorMode) { + var posView = self.viewControllers[self.getFooterName(false)].getView(1); + if(posView) { + posView.setText(pos.row + ',' + pos.col); + self.getBodyView().setFocus(true); + } + } + }; + this.menuMethods = { headerSubmit : function(formData, extraArgs) { - console.log('submit header:\n' + JSON.stringify(self.viewControllers.header.getFormData())) +// console.log('submit header:\n' + JSON.stringify(self.viewControllers.header.getFormData())) + self.viewControllers.header.removeFocus(); self.viewControllers.body.switchFocus(1); + + self.getBodyView().on('cursor position', function cursorPosUpdate(pos) { + self.updateEditModePosition(pos); + }); }, editorEscPressed : function(formData, extraArgs) { diff --git a/mods/menu.json b/mods/menu.json index 80059697..3cf4b6af 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -514,7 +514,7 @@ "mci" : { "MT1" : { "width" : 79, - "height" : 16, + "height" : 17, "text" : "", // :TODO: should not be req. "submit" : [ "escape" ] } @@ -528,6 +528,18 @@ ] } } + }, + "2" : { + "TL1TL2" : { + "mci" : { + "TL1" : { + "width" : 5 + }, + "TL2" : { + "width" : 4 + } + } + } } } /*