Skip to content

Commit

Permalink
feat: introduce move top, bottom, lineBegin and lineEnd instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Oct 23, 2018
1 parent de7ec01 commit ad53db1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,38 @@ Move cursor `n` lines forward if `n` is positive, otherwise `n` lines backward,
process.stdout.write(clc.move.lines(2));
```

##### 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

##### clc.windowSize.width
Expand Down
6 changes: 5 additions & 1 deletion move.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ module.exports = Object.defineProperties(
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")
}
);

0 comments on commit ad53db1

Please sign in to comment.