Sha256: f32a6c946e22c4f3102c033d872e0af74da1465761730b2ccdaa10bdacdaa2c5

Contents?: true

Size: 611 Bytes

Versions: 3

Compression:

Stored size: 611 Bytes

Contents

module TermNote
  module Pane
    class Code
      include Pane

      attr_accessor :source, :language

      def initialize(options)
        @source = options[:source] || options['source']
        @language = options[:language] || options['language']
      end

      def rows
        highlighted.split("\n")
      end

      private

      def highlighted
        CodeRay.scan(source, language).term
      end

      def gutter_width(row)
        width * 0.25
      end

      def space
        newlines = height > rows.size ? (height - rows.size) / 2 : 0
        "\n" * newlines
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
termnote-2.0.1 lib/termnote/pane/code.rb
termnote-2.0.0 lib/termnote/pane/code.rb
termnote-1.5.1 lib/termnote/pane/code.rb