tty-cursor 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21bae31e727bfc59faaf59b29fe458f9d6c96463
4
- data.tar.gz: 145f6e5308fc50a95c51e76bff5b076114d6bc06
3
+ metadata.gz: ced9bfc434424bc7c450d55a5722d629bfccb300
4
+ data.tar.gz: 8e74ddf9066f4e707fe6540b0de72edd6ffa7ffb
5
5
  SHA512:
6
- metadata.gz: 38785d325d0a77807bfdc213b87e90e6786a1508c4416a8ecf68bf92d1227e9cdb35aa7fcc43116e1e49759dc07e10bddcd321eb1f5fc4e70d89a5e6cbeca0fd
7
- data.tar.gz: 12c6e6be868e68e6f0f3bd50b02eea8c409940ed9189d3d99910eeab43c6c4ccd3c85e4d0bd789e04a8b66262e58fe79dfc9198e7abc449c4df500d66231b662
6
+ metadata.gz: c9b25ab21870b143583d27ec9894e26215beb58ddbe515a54bc0b601c493fa532ab318a863a8f61ea77c5d8f6cb6b5ccefbfa4e6b08f4a1bc0a09bda7b52bac6
7
+ data.tar.gz: 2ede7d2c394cfdb8f76116688baf2879e54ab691013b805c0464b2f0ae7b8eb39a6dc444d092aea5ea984013155f24658e0fc587db28a3f621a044e0f6549c2f
@@ -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
@@ -3,8 +3,6 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem 'rake', '~> 10.4.2'
7
- gem 'rspec', '~> 3.5.0'
8
6
  gem 'yard', '~> 0.8.7'
9
7
  gem 'benchmark-ips', '~> 2.0.0'
10
8
  end
@@ -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('') do |acc, i|
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TTY
4
4
  module Cursor
5
- VERSION = '0.4.0'
5
+ VERSION = '0.5.0'
6
6
  end # Cursor
7
7
  end # TTY
@@ -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
 
@@ -19,4 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec', '~> 3.5.0'
22
24
  end
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.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-08 00:00:00.000000000 Z
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: