terminal-layout 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/lib/ansi_string.rb +4 -0
- data/lib/terminal_layout/version.rb +1 -1
- data/lib/terminal_layout.rb +30 -15
- data/spec/ansi_string_spec.rb +9 -0
- data/terminal-layout.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 717c542a1d6c338e54086d1a3bb5b77dd95cb035
|
4
|
+
data.tar.gz: 2009b46c650de33f6eb1c427acfa59896b27c608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06115b77a9a0176f96793a2a61cd9a518429a96a3583942f13789dd819db2d33e818c2aeee708a0df429ed13bd483940bf5c3d155b6a2e9a7b94f7f64a0e28f9
|
7
|
+
data.tar.gz: 0afcb428fcfdcdb0c2c3d739697e411f81a1e8faeb881a35698c6b338db2c3fcf0c9c54faea966b38857cbff3a6c6315d632130e02d1ef9761119d6d47def123
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
terminal-layout (0.3.
|
4
|
+
terminal-layout (0.3.1)
|
5
5
|
highline (~> 1.7, >= 1.7.8)
|
6
6
|
ruby-terminfo (~> 0.1.1)
|
7
7
|
ruby-termios (~> 0.9.6)
|
8
|
+
treefell (~> 0.2.3)
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
@@ -43,6 +44,8 @@ GEM
|
|
43
44
|
term-ansicolor (1.3.0)
|
44
45
|
tins (~> 1.0)
|
45
46
|
tins (1.3.5)
|
47
|
+
treefell (0.2.3)
|
48
|
+
term-ansicolor (~> 1.3)
|
46
49
|
|
47
50
|
PLATFORMS
|
48
51
|
ruby
|
data/lib/ansi_string.rb
CHANGED
data/lib/terminal_layout.rb
CHANGED
@@ -325,20 +325,7 @@ module TerminalLayout
|
|
325
325
|
@computed = {}
|
326
326
|
|
327
327
|
initialize_defaults
|
328
|
-
|
329
|
-
@children.each do |child|
|
330
|
-
child.on(:content_changed) do |*args|
|
331
|
-
emit :child_changed
|
332
|
-
end
|
333
|
-
|
334
|
-
child.on(:child_changed) do |*args|
|
335
|
-
emit :child_changed
|
336
|
-
end
|
337
|
-
|
338
|
-
child.on(:position_changed) do |*args|
|
339
|
-
emit :position_changed
|
340
|
-
end
|
341
|
-
end
|
328
|
+
subscribe_to_events_on_children
|
342
329
|
end
|
343
330
|
|
344
331
|
%w(width height display x y float).each do |method|
|
@@ -356,8 +343,10 @@ module TerminalLayout
|
|
356
343
|
end
|
357
344
|
|
358
345
|
def children=(new_children)
|
346
|
+
unsubscribe_from_events_on_children
|
359
347
|
old_children = @children
|
360
348
|
@children = new_children
|
349
|
+
subscribe_to_events_on_children
|
361
350
|
emit :child_changed, old_children, new_children
|
362
351
|
end
|
363
352
|
|
@@ -398,6 +387,28 @@ module TerminalLayout
|
|
398
387
|
def initialize_defaults
|
399
388
|
style.has_key?(:display) || style[:display] = :block
|
400
389
|
end
|
390
|
+
|
391
|
+
private
|
392
|
+
|
393
|
+
def unsubscribe_from_events_on_children
|
394
|
+
@children.each do |child|
|
395
|
+
child.unsubscribe
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
def subscribe_to_events_on_children
|
400
|
+
@children.each do |child|
|
401
|
+
child.on(:content_changed) do |*args|
|
402
|
+
emit :child_changed
|
403
|
+
end
|
404
|
+
child.on(:child_changed) do |*args|
|
405
|
+
emit :child_changed
|
406
|
+
end
|
407
|
+
child.on(:position_changed) do |*args|
|
408
|
+
emit :position_changed
|
409
|
+
end
|
410
|
+
end
|
411
|
+
end
|
401
412
|
end
|
402
413
|
|
403
414
|
|
@@ -555,9 +566,13 @@ module TerminalLayout
|
|
555
566
|
|
556
567
|
printable_lines.zip(@previously_printed_lines) do |new_line, previous_line|
|
557
568
|
if new_line != previous_line
|
569
|
+
# be sure to reset the terminal at the outset of every line
|
570
|
+
# because we don't know what state the previous line ended in
|
571
|
+
line2print = "#{new_line}\e[0m"
|
558
572
|
term_info.control "el"
|
559
573
|
move_to_beginning_of_row
|
560
|
-
|
574
|
+
Treefell['render'].puts "printing line=#{line2print.inspect}"
|
575
|
+
@output.puts line2print
|
561
576
|
else
|
562
577
|
move_down_n_rows 1
|
563
578
|
end
|
data/spec/ansi_string_spec.rb
CHANGED
@@ -681,6 +681,15 @@ describe 'ANSIString' do
|
|
681
681
|
end
|
682
682
|
end
|
683
683
|
|
684
|
+
describe "#inspect" do
|
685
|
+
subject(:ansi_string){ ANSIString.new blue(string) }
|
686
|
+
let(:string){ "this is blue" }
|
687
|
+
|
688
|
+
it "returns a quoted version of the strong" do
|
689
|
+
expect(ansi_string.inspect).to eq "\"\\e[34mthis is blue\\e[0m\""
|
690
|
+
end
|
691
|
+
end
|
692
|
+
|
684
693
|
describe "#succ" do
|
685
694
|
it "needs to be implemented"
|
686
695
|
end
|
data/terminal-layout.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "ruby-terminfo", "~> 0.1.1"
|
22
22
|
spec.add_dependency "ruby-termios", "~> 0.9.6"
|
23
23
|
spec.add_dependency 'highline', '~> 1.7', '>= 1.7.8'
|
24
|
+
spec.add_dependency "treefell", "~> 0.2.3"
|
24
25
|
|
25
26
|
spec.add_development_dependency "bundler", "~> 1.7"
|
26
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal-layout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-terminfo
|
@@ -58,6 +58,20 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 1.7.8
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: treefell
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.2.3
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.2.3
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: bundler
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|