mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-01-09 18:45:51 +00:00
refactor, options, comments. flags.
This commit is contained in:
parent
587443f9e3
commit
6c6b4f8f66
@ -1,6 +1,9 @@
|
|||||||
var Tput = require('../lib/tput');
|
var Tput = require('../').Tput;
|
||||||
|
|
||||||
var tput = new Tput(process.argv[2] || 'xterm', true);
|
var tput = Tput({
|
||||||
|
term: process.argv[2] || 'xterm',
|
||||||
|
debug: true
|
||||||
|
});
|
||||||
|
|
||||||
//tput.colors();
|
//tput.colors();
|
||||||
|
|
||||||
|
31
lib/tput.js
31
lib/tput.js
@ -22,15 +22,21 @@ var assert = require('assert')
|
|||||||
* Tput
|
* Tput
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function Tput(term, debug) {
|
function Tput(options) {
|
||||||
if (!(this instanceof Tput)) {
|
if (!(this instanceof Tput)) {
|
||||||
return new Tput(term);
|
return new Tput(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.term = term;
|
if (typeof options === 'string') {
|
||||||
|
options = { term: options };
|
||||||
|
}
|
||||||
|
|
||||||
|
this.options = options;
|
||||||
|
this.term = options.term;
|
||||||
this.data = null;
|
this.data = null;
|
||||||
this.info = {};
|
this.info = {};
|
||||||
this.debug = debug;
|
this.debug = options.debug;
|
||||||
|
this.padding = options.padding;
|
||||||
|
|
||||||
this.readTerminfo();
|
this.readTerminfo();
|
||||||
this.compile();
|
this.compile();
|
||||||
@ -514,7 +520,18 @@ Tput.prototype._compile = function(val) {
|
|||||||
// as in printf, flags are [-+#] and space. Use a `:' to allow the
|
// as in printf, flags are [-+#] and space. Use a `:' to allow the
|
||||||
// next character to be a `-' flag, avoiding interpreting "%-" as an
|
// next character to be a `-' flag, avoiding interpreting "%-" as an
|
||||||
// operator.
|
// operator.
|
||||||
if (read(/^%(:-|[+# ])(?:(\d+)(\.\d+)?)?([doxXs])?/)) {
|
// NOTE: Possibly remove one of the {0,1}'s.
|
||||||
|
// Otherwise %+ and other ops could be mistaken for this.
|
||||||
|
// Guessing it looks like:
|
||||||
|
// %:-d
|
||||||
|
// %+d
|
||||||
|
// %#x
|
||||||
|
// %+10d
|
||||||
|
// Probably should be: /^%(:-|[+# ])?(\d+(?:\.\d+)?)?([doxXs])/
|
||||||
|
if (read(/^%(:-|[+# ])(\d+(?:\.\d+)?)?([doxXs])?/)) {
|
||||||
|
// var op = cap[1]
|
||||||
|
// , width = cap[2]
|
||||||
|
// , flag = cap[3];
|
||||||
print('');
|
print('');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -525,8 +542,8 @@ Tput.prototype._compile = function(val) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// %d print pop() like %d in printf
|
// %d print pop()
|
||||||
// NOT SURE ABOUT %d being print!
|
// "Print (e.g., "%d") is a special case."
|
||||||
if (read(/^%d/)) {
|
if (read(/^%d/)) {
|
||||||
echo('stack.pop()');
|
echo('stack.pop()');
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user