Class: PWKeep::StatusBar

Inherits:
Object
  • Object
show all
Defined in:
lib/pwkeep/editor.rb

Instance Method Summary collapse

Constructor Details

#initialize(editor, options) ⇒ StatusBar

Returns a new instance of StatusBar.



422
423
424
425
# File 'lib/pwkeep/editor.rb', line 422

def initialize(editor, options)
  @editor = editor
  @options = options
end

Instance Method Details

#change_indicatorObject



444
445
446
# File 'lib/pwkeep/editor.rb', line 444

def change_indicator
  @editor.modified? ? '*' : ' '
end

#style_mapObject



440
441
442
# File 'lib/pwkeep/editor.rb', line 440

def style_map
  Dispel::StyleMap.single_line_reversed(@options[:columns])
end

#viewObject



427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/pwkeep/editor.rb', line 427

def view
  columns = @options[:columns]

  version = "Ruco #{Ruco::VERSION} -- "
  position = " #{@editor.position.line + 1}:#{@editor.position.column + 1}"
  indicators = "#{change_indicator}#{writable_indicator}"
  essential = version + position + indicators
  space_left = [columns - essential.size, 0].max

  # fit file name into remaining space
  "#{version}#{indicators}#{' ' * space_left}#{position}"[0, columns]
end

#writable_indicatorObject



448
449
450
# File 'lib/pwkeep/editor.rb', line 448

def writable_indicator
  true
end