Sha256: 5f405f2bac02279401e6f83c5a88d8ede87a837ea30fdb8cc24ea41c1e8ff1a0

Contents?: true

Size: 745 Bytes

Versions: 8

Compression:

Stored size: 745 Bytes

Contents

module Ruco
  class StatusBar
    def initialize(editor, options)
      @editor = editor
      @options = options
    end

    def view
      position = @editor.position
      spread "Ruco #{Ruco::VERSION} -- #{@editor.file}#{change_indicator}#{writable_indicator}", "#{position.line + 1}:#{position.column + 1}"
    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

    def spread(left, right)
      empty = [@options[:columns] - left.size - right.size, 0].max
      "#{left}#{' ' * empty}#{right}"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruco-0.1.4 lib/ruco/status_bar.rb
ruco-0.1.3 lib/ruco/status_bar.rb
ruco-0.1.2 lib/ruco/status_bar.rb
ruco-0.1.1 lib/ruco/status_bar.rb
ruco-0.1.0 lib/ruco/status_bar.rb
ruco-0.0.56 lib/ruco/status_bar.rb
ruco-0.0.55 lib/ruco/status_bar.rb
ruco-0.0.54 lib/ruco/status_bar.rb