Class: Bash_Visual::VerticalScroll

Inherits:
Scroll
  • Object
show all
Defined in:
lib/bash-visual/vertical_scroll.rb

Constant Summary

Constants inherited from Scroll

Scroll::BACKWARD, Scroll::BEGINNING, Scroll::ENDING, Scroll::FORWARD

Instance Attribute Summary

Attributes inherited from Scroll

#console

Attributes included from FixedObject

#height, #width, #x, #y

Instance Method Summary collapse

Methods inherited from Scroll

#add, form_block, #initialize, #prefix, #prefix=, #scroll

Methods included from FixedObject

#position, #size

Constructor Details

This class inherits a constructor from Bash_Visual::Scroll

Instance Method Details

#get_y_position(available_area_height, message_size = 0) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/bash-visual/vertical_scroll.rb', line 4

def get_y_position available_area_height, message_size = 0
  if (@start == BEGINNING)
    @y + (@height - available_area_height)
  else
    @y + available_area_height - message_size
  end
end


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bash-visual/vertical_scroll.rb', line 12

def print_message message, font, available_area

  available_area_width, available_area_height = available_area

  msg_block_height =
      case
        when !@adapt
          1
        when @fixed_message_block_size
          @fixed_message_block_size
        when @max_message_block_size
          @max_message_block_size
        else
          available_area_height
      end

  msg_block_height -= 1 if @separator
  msg_block_height = available_area_height if msg_block_height > available_area_height

  message = Scroll.form_block message, [available_area_width, msg_block_height]
  if @separator
    message << @separator * available_area_width
  end

  write(@x, get_y_position(available_area_height, message.size), message, font)

  [available_area_width, available_area_height - message.size]
end