tty-cursor 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +0 -2
- data/lib/tty/cursor.rb +5 -4
- data/lib/tty/version.rb +1 -1
- data/spec/unit/cursor_spec.rb +16 -0
- data/tty-cursor.gemspec +2 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ced9bfc434424bc7c450d55a5722d629bfccb300
|
4
|
+
data.tar.gz: 8e74ddf9066f4e707fe6540b0de72edd6ffa7ffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9b25ab21870b143583d27ec9894e26215beb58ddbe515a54bc0b601c493fa532ab318a863a8f61ea77c5d8f6cb6b5ccefbfa4e6b08f4a1bc0a09bda7b52bac6
|
7
|
+
data.tar.gz: 2ede7d2c394cfdb8f76116688baf2879e54ab691013b805c0464b2f0ae7b8eb39a6dc444d092aea5ea984013155f24658e0fc587db28a3f621a044e0f6549c2f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.5.0] - 2017-08-01
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
* Change #save & #restore to work on major systems by Austin Blatt[@austb]
|
7
|
+
|
3
8
|
## [v0.4.0] - 2017-01-08
|
4
9
|
|
5
10
|
### Added
|
@@ -32,6 +37,7 @@
|
|
32
37
|
|
33
38
|
* Initial implementation and release
|
34
39
|
|
40
|
+
[v0.5.0]: https://github.com/peter-murach/tty-cursor/compare/v0.4.0...v0.5.0
|
35
41
|
[v0.4.0]: https://github.com/peter-murach/tty-cursor/compare/v0.3.0...v0.4.0
|
36
42
|
[v0.3.0]: https://github.com/peter-murach/tty-cursor/compare/v0.2.0...v0.3.0
|
37
43
|
[v0.2.0]: https://github.com/peter-murach/tty-cursor/compare/v0.1.0...v0.2.0
|
data/Gemfile
CHANGED
data/lib/tty/cursor.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module TTY
|
4
5
|
# Terminal cursor movement ANSI codes
|
@@ -35,13 +36,13 @@ module TTY
|
|
35
36
|
# Save current position
|
36
37
|
# @api public
|
37
38
|
def save
|
38
|
-
CSI + 's'
|
39
|
+
Gem.win_platform? ? CSI + 's' : ESC + '7'
|
39
40
|
end
|
40
41
|
|
41
42
|
# Restore cursor position
|
42
43
|
# @api public
|
43
44
|
def restore
|
44
|
-
CSI + 'u'
|
45
|
+
Gem.win_platform? ? CSI + 'u' : ESC + '8'
|
45
46
|
end
|
46
47
|
|
47
48
|
# Query cursor current position
|
@@ -165,10 +166,10 @@ module TTY
|
|
165
166
|
#
|
166
167
|
# @api public
|
167
168
|
def clear_lines(n, direction = :up)
|
168
|
-
n.times.reduce(
|
169
|
+
n.times.reduce([]) do |acc, i|
|
169
170
|
dir = direction == :up ? up : down
|
170
171
|
acc << clear_line + ((i == n - 1) ? '' : dir)
|
171
|
-
end
|
172
|
+
end.join
|
172
173
|
end
|
173
174
|
alias clear_rows clear_lines
|
174
175
|
|
data/lib/tty/version.rb
CHANGED
data/spec/unit/cursor_spec.rb
CHANGED
@@ -12,10 +12,26 @@ RSpec.describe TTY::Cursor do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "saves cursor position" do
|
15
|
+
allow(Gem).to receive(:win_platform?).and_return(false)
|
16
|
+
|
17
|
+
expect(cursor.save).to eq("\e7")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "saves cursor position on Windows" do
|
21
|
+
allow(Gem).to receive(:win_platform?).and_return(true)
|
22
|
+
|
15
23
|
expect(cursor.save).to eq("\e[s")
|
16
24
|
end
|
17
25
|
|
18
26
|
it "restores cursor position" do
|
27
|
+
allow(Gem).to receive(:win_platform?).and_return(false)
|
28
|
+
|
29
|
+
expect(cursor.restore).to eq("\e8")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "restores cursor position on Windows" do
|
33
|
+
allow(Gem).to receive(:win_platform?).and_return(true)
|
34
|
+
|
19
35
|
expect(cursor.restore).to eq("\e[u")
|
20
36
|
end
|
21
37
|
|
data/tty-cursor.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-cursor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01
|
11
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.5.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.5.0
|
27
55
|
description: The purpose of this library is to help move the terminal cursor around
|
28
56
|
and manipulate text by using intuitive method calls.
|
29
57
|
email:
|