Comparing version 1.3.0 to 1.4.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="1.4.0"></a> | ||
# [1.4.0](https://github.com/medikoo/cli-color/compare/v1.3.0...v1.4.0) (2018-10-23) | ||
### Features | ||
* introduce move top, bottom, lineBegin and lineEnd instructions ([ad53db1](https://github.com/medikoo/cli-color/commit/ad53db1)) | ||
<a name="1.3.0"></a> | ||
@@ -7,0 +17,0 @@ |
57
move.js
"use strict"; | ||
var d = require("d") | ||
, trunc = require("es5-ext/math/trunc") | ||
, trunc = require("es5-ext/math/trunc"); | ||
, up, down, right, left | ||
, abs = Math.abs, floor = Math.floor, max = Math.max; | ||
var up, down, right, left, abs = Math.abs, floor = Math.floor, max = Math.max; | ||
@@ -15,23 +14,31 @@ var getMove = function (control) { | ||
}; | ||
module.exports = Object.defineProperties(function (x, y) { | ||
x = isNaN(x) ? 0 : floor(x); | ||
y = isNaN(y) ? 0 : floor(y); | ||
return (x > 0 ? right(x) : left(-x)) + (y > 0 ? down(y) : up(-y)); | ||
}, { | ||
up: d(up = getMove("A")), | ||
down: d(down = getMove("B")), | ||
right: d(right = getMove("C")), | ||
left: d(left = getMove("D")), | ||
to: d(function (x, y) { | ||
x = isNaN(x) ? 1 : max(floor(x), 0) + 1; | ||
y = isNaN(y) ? 1 : max(floor(y), 0) + 1; | ||
return "\x1b[" + y + ";" + x + "H"; | ||
}), | ||
lines: d(function (n) { | ||
var dir; | ||
n = trunc(n) || 0; | ||
dir = n >= 0 ? "E" : "F"; | ||
n = floor(abs(n)); | ||
return "\x1b[" + n + dir; | ||
}) | ||
}); | ||
module.exports = Object.defineProperties( | ||
function (x, y) { | ||
x = isNaN(x) ? 0 : floor(x); | ||
y = isNaN(y) ? 0 : floor(y); | ||
return (x > 0 ? right(x) : left(-x)) + (y > 0 ? down(y) : up(-y)); | ||
}, | ||
{ | ||
up: d((up = getMove("A"))), | ||
down: d((down = getMove("B"))), | ||
right: d((right = getMove("C"))), | ||
left: d((left = getMove("D"))), | ||
to: d(function (x, y) { | ||
x = isNaN(x) ? 1 : max(floor(x), 0) + 1; | ||
y = isNaN(y) ? 1 : max(floor(y), 0) + 1; | ||
return "\x1b[" + y + ";" + x + "H"; | ||
}), | ||
lines: d(function (n) { | ||
var dir; | ||
n = trunc(n) || 0; | ||
dir = n >= 0 ? "E" : "F"; | ||
n = floor(abs(n)); | ||
return "\x1b[" + n + dir; | ||
}), | ||
top: d("\x1b[5000F"), | ||
bottom: d("\x1b[5000B"), | ||
lineBegin: d("\x1b[5000D"), | ||
lineEnd: d("\x1b[5000C") | ||
} | ||
); |
{ | ||
"name": "cli-color", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Colors, formatting and other tools for the console", | ||
@@ -5,0 +5,0 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", |
@@ -578,3 +578,3 @@ [![*nix build status][nix-build-image]][nix-build-url] | ||
Move cursor `n` lines forward if `n` is positive, otherwise `n` lines backward. | ||
Move cursor `n` lines forward if `n` is positive, otherwise `n` lines backward, and place it at line beginning | ||
@@ -585,2 +585,34 @@ ```javascript | ||
##### clc.move.top | ||
Move cursor to top of a screen | ||
```javascript | ||
process.stdout.write(clc.move.top); | ||
``` | ||
##### clc.move.bottom | ||
Move cursor to bottom of a screen | ||
```javascript | ||
process.stdout.write(clc.move.bottom); | ||
``` | ||
##### clc.move.lineBegin | ||
Move cursor to begin of a line | ||
```javascript | ||
process.stdout.write(clc.move.lineBegin); | ||
``` | ||
##### clc.move.lineEnd | ||
Move cursor to end of a line | ||
```javascript | ||
process.stdout.write(clc.move.lineEnd); | ||
``` | ||
#### Terminal characteristics | ||
@@ -587,0 +619,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
94207
1352
739
1