From 1a81532aa7a20a7c44113519e1f9cfecd49f755e Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 10 Sep 2015 22:20:11 -0600 Subject: [PATCH] * Mostly thoughts on starting pipe code support for preview mode of MLTEV --- core/mci_view_factory.js | 1 + core/multi_line_edit_text_view.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/core/mci_view_factory.js b/core/mci_view_factory.js index 5d90a866..6e665ba3 100644 --- a/core/mci_view_factory.js +++ b/core/mci_view_factory.js @@ -108,6 +108,7 @@ MCIViewFactory.prototype.createFromMCI = function(mci) { break; // Pre-defined Label (Text View) + // :TODO: Currently no real point of PL -- @method replaces this pretty much... probably remove case 'PL' : if(mci.args.length > 0) { options.text = getPredefinedMCIValue(this.client, mci.args[0]); diff --git a/core/multi_line_edit_text_view.js b/core/multi_line_edit_text_view.js index 484a476b..f24cf834 100644 --- a/core/multi_line_edit_text_view.js +++ b/core/multi_line_edit_text_view.js @@ -5,6 +5,7 @@ var View = require('./view.js').View; var miscUtil = require('./misc_util.js'); var strUtil = require('./string_util.js'); var ansi = require('./ansi_term.js'); +var colorCodes = require('./color_codes.js'); var assert = require('assert'); var _ = require('lodash'); @@ -486,6 +487,10 @@ function MultiLineEditTextView(options) { return new Array(self.getRemainingTabWidth(col)).join(expandChar); }; + this.getStringLength = function(s) { + return self.isPreviewMode() ? colorCodes.enigmaStrLen(s) : s.length; + }; + this.wordWrapSingleLine = function(s, tabHandling, width) { tabHandling = tabHandling || 'expandTabs'; if(!_.isNumber(width)) { @@ -513,12 +518,17 @@ function MultiLineEditTextView(options) { var results = { wrapped : [ '' ] }; var i = 0; var word; + var wordLen; function addWord() { word.match(new RegExp('.{0,' + width + '}', 'g')).forEach(function wrd(w) { + wordLen = self.getStringLength(w); + if(results.wrapped[i].length + w.length > width) { + //if(results.wrapped[i].length + wordLen > width) { if(0 === i) { results.firstWrapRange = { start : wordStart, end : wordStart + w.length }; + //results.firstWrapRange = { start : wordStart, end : wordStart + wordLen }; } results.wrapped[++i] = w; } else {