reterm 0.5.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reterm/init.rb +10 -9
- data/lib/reterm/mixins/cdk_component.rb +4 -0
- data/lib/reterm/resize.rb +12 -1
- data/lib/reterm/terminal.rb +4 -1
- data/lib/reterm/version.rb +1 -1
- data/lib/reterm/window.rb +5 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 322cb2050b47800401185435691f5b5e79d9a9d3
|
4
|
+
data.tar.gz: 010ddff147de71d7a7163ab3627a05162b39e785
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94489d9e2e1336538ea9605d82bd37ca1dfc4ea322ec382b1f5376ced1d0c631d0997a284f8799f24391ba1ca427c6c37f9ec8a054ce5e86b8ff6add06b6e1e0
|
7
|
+
data.tar.gz: 77f4e71b0ca2c0eb005ecb17f6bc5e85c94bf5a8339686fec4bab6e664c6ac57f71b2978c60620c4829fe23b8763a30c40dcbfd7151cc519b8cda33c4e54d753
|
data/lib/reterm/init.rb
CHANGED
@@ -26,18 +26,19 @@ module RETerm
|
|
26
26
|
|
27
27
|
err = nil
|
28
28
|
|
29
|
+
min = opts[:min_size]
|
30
|
+
|
29
31
|
begin
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
# without a 'reset' (see below).
|
35
|
-
# So just preload terminal info here.
|
32
|
+
# XXX: must load terminal info before changing terminal settings
|
33
|
+
# (else causes crash... not sure why)
|
34
|
+
# But we also check min dimensions here
|
35
|
+
Terminal.load(min)
|
36
36
|
|
37
37
|
# shorten up the esc delay time
|
38
38
|
ENV["ESCDELAY"] = 100.to_s
|
39
39
|
|
40
40
|
stdscr = Ncurses::initscr
|
41
|
+
initialized = true
|
41
42
|
Ncurses::start_color
|
42
43
|
Ncurses::noecho
|
43
44
|
Ncurses::cbreak
|
@@ -56,10 +57,10 @@ module RETerm
|
|
56
57
|
|
57
58
|
ensure
|
58
59
|
stop_track_resize
|
59
|
-
Ncurses.curs_set(1)
|
60
|
+
Ncurses.curs_set(1) if !!initialized
|
60
61
|
Window.top.each { |w| w.finalize! }
|
61
62
|
CDK::SCREEN.endCDK if cdk_enabled?
|
62
|
-
Ncurses.endwin
|
63
|
+
Ncurses.endwin if !!initialized
|
63
64
|
#`reset -Q` # XXX only way to guarantee a full reset (see above)
|
64
65
|
end
|
65
66
|
|
@@ -95,7 +96,7 @@ module RETerm
|
|
95
96
|
Window.top.each { |w| w.noutrefresh }
|
96
97
|
end
|
97
98
|
|
98
|
-
Ncurses::Panel.update_panels
|
99
|
+
#Ncurses::Panel.update_panels
|
99
100
|
Ncurses.doupdate
|
100
101
|
end
|
101
102
|
|
data/lib/reterm/resize.rb
CHANGED
@@ -2,6 +2,11 @@ module RETerm
|
|
2
2
|
# Seconds between terminal size syncs
|
3
3
|
RESIZE_TIME = 0.2
|
4
4
|
|
5
|
+
# Set the global callback to be invoked on resize
|
6
|
+
def on_resize(&bl)
|
7
|
+
@on_resize = bl
|
8
|
+
end
|
9
|
+
|
5
10
|
# Internal helper to track size of terminal.
|
6
11
|
# This is a simple mechanism that launches a
|
7
12
|
# worker thread to periodically poll terminal size.
|
@@ -13,7 +18,13 @@ module RETerm
|
|
13
18
|
while @track_resize
|
14
19
|
Terminal.reset!
|
15
20
|
t = Terminal.dimensions
|
16
|
-
|
21
|
+
|
22
|
+
if t != d && !shutdown?
|
23
|
+
Terminal.resize!
|
24
|
+
@on_resize.call if !!@on_resize
|
25
|
+
end
|
26
|
+
|
27
|
+
d = Terminal.dimensions
|
17
28
|
sleep(RESIZE_TIME)
|
18
29
|
end
|
19
30
|
}
|
data/lib/reterm/terminal.rb
CHANGED
@@ -11,8 +11,11 @@ module RETerm
|
|
11
11
|
@dimensions ||= TermInfo.screen_size
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.load
|
14
|
+
def self.load(min = nil)
|
15
15
|
dimensions
|
16
|
+
raise ArgumentError, "Terminal too Small - min: #{min}" if min &&
|
17
|
+
(cols < min[:cols] ||
|
18
|
+
rows < min[:rows])
|
16
19
|
nil
|
17
20
|
end
|
18
21
|
|
data/lib/reterm/version.rb
CHANGED
data/lib/reterm/window.rb
CHANGED
@@ -166,11 +166,13 @@ module RETerm
|
|
166
166
|
@win = Ncurses::WINDOW.new(@rows, @cols, @y, @x)
|
167
167
|
end
|
168
168
|
|
169
|
+
raise ArgumentError, "could not create window" if !@win
|
170
|
+
|
169
171
|
self.component = component if !!component
|
170
172
|
|
171
173
|
Ncurses::keypad(@win, true)
|
172
174
|
|
173
|
-
@win.timeout(SYNC_TIMEOUT) if
|
175
|
+
@win.timeout(SYNC_TIMEOUT) if sync_enabled? # XXX
|
174
176
|
|
175
177
|
@expand = !!args[:expand]
|
176
178
|
@must_expand = !!args[:must_expand]
|
@@ -321,7 +323,7 @@ module RETerm
|
|
321
323
|
@children.delete(child)
|
322
324
|
@@registry.delete(child)
|
323
325
|
child.finalize!
|
324
|
-
child.win.delwin
|
326
|
+
child.win.delwin if !!child.win
|
325
327
|
end
|
326
328
|
|
327
329
|
# Return child containing specified screen coordiantes, else nil
|
@@ -377,7 +379,7 @@ module RETerm
|
|
377
379
|
|
378
380
|
@win.werase if @win
|
379
381
|
|
380
|
-
component.component.erase if cdk?
|
382
|
+
component.component.erase if cdk? && component? && component.init?
|
381
383
|
end
|
382
384
|
|
383
385
|
# Erases window screen by overwriting it with blanks
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reterm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mo Morsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-terminfo
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.6.
|
167
|
+
rubygems_version: 2.6.14
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: Text Based UI Framework built ontop of ncurses
|