Class: GitSpelunk::UI::RepoWindow

Inherits:
Window
  • Object
show all
Defined in:
lib/git_spelunk/ui/repo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Window

#line_remainder, #with_highlighting

Constructor Details

#initialize(height, offset) ⇒ RepoWindow

Returns a new instance of RepoWindow.



4
5
6
7
8
9
# File 'lib/git_spelunk/ui/repo.rb', line 4

def initialize(height, offset)
  @window = Curses::Window.new(height, Curses.cols, offset, 0)
  @offset = offset
  @height = height
  @content = ""
end

Instance Attribute Details

#command_bufferObject

Returns the value of attribute command_buffer.



11
12
13
# File 'lib/git_spelunk/ui/repo.rb', line 11

def command_buffer
  @command_buffer
end

#command_modeObject

Returns the value of attribute command_mode.



11
12
13
# File 'lib/git_spelunk/ui/repo.rb', line 11

def command_mode
  @command_mode
end

#contentObject

Returns the value of attribute content.



11
12
13
# File 'lib/git_spelunk/ui/repo.rb', line 11

def content
  @content
end

Instance Method Details

#drawObject



13
14
15
16
17
18
19
# File 'lib/git_spelunk/ui/repo.rb', line 13

def draw
  @window.setpos(0,0)
  draw_status_line
  @window.addstr(@content + "\n") if content
  @window.addstr("\n" * (@height - @content.split("\n").size - 1))
  @window.refresh
end

#draw_status_lineObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/git_spelunk/ui/repo.rb', line 21

def draw_status_line
  with_highlighting do
    @window.addstr("navigation: j k CTRL-D CTRL-U   ")
    @window.addstr("history: [ ]   ")
    @window.addstr("search: / ? n N   ")
    @window.addstr("git-show: s   ")
    @window.addstr("quit: q   ")
    @window.addstr(" " * line_remainder + "\n")
  end
end