fix textareas. 1 cell margin on content for textareas.

This commit is contained in:
Christopher Jeffrey 2013-07-16 01:54:29 -05:00
parent c5d47187cf
commit 28bd6ba3e4
1 changed files with 8 additions and 3 deletions

View File

@ -1498,7 +1498,8 @@ Element.prototype.parseContent = function() {
content = content.replace(/\x1b(?!\[[\d;]*m)/g, '');
content = this._parseTags(content || '');
content = content.replace(/\t/g, ' ');
this._clines = wrapContent(content, width, this.parseTags, this.align);
this._clines = wrapContent(content, width,
this.parseTags, this.align, this.type === 'textarea');
this._clines.width = width;
this._clines.content = this.content;
this._pcontent = this._clines.join('\n');
@ -3030,6 +3031,7 @@ Textarea.prototype.updateCursor = function() {
// Stop a situation where the textarea begins scrolling
// and the last cline appears to always be empty from the
// _typeScroll `+ '\n'` thing.
// Maybe not necessary anymore?
if (last === '' && this.value[this.value.length-1] !== '\n') {
last = this._clines[this._clines.length-2] || '';
}
@ -3136,7 +3138,7 @@ Textarea.prototype._listener = function(ch, key) {
Textarea.prototype._typeScroll = function() {
// XXX Workaround
if (this._clines.length - this.childBase > this.height - (this.border ? 2 : 0) - this.padding * 2) {
this.setContent(this.value + '\n');
//this.setContent(this.value + '\n');
this.scroll(this._clines.length);
}
};
@ -4093,7 +4095,7 @@ function sp(line, width, align) {
// characters, this means wrapContent is doing
// something wrong and determining length including
// at least 1 char from the escape code.
function wrapContent(content, width, tags, state) {
function wrapContent(content, width, tags, state, margin) {
var lines = content.split('\n')
, out = [];
@ -4102,6 +4104,9 @@ function wrapContent(content, width, tags, state) {
return out;
}
// Useful for textareas.
if (margin && width > 1) width--;
lines.forEach(function(line) {
var align = state
, cap;