tty-box 0.1.0 → 0.2.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 +7 -0
- data/README.md +11 -1
- data/lib/tty/box.rb +11 -7
- data/lib/tty/box/version.rb +1 -1
- data/tty-box.gemspec +5 -3
- metadata +2 -6
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.travis.yml +0 -26
- data/assets/tty-box-drawing.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9daceddbaca9658a170dde1ce447aebc05af9972015cc71aa003de5e120b2c8
|
4
|
+
data.tar.gz: d9ba3ea634b244a7b6044d1060a1cb38a2164646a6ff7bc9c716000bd49e78cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7d43320b77c1edb2164684e90f5a2431e58f48f31838170b20b16349f2d0074c4274fe92348457546bafd2ad29874ca5b889c9c7a40c7271721fa599a0ae2cf
|
7
|
+
data.tar.gz: 422d8dc8a0b7eaa183e2f7db40a3e2c0d89dae5bdfde98181919109bdc86555de82a957f3855fe73338f285d40df118fdf82a2622a87831dc50899ad3e9fcea2
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.2.0] - 2018-07-31
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
* Change to stop positioning box without `:top` & `:left` coordinates
|
7
|
+
* Change to load manually required files in gemspec without using git
|
8
|
+
|
3
9
|
## [v0.1.0] - 2018-07-23
|
4
10
|
|
5
11
|
* Initial implementation and release
|
6
12
|
|
13
|
+
[v0.2.0]: https://github.com/piotrmurach/tty-box/compare/v0.1.0...v0.2.0
|
7
14
|
[v0.1.0]: https://github.com/piotrmurach/tty-box/compare/v0.1.0
|
data/README.md
CHANGED
@@ -136,12 +136,14 @@ print box
|
|
136
136
|
|
137
137
|
### 2.2 position
|
138
138
|
|
139
|
-
By default, a box will be positioned
|
139
|
+
By default, a box will not be positioned. To position your box absolutely within a terminal window use `:top` and `:left` keyword arguments:
|
140
140
|
|
141
141
|
```ruby
|
142
142
|
TTY::Box.frame(top: 5, left: 10)
|
143
143
|
```
|
144
144
|
|
145
|
+
This will place box 10 columns to the right and 5 lines down counting from the top left corner.
|
146
|
+
|
145
147
|
If you wish to center your box within the terminal window then consider using [tty-screen](https://github.com/piotrmurach/tty-screen) for gathering terminal screen size information.
|
146
148
|
|
147
149
|
### 2.3 dimension
|
@@ -152,6 +154,14 @@ At the very minimum a box requires to be given size by using two keyword argumen
|
|
152
154
|
TTY::Box.frame(width: 30, height: 10)
|
153
155
|
```
|
154
156
|
|
157
|
+
If you wish to create a box that depends on the terminal window size then consider using [tty-screen](https://github.com/piotrmurach/tty-screen) for gathering terminal screen size information.
|
158
|
+
|
159
|
+
For example to print a box that spans the whole terminal window do:
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
TTY::Box.frame(width: TTY::Screen.width, height: TTY::Screen.height)
|
163
|
+
```
|
164
|
+
|
155
165
|
### 2.4 title
|
156
166
|
|
157
167
|
You can specify titles using the `:title` keyword and a hash value that contains one of the `:top_left`, `:top_center`, `:top_right`, `:bottom_left`, `:bottom_center`, `:bottom_right` keys and actual title as value. For example, to add titles to top left and bottom right of the frame do:
|
data/lib/tty/box.rb
CHANGED
@@ -71,10 +71,11 @@ module TTY
|
|
71
71
|
# Create a frame
|
72
72
|
#
|
73
73
|
# @api public
|
74
|
-
def frame(top:
|
74
|
+
def frame(top: nil, left: nil, width: 35, height: 3, align: :left, padding: 0,
|
75
75
|
title: {}, border: :light, style: {})
|
76
76
|
output = []
|
77
77
|
content = []
|
78
|
+
position = top && left
|
78
79
|
|
79
80
|
border = Border.parse(border)
|
80
81
|
|
@@ -86,16 +87,17 @@ module TTY
|
|
86
87
|
border_fg, border_bg = *extract_style(style[:border] || {})
|
87
88
|
|
88
89
|
if border.top?
|
89
|
-
output << cursor.move_to(left, top)
|
90
|
+
output << cursor.move_to(left, top) if position
|
90
91
|
output << top_border(title, width, border.type, style)
|
92
|
+
output << "\n" unless position
|
91
93
|
end
|
92
94
|
(height - 2).times do |i|
|
93
95
|
if border.left?
|
94
|
-
output << cursor.move_to(left, top + i + 1)
|
96
|
+
output << cursor.move_to(left, top + i + 1) if position
|
95
97
|
output << border_bg.(border_fg.(pipe_char(border.type)))
|
96
98
|
end
|
97
|
-
if content[i].nil?
|
98
|
-
output << bg.(fg.(' ' * (width - 2)))
|
99
|
+
if content[i].nil? && (style[:fg] || style[:bg] || !position)
|
100
|
+
output << bg.(fg.(' ' * (width - 2)))
|
99
101
|
else
|
100
102
|
output << bg.(fg.(content[i]))
|
101
103
|
if style[:fg] || style[:bg]
|
@@ -103,13 +105,15 @@ module TTY
|
|
103
105
|
end
|
104
106
|
end
|
105
107
|
if border.right?
|
106
|
-
output << cursor.move_to(left + width - 1, top + i + 1)
|
108
|
+
output << cursor.move_to(left + width - 1, top + i + 1) if position
|
107
109
|
output << border_bg.(border_fg.(pipe_char(border.type)))
|
108
110
|
end
|
111
|
+
output << "\n" unless position
|
109
112
|
end
|
110
113
|
if border.bottom?
|
111
|
-
output << cursor.move_to(left, top + height - 1)
|
114
|
+
output << cursor.move_to(left, top + height - 1) if position
|
112
115
|
output << bottom_border(title, width, border.type, style)
|
116
|
+
output << "\n" unless position
|
113
117
|
end
|
114
118
|
|
115
119
|
output.join
|
data/lib/tty/box/version.rb
CHANGED
data/tty-box.gemspec
CHANGED
@@ -13,9 +13,11 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://piotrmurach.github.io/tty"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files
|
17
|
-
|
18
|
-
|
16
|
+
spec.files = Dir.glob('lib/**/*.rb') + Dir.glob('bin/*')
|
17
|
+
spec.files += Dir.glob('examples/*.rb') + Dir.glob('tasks/*.rake')
|
18
|
+
spec.files += Dir.glob('[A-Z]*') + Dir.glob('[a-z]*\.*')
|
19
|
+
spec.files.reject! { |f| f.match(%r{.lock$}) }
|
20
|
+
|
19
21
|
spec.bindir = "exe"
|
20
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
23
|
spec.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pastel
|
@@ -101,9 +101,6 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- ".gitignore"
|
105
|
-
- ".rspec"
|
106
|
-
- ".travis.yml"
|
107
104
|
- CHANGELOG.md
|
108
105
|
- CODE_OF_CONDUCT.md
|
109
106
|
- Gemfile
|
@@ -111,7 +108,6 @@ files:
|
|
111
108
|
- README.md
|
112
109
|
- Rakefile
|
113
110
|
- appveyor.yml
|
114
|
-
- assets/tty-box-drawing.png
|
115
111
|
- bin/console
|
116
112
|
- bin/setup
|
117
113
|
- examples/commander.rb
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
---
|
2
|
-
language: ruby
|
3
|
-
sudo: false
|
4
|
-
cache: bundler
|
5
|
-
before_install: "gem update bundler"
|
6
|
-
script: "bundle exec rake ci"
|
7
|
-
rvm:
|
8
|
-
- 2.0.0
|
9
|
-
- 2.1.10
|
10
|
-
- 2.2.9
|
11
|
-
- 2.3.6
|
12
|
-
- 2.4.4
|
13
|
-
- 2.5.1
|
14
|
-
- ruby-head
|
15
|
-
- jruby-9.1.5.0
|
16
|
-
- jruby-head
|
17
|
-
matrix:
|
18
|
-
allow_failures:
|
19
|
-
- rvm: ruby-head
|
20
|
-
- rvm: jruby-9.1.5.0
|
21
|
-
- rvm: jruby-head
|
22
|
-
fast_finish: true
|
23
|
-
branches:
|
24
|
-
only: master
|
25
|
-
notifications:
|
26
|
-
email: false
|
data/assets/tty-box-drawing.png
DELETED
Binary file
|