Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Ronvel committed Aug 17, 2018
1 parent e91c22a commit 46bc925
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions lib/TextBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function TextBuffer( options = {} ) {
this.tabWidth = options.tabWidth || 4 ;
this.forceInBound = !! options.forceInBound ;
this.wrap = !! options.wrap ;
this.lineWrapping = options.lineWrapping || false ;

this.buffer = [ [] ] ;

Expand Down Expand Up @@ -730,6 +731,25 @@ TextBuffer.prototype.drawCursor = function drawCursor( options ) {



TextBuffer.prototype.lineWrapper = function lineWrapper( width ) {
var output = [] ;

this.buffer.forEach( line => {
if ( line.length <= width ) {
output.push( line ) ;
return ;
}

for ( let offset = 0 ; offset < line.length ; offset += width ) {
output.push( line.slice( offset , offset + width ) ) ;
}
} ) ;

return output ;
} ;



TextBuffer.prototype.blitter = function blitter( p ) {
var tr , iterator , iteratorCallback ;

Expand All @@ -742,8 +762,8 @@ TextBuffer.prototype.blitter = function blitter( p ) {
emptyCellAttr: this.emptyCellAttr ,
writeAttr:
this.ScreenBuffer === termkit.ScreenBuffer ?
function( dst , attr , offset ) { dst.writeInt32BE( attr , offset ) ; } :
function( dst , attr , offset ) { attr.copy( dst , offset ) ; }
( dst , attr , offset ) => { dst.writeInt32BE( attr , offset ) ; } :
( dst , attr , offset ) => { attr.copy( dst , offset ) ; }
} ,
dstRect: termkit.Rect.create( p.dst ) ,
srcRect: termkit.Rect.create( this ) ,
Expand Down

0 comments on commit 46bc925

Please sign in to comment.