* More WIP on FSE

* Fix issue with events captured in VC when setFocus() toggle
This commit is contained in:
Bryan Ashby 2015-07-11 20:12:07 -06:00
parent aab07bb330
commit 1bb997133f
5 changed files with 26 additions and 51 deletions

View File

@ -27,7 +27,7 @@ function HorizontalMenuView(options) {
this.getSpacer = function() {
return new Array(self.itemSpacing + 1).join(' ');
}
};
this.performAutoScale = function() {
if(self.autoScale.width) {

View File

@ -406,9 +406,6 @@ function MultiLineEditTextView(options) {
var absPos;
if(self.getTextLength(index) > self.dimens.width) {
//console.log('textLen=' + self.getTextLength(index) + ' / ' + self.dimens.width + ' / ' +
// JSON.stringify(self.getAbsolutePosition(self.cursorPos.row, self.cursorPos.col)))
//
// Update word wrapping and |cursorOffset| if the cursor
// was within the bounds of the wrapped text
@ -423,27 +420,16 @@ function MultiLineEditTextView(options) {
self.redrawRows(self.cursorPos.row, self.dimens.height);
if(!_.isUndefined(cursorOffset)) {
//console.log('cursorOffset=' + cursorOffset)
self.cursorBeginOfNextLine();
self.cursorPos.col += cursorOffset;
self.client.term.rawWrite(ansi.right(cursorOffset));
} else {
//console.log('this path')
self.moveClientCusorToCursorPos();
/*
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.rawWrite(ansi.goto(absPos.row, absPos.col));
*/
}
} else {
//
// We must only redraw from col -> end of current visible line
//
//console.log('textLen=' + self.getTextLength(index))
absPos = self.getAbsolutePosition(self.cursorPos.row, self.cursorPos.col);
self.client.term.write(
ansi.hideCursor() +
@ -518,8 +504,6 @@ function MultiLineEditTextView(options) {
function addWord() {
word.match(new RegExp('.{0,' + width + '}', 'g')).forEach(function wrd(w) {
//console.log(word.match(new RegExp('.{0,' + (width - 1) + '}', 'g')))
//if(results.wrapped[i].length + w.length >= width) {
if(results.wrapped[i].length + w.length > width) {
if(0 === i) {
results.firstWrapRange = { start : wordStart, end : wordStart + w.length };
@ -730,7 +714,6 @@ function MultiLineEditTextView(options) {
} else {
self.cursorPos.col = 0;
}
console.log('"' + self.getVisibleText() + '"')
self.moveClientCusorToCursorPos();
self.emitEditPosition();
@ -1050,16 +1033,10 @@ MultiLineEditTextView.prototype.setFocus = function(focused) {
};
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/nuskooler/Downloads/test_text.txt', { encoding : 'utf-8'});
this.insertRawText(text);//, 0, 0);
this.insertRawText(text);
this.cursorEndOfDocument();
console.log(this.textLines)
};
MultiLineEditTextView.prototype.getData = function() {

View File

@ -210,8 +210,16 @@ ViewController.prototype.attachClientEvents = function() {
return;
}
var self = this;
this.client.on('key press', this.clientKeyPressHandler);
Object.keys(this.views).forEach(function vid(i) {
// remove, then add to ensure we only have one listener
self.views[i].removeListener('action', self.viewActionListener);
self.views[i].on('action', self.viewActionListener);
});
this.attached = true;
};

View File

@ -237,7 +237,7 @@ function FullScreenEditorModule(options) {
}
],
function complete(err) {
var bodyView = self.getBodyView();
var bodyView = self.viewControllers.body.getView(1);
self.updateTextEditMode(bodyView.getTextEditMode());
self.updateEditModePosition(bodyView.getEditPosition());
@ -247,10 +247,6 @@ function FullScreenEditorModule(options) {
);
};
this.getBodyView = function() {
return self.viewControllers.body.getView(1);
};
this.updateEditModePosition = function(pos) {
if('edit' === this.editorMode) {
var posView = self.viewControllers.footerEdit.getView(1);
@ -273,6 +269,7 @@ function FullScreenEditorModule(options) {
}
};
/*
this.displayHelp = function() {
//
// Replace body area with a temporary read-only MultiLineEditText
@ -305,12 +302,13 @@ function FullScreenEditorModule(options) {
self.viewControllers.help.redrawAll();
};
*/
this.displayHelp2 = function() {
this.displayHelp = function() {
self.client.term.rawWrite(ansi.resetScreen());
theme.displayThemeArt( { name : self.menuConfig.config.art.help, client : self.client },
function artDisplayed(err, artData) {
function helpDisplayed(err, artData) {
self.client.waitForKeyPress(function keyPress(ch, key) {
self.redrawScreen();
self.viewControllers.footerEditMenu.setFocus(true);
@ -320,7 +318,7 @@ function FullScreenEditorModule(options) {
};
this.observeEditEvents = function() {
var bodyView = self.getBodyView();
var bodyView = self.viewControllers.body.getView(1);
bodyView.on('edit position', function cursorPosUpdate(pos) {
self.updateEditModePosition(pos);
@ -367,14 +365,17 @@ function FullScreenEditorModule(options) {
}
});
},
editModeMenuSave : function(formData, extraArgs) {
},
editModeMenuHelp : function(formData, extraArgs) {
self.viewControllers.footerEditMenu.setFocus(false);
self.displayHelp();
},
editModeMenu : function(formData, extraArgs) {
console.log('menu ' + formData.value['1'])
if(3 == formData.value['1']) {
console.log('Display help...')
self.viewControllers.footerEditMenu.setFocus(false);
self.displayHelp2();
}
}
};
}

View File

@ -587,7 +587,7 @@
},
{
"value" : { "1" : 1 },
"action" : "@method:editModeMenu"
"action" : "@menu:demoMain"
},
{
"value" : { "1" : 2 },
@ -595,7 +595,7 @@
},
{
"value" : { "1" : 3 },
"action" : "@method:editModeMenu"
"action" : "@method:editModeMenuHelp"
},
{
"value" : 1,
@ -617,17 +617,6 @@
}
*/
}
},
"5" : {
"ML1" : {
"mci" : {
"ML1" : {
"width" : 79,
"height" : 17,
"text" : "" // :TODO: fixme
}
}
}
}
}
/*