Class: JarEd::FileView

Inherits:
Object
  • Object
show all
Defined in:
lib/jared/file_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer) ⇒ FileView

Returns a new instance of FileView.



7
8
9
10
11
12
# File 'lib/jared/file_view.rb', line 7

def initialize(buffer)
  @buffer = buffer
  @row_offset = 0
  @cursor_row = 0
  @cursor_column = 0
end

Instance Attribute Details

#paneObject

Returns the value of attribute pane.



5
6
7
# File 'lib/jared/file_view.rb', line 5

def pane
  @pane
end

Instance Method Details

#send_input(input) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jared/file_view.rb', line 23

def send_input(input)
  case input
  when "h"
    update_cursor(column: cursor_column - 1)
  when "j"
    update_cursor(row: cursor_row + 1)
  when "k"
    update_cursor(row: cursor_row - 1)
  when "l"
    update_cursor(column: cursor_column + 1)
  end
end

#to_screenObject



15
16
17
18
19
20
21
# File 'lib/jared/file_view.rb', line 15

def to_screen
  Screen.new(
    cursor_column: screen_cursor_column,
    cursor_row: screen_cursor_row,
    lines: screen_lines
  )
end