Skip to content

Commit

Permalink
New: term.markupOnly()
Browse files Browse the repository at this point in the history
  • Loading branch information
cronvel committed Aug 13, 2016
1 parent 10066b4 commit 599378a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions .todo.txt/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ mrxvt support: draw-test does not work @bug
(A) document fileInput @doc
(A) document .inputField() options 'minLength', 'default', 'style' and 'cancelable' @doc
(A) document .inputField() option 'keyBindings' @doc
(A) document .markupOnly @doc
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

v0.24.25
--------

New: term.markupOnly()


v0.24.24
--------

Expand Down
10 changes: 8 additions & 2 deletions lib/Terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ Terminal.create = function createTerminal( createOptions )
if ( this.root.esc[ key ].err ) { options.err = true ; options.out = this.root.stderr ; }
if ( this.root.esc[ key ].str ) { options.str = true ; }
if ( this.root.esc[ key ].noFormat ) { options.noFormat = true ; }
if ( this.root.esc[ key ].markupOnly ) { options.markupOnly = true ; }

fn = applyEscape.bind( undefined , options ) ;

Expand Down Expand Up @@ -354,6 +355,7 @@ Terminal.create = function createTerminal( createOptions )
for ( k in term.escOffHandler ) { formatObject.fn[ k + '_off' ] = term.escOffHandler[ k ] ; }

term.format = string.formatMethod.bind( formatObject ) ;
term.markup = string.markupMethod.bind( formatObject ) ;
term.options = options ;

return term ;
Expand Down Expand Up @@ -475,8 +477,11 @@ function applyEscape( options )

on = options.onHasFormatting ? options.root.format.apply( undefined , onFormat ) : options.on ;

//if ( arguments.length > 2 && ! options.noFormat ) // because of markup, we have to do that anyway
if ( ! options.noFormat )
if ( options.markupOnly )
{
action = options.root.markup.apply( undefined , Array.prototype.slice.call( arguments , 1 + options.params ) ) ;
}
else if ( ! options.noFormat )
{
action = options.root.format.apply( undefined , Array.prototype.slice.call( arguments , 1 + options.params ) ) ;
}
Expand Down Expand Up @@ -516,6 +521,7 @@ var pseudoEsc = {
// It just set noFormat:true so it will not call string.format() on user input,
// only useful for ScreenBuffer, so blit-like redraw() can perform slightly faster
noFormat: { noFormat: true } ,
markupOnly: { markupOnly: true } ,

move: {
on: '%[move:%a%a]F' ,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "terminal-kit",
"version": "0.24.24",
"version": "0.24.25",
"description": "256 colors, keys & mouse, input field, screen buffer, interactive 'yes or no', and many more... Whether you just need colors & styles, build a simple interactive command line tool or a complexe terminal app: this is the absolute terminal lib for Node.js!",
"main": "lib/termkit.js",
"directories": {
Expand Down
3 changes: 1 addition & 2 deletions sample/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@


var term = require( '../lib/termkit.js' ).terminal ;
term.options.crlf = true ;
term( 'toto\ntata\ntiti\n' ) ;
term.markupOnly( 'one ^Btwo %I three\n' ) ;
return ;

/*
Expand Down

0 comments on commit 599378a

Please sign in to comment.