terminal-layout 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.travis.yml +14 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +60 -0
- data/README.md +7 -0
- data/block-flow.rb +361 -0
- data/lib/ansi_string.rb +315 -0
- data/lib/terminal_layout.rb +527 -0
- data/spec/ansi_string_spec.rb +499 -0
- data/spec/spec_helper.rb +102 -0
- data/spec/terminal_layout_spec.rb +745 -0
- data/terminal-layout.gemspec +28 -0
- data/test-1.rb +90 -0
- metadata +158 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "terminal-layout"
|
7
|
+
spec.version = "0.1.0"
|
8
|
+
spec.authors = ["Zach Dennis"]
|
9
|
+
spec.email = ["zach.dennis@gmail.com"]
|
10
|
+
spec.summary = %q{A terminal layout manager}
|
11
|
+
spec.description = %q{A terminal layout manager}
|
12
|
+
spec.homepage = "https://github.com/zdennis/terminal-layout"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
# spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "ruby-terminfo", "~> 0.1.1"
|
21
|
+
spec.add_dependency "ruby-termios", "~> 0.9.6"
|
22
|
+
spec.add_dependency "highline"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
end
|
data/test-1.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
post_number = 1
|
5
|
+
|
6
|
+
require 'pry'
|
7
|
+
$LOAD_PATH << "lib"
|
8
|
+
require "terminal_layout"
|
9
|
+
require 'term/ansicolor'
|
10
|
+
|
11
|
+
Color = Term::ANSIColor
|
12
|
+
|
13
|
+
|
14
|
+
left_status = Color.yellow("[/Users/zdennis/20150923213313_create_nested_question_answer_join_table.rb]")
|
15
|
+
prompt = "This is my very special prompt> "
|
16
|
+
right_status = Color.blue("EVERYTHING LOOKS GOOD MY FRIEND!")
|
17
|
+
|
18
|
+
left_status_box = TerminalLayout::Box.new(content: left_status, style: {display: :inline})
|
19
|
+
right_status_box = TerminalLayout::Box.new(content: right_status, style: {display: :inline})
|
20
|
+
|
21
|
+
bottom_left_status_box = TerminalLayout::Box.new(content: left_status.dup, style: {display: :inline})
|
22
|
+
bottom_right_status_box = TerminalLayout::Box.new(content: right_status.dup, style: {display: :inline})
|
23
|
+
|
24
|
+
hard_status_box = TerminalLayout::Box.new(content: "^^^^^^^^^^^^^^^^^^^^^^^ HARD STATUS ^^^^^^^^^^^^^^^^^^")
|
25
|
+
|
26
|
+
|
27
|
+
dom = TerminalLayout::Box.new(children:[
|
28
|
+
left_status_box,
|
29
|
+
TerminalLayout::Box.new(style: {display: :float, float: :right, width: right_status.length},
|
30
|
+
children: [
|
31
|
+
right_status_box
|
32
|
+
]),
|
33
|
+
TerminalLayout::Box.new(content: prompt, style: {display: :inline}),
|
34
|
+
TerminalLayout::Box.new(content: "ls | grep foo", style: {display: :inline}),
|
35
|
+
hard_status_box,
|
36
|
+
TerminalLayout::Box.new(style: {display: :float, float: :left, width: left_status.length},
|
37
|
+
children: [
|
38
|
+
bottom_left_status_box
|
39
|
+
]),
|
40
|
+
TerminalLayout::Box.new(style: {display: :float, float: :right, width: right_status.length},
|
41
|
+
children: [
|
42
|
+
bottom_right_status_box
|
43
|
+
]),
|
44
|
+
])
|
45
|
+
|
46
|
+
$z = File.open("/tmp/z.log", "w+")
|
47
|
+
$z.sync = true
|
48
|
+
|
49
|
+
terminal_renderer = TerminalLayout::TerminalRenderer.new
|
50
|
+
|
51
|
+
render_tree = TerminalLayout::RenderTree.new(dom, parent: nil, style: {width:178, height:44}, renderer: terminal_renderer)
|
52
|
+
render_tree.layout
|
53
|
+
terminal_renderer.render(render_tree)
|
54
|
+
|
55
|
+
sleep 0.75
|
56
|
+
left_status_box.content = Color.red("[UPDATED LEFT STATUS]")
|
57
|
+
sleep 0.5
|
58
|
+
|
59
|
+
dirs = (Dir[ENV["HOME"] + "/*"] * 100).to_enum
|
60
|
+
|
61
|
+
# dirs = (["/Users/zdennis/20150923213313_create_nested_question_answer_join_table.rb"]*100).to_enum
|
62
|
+
|
63
|
+
b = "a"
|
64
|
+
c = 12345
|
65
|
+
# sleep 2
|
66
|
+
loop do
|
67
|
+
right_status_box.content = Color.green("[#{Time.now}]")
|
68
|
+
sleep 0.25
|
69
|
+
bottom_left_status_box.content = b.succ!
|
70
|
+
sleep 0.25
|
71
|
+
|
72
|
+
bottom_right_status_box.content = (c+=1).to_s
|
73
|
+
sleep 0.25
|
74
|
+
|
75
|
+
left_status_box.content = "[" + dirs.next + "]"
|
76
|
+
sleep 0.25
|
77
|
+
|
78
|
+
# sample_post = JSON.parse Net::HTTP.get(URI("http://jsonplaceholder.typicode.com/posts/#{post_number+=1}"))
|
79
|
+
# title = sample_post["title"]
|
80
|
+
# length = 178
|
81
|
+
# num_spaces = (length - title.length) / 2
|
82
|
+
# str = "#{' ' * num_spaces}#{Color.green(sample_post['title'])}#{' ' * num_spaces}"
|
83
|
+
# $c = true
|
84
|
+
# hard_status_box.content = "#{' ' * num_spaces}#{Color.green(sample_post['title'])}#{' ' * num_spaces}"
|
85
|
+
# sleep 199
|
86
|
+
|
87
|
+
# hard_status_box.content + hard_status_box.content
|
88
|
+
hard_status_box.content = hard_status_box.content + ("A"* 30) + " " #hard_status_box.content
|
89
|
+
end
|
90
|
+
puts "DIED?"
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: terminal-layout
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zach Dennis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruby-terminfo
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-termios
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.9.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: highline
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A terminal layout manager
|
112
|
+
email:
|
113
|
+
- zach.dennis@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".rspec"
|
119
|
+
- ".travis.yml"
|
120
|
+
- Gemfile
|
121
|
+
- Gemfile.lock
|
122
|
+
- README.md
|
123
|
+
- block-flow.rb
|
124
|
+
- lib/ansi_string.rb
|
125
|
+
- lib/terminal_layout.rb
|
126
|
+
- spec/ansi_string_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/terminal_layout_spec.rb
|
129
|
+
- terminal-layout.gemspec
|
130
|
+
- test-1.rb
|
131
|
+
homepage: https://github.com/zdennis/terminal-layout
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.4.6
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: A terminal layout manager
|
155
|
+
test_files:
|
156
|
+
- spec/ansi_string_spec.rb
|
157
|
+
- spec/spec_helper.rb
|
158
|
+
- spec/terminal_layout_spec.rb
|