From b75997574295212f066886d6e6dbf36d11a3a5f5 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Mon, 8 Jun 2015 22:41:57 -0600 Subject: [PATCH] * Some minor tweaks. Nothing major right now --- core/multi_line_edit_text_view2.js | 30 ++++++++++++++++++------------ core/theme.js | 3 +++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/core/multi_line_edit_text_view2.js b/core/multi_line_edit_text_view2.js index 60d5ab85..1913cc37 100644 --- a/core/multi_line_edit_text_view2.js +++ b/core/multi_line_edit_text_view2.js @@ -180,7 +180,7 @@ function MultiLineEditTextView2(options) { return text; }; - this.getOutputText = function(startIndex, endIndex) { + this.getOutputText = function(startIndex, endIndex, includeEol) { var lines; if(startIndex === endIndex) { lines = [ self.textLines[startIndex] ]; @@ -196,7 +196,7 @@ function MultiLineEditTextView2(options) { var re = new RegExp('\\t{' + (self.tabWidth - 1) + '}', 'g'); for(var i = 0; i < lines.length; ++i) { text += lines[i].text.replace(re, '\t'); - if(lines[i].eol) { + if(includeEol && lines[i].eol) { text += '\n'; } } @@ -380,7 +380,7 @@ function MultiLineEditTextView2(options) { self.cursorPos.col++; var text = self.getText(index); - var cursorOffset = 0; + var cursorOffset; if(self.getText(index).length >= self.dimens.width) { // @@ -391,11 +391,10 @@ function MultiLineEditTextView2(options) { for(var i = text.length; 0 !== i; i--) { if(/\s/.test(text[i])) { i++; // advance to actual character, if any - console.log(i); if(self.cursorPos.col >= i && self.cursorPos.col <= text.length) { i = self.cursorPos.col - i; - cursorOffset = i - 1; - console.log(i) + cursorOffset = i; + console.log('cursorOffset=' + i) } break; @@ -410,7 +409,7 @@ function MultiLineEditTextView2(options) { var nextEolIndex = self.getNextEndOfLineIndex(index); var newLines = self.wordWrapSingleLine(self.getOutputText(index, nextEolIndex)); - console.log(self.getOutputText(index, nextEolIndex)) + console.log('"' + self.getOutputText(index, nextEolIndex) + '"') for(var i = 0; i < newLines.length; ++i) { newLines[i] = { text : newLines[i] }; @@ -429,14 +428,21 @@ function MultiLineEditTextView2(options) { self.textLines, [ index, (nextEolIndex - index) + 1 ].concat(newLines)); - //console.log('----') - //console.log(self.textLines) + console.log('----') + console.log(self.textLines) var absPos = self.getAbsolutePosition(self.cursorPos.row, self.cursorPos.col); // redraw from current row to end of visible area self.redrawRows(self.cursorPos.row, self.dimens.height); - self.client.term.write(ansi.goto(absPos.row, absPos.col)); + + if(!_.isUndefined(cursorOffset)) { + self.cursorBeginOfNextLine(); + self.cursorPos.col += cursorOffset; + self.client.term.write(ansi.right(cursorOffset)); + } else { + self.client.term.write(ansi.goto(absPos.row, absPos.col)); + } } else { //console.log('redraw col+\n' + self.getRenderText(index).slice(self.cursorPos.col - 1) ) // @@ -519,7 +525,7 @@ function MultiLineEditTextView2(options) { } else { self.cursorPos.col = 0; } - console.log(self.getVisibleText()) + console.log('"' + self.getVisibleText() + '"') self.moveClientCusorToCursorPos(); }; @@ -673,7 +679,7 @@ MultiLineEditTextView2.prototype.setFocus = function(focused) { MultiLineEditTextView2.prototype.setText = function(text) { this.textLines = [ ]; //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.insertText(text);//, 0, 0); this.cursorEndOfDocument(); diff --git a/core/theme.js b/core/theme.js index 1db4719c..bf3322a8 100644 --- a/core/theme.js +++ b/core/theme.js @@ -117,6 +117,9 @@ function getThemeArt(name, themeID, options, cb) { } // set/override some options + + // :TODO: replace asAnsi stuff with something like retrieveAs = 'ansi' | 'pipe' | ... + // :TODO: Some of these options should only be set if not provided! options.asAnsi = true; options.readSauce = true; // encoding/fonts/etc. options.random = miscUtil.valueWithDefault(options.random, true);