Sha256: 1ce58c1a2083fef80ff0481581b940e5067d6ad7ea2b96411dd22372514ecb98
Contents?: true
Size: 1.31 KB
Versions: 33
Compression:
Stored size: 1.31 KB
Contents
module Ruco class StatusBar def initialize(editor, options) @editor = editor @options = options end 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 file = @editor.file file = file.ellipsize(:max => space_left) space_left -= file.size "#{version}#{file}#{indicators}#{' ' * space_left}#{position}"[0, columns] end def style_map StyleMap.single_line_reversed(@options[:columns]) end def change_indicator @editor.modified? ? '*' : ' ' end def writable_indicator @writable ||= begin writable = (not File.exist?(@editor.file) or system("test -w #{@editor.file}")) writable ? ' ' : '!' end end private # fill the line with left column and then overwrite the right section def spread(left, right) empty = [@options[:columns] - left.size, 0].max line = left + (" " * empty) line[(@options[:columns] - right.size - 1)..-1] = ' ' + right line end end end
Version data entries
33 entries across 33 versions & 1 rubygems