tty_string 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +29 -26
- data/lib/tty_string/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9abd5adac382e5520dc2699ff14dd2e213a9fed0d7aa3807e0b054a610ca9c46
|
4
|
+
data.tar.gz: 254d7adb36f29313bc441c237dc760399f9e3e9f4a4447c348a1387282d43b33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2883d488aa1ba89ddc5535ccf6c50d9b5722d3d9e906f5b856bca53a237f6901069f85e9d51a20d2c2fc9d10d9cab2ef14a37fa23665ddf7310c66fcdfde53e
|
7
|
+
data.tar.gz: c048606897448877ba108a78555697f7cbaad9578abd381313be692bb8dc16dd0bd1594c9b33e0fc32646b1529187ef873b60882d8e00d54765337d1507aa7d3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# TTYString
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.
|
3
|
+
[![Build Status](https://travis-ci.com/robotdana/tty_string.svg?branch=master)](https://travis-ci.com/robotdana/tty_string)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/tty_string.svg)](https://rubygems.org/gems/tty_string)
|
4
5
|
|
5
6
|
Render to a string like your terminal does by (narrowly) parsing ANSI TTY codes.
|
7
|
+
Intended for use in tests of command line interfaces.
|
6
8
|
|
7
9
|
## Features
|
8
10
|
|
@@ -11,25 +13,26 @@ Render to a string like your terminal does by (narrowly) parsing ANSI TTY codes.
|
|
11
13
|
|
12
14
|
## Supported codes
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
16
|
+
| Code | Description | Default |
|
17
|
+
|------|-------------|---------|
|
18
|
+
| `\a` | bell: suppressed | |
|
19
|
+
| `\b` | backspace: clear the character to the left of the cursor and move the cursor back one column | |
|
20
|
+
| `\n` | newline: move the cursor to the start of the next line | |
|
21
|
+
| `\r` | return: move the cursor to the start of the current line | |
|
22
|
+
| `\t` | tab: move the cursor to the next multiple-of-8 column | |
|
23
|
+
| `\e[nA` | move the cursor up _n_ lines | _n_=`1` |
|
24
|
+
| `\e[nB` | move the cursor down _n_ lines | _n_=`1` |
|
25
|
+
| `\e[nC` | move the cursor right _n_ columns | _n_=`1` |
|
26
|
+
| `\e[nD` | move the cursor left _n_ columns | _n_=`1` |
|
27
|
+
| `\e[nE` | move the cursor down _n_ lines, and to the start of the line | _n_=`1` |
|
28
|
+
| `\e[nF` | move the cursor up _n_ lines, and to the start of the line | _n_=`1` |
|
29
|
+
| `\e[nG` | move the cursor to column _n_. `1` is left-most column | _n_=`1` |
|
30
|
+
| `\e[n;mH` <br> `\e[n;mf` | move the cursor to row _n_, column _m_. `1;1` is top left corner | _n_=`1` _m_=`1` |
|
31
|
+
| `\e[nJ` | _n_=`0`: clear the screen from the cursor forward <br>_n_=`1`: clear the screen from the cursor backward <br>_n_=`2` or _n_=`3`: clear the screen | _n_=`0` |
|
32
|
+
| `\e[nK` | _n_=`0`: clear the line from the cursor forward <br>_n_=`1`: clear the line from the cursor backward <br>_n_=`2`: clear the line | _n_=`0` |
|
33
|
+
| `\e[nS` | scroll up _n_ rows | _n_=`1` |
|
34
|
+
| `\e[nT` | scroll down _n_ rows | _n_=`1` |
|
35
|
+
| `\e[m` | styling codes: optionally suppressed with `clear_style: false` | |
|
33
36
|
|
34
37
|
## Installation
|
35
38
|
|
@@ -67,17 +70,17 @@ TTYString.parse("th\ta \e[31mstring\e[0m\e[3Gis is", clear_style: false)
|
|
67
70
|
|
68
71
|
Just for fun TTYString.to_proc provides the `parse` method as a lambda, so:
|
69
72
|
```ruby
|
70
|
-
"th\ta string\e[3Gis is".
|
71
|
-
=> "this is a string"
|
73
|
+
["th\ta string\e[3Gis is"].each(&TTYString)
|
74
|
+
=> ["this is a string"]
|
72
75
|
```
|
73
76
|
|
74
77
|
## Limitations
|
75
78
|
|
76
|
-
Various terminals are wildly variously permissive with what they accept,
|
77
|
-
so this doesn't even try to cover all possible cases,
|
78
|
-
instead it covers the narrowest possible case, and leaves the codes in place when unrecognized
|
79
|
+
- Various terminals are wildly variously permissive with what they accept,
|
80
|
+
so this doesn't even try to cover all possible cases,
|
81
|
+
instead it covers the narrowest possible case, and leaves the codes in place when unrecognized
|
79
82
|
|
80
|
-
`clear_style: false` treats the style codes as regular text which may work differently when rendering codes that move the cursor.
|
83
|
+
- `clear_style: false` treats the style codes as regular text which may work differently when rendering codes that move the cursor.
|
81
84
|
|
82
85
|
## Development
|
83
86
|
|
data/lib/tty_string/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty_string
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dana Sherson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|