Module: Remedy::Console::Resize

Defined in:
lib/remedy/console_resize.rb

Class Method Summary collapse

Class Method Details

.default_console_resized_hook!Object



44
45
46
# File 'lib/remedy/console_resize.rb', line 44

def default_console_resized_hook!
  Signal.trap 'SIGWINCH', 'DEFAULT'
end

.resized!Object



16
17
18
# File 'lib/remedy/console_resize.rb', line 16

def resized!
  @resize_count = @resize_count < 0 ? 0 : @resize_count - 1
end

.resized?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/remedy/console_resize.rb', line 12

def resized?
  @resize_count <= 1
end

.resizer?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/remedy/console_resize.rb', line 20

def resizer?
  @resize_count == 1
end

.resizing!Object



8
9
10
# File 'lib/remedy/console_resize.rb', line 8

def resizing!
  @resize_count = @resize_count < 1 ? 1 : @resize_count + 1
end

.resizing?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/remedy/console_resize.rb', line 4

def resizing?
  @resize_count > 0
end

.set_console_resized_hook!Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/remedy/console_resize.rb', line 24

def set_console_resized_hook!
  @resize_count = 0

  Signal.trap 'SIGWINCH' do
    resizing!

    if resized? then
      begin
        yield Console.size
      rescue Exception => ex
        # Ruby will eat *any* errors inside a trap,
        # so we need to expose them for debuggability
        p ex
      end
    end

    resized!
  end
end