module Gdk::MarkupGenerator

begin rdoc

本文の、描画するためのテキストを生成するモジュール。

end

Public Instance Methods

_plain_description() click to toggle source
# File core/mui/cairo_markup_generator.rb, line 69
                def _plain_description
  Hash.new do |h, expand_emoji|
    h[expand_emoji] = score.map{|note|
      if expand_emoji && note.respond_to?(:inline_photo)
        '.'
      else
        note.description
      end
    }.to_a.join
  end
end
clickable?(model) click to toggle source
# File core/mui/cairo_markup_generator.rb, line 53
def clickable?(model)
  has_model_intent = Enumerator.new {|y| Plugin.filtering(:intent_select_by_model_slug, model.class.slug, y) }.first
  return true if has_model_intent
  Enumerator.new {|y|
    Plugin.filtering(:model_of_uri, model.uri, y)
  }.any?{|model_slug|
    Enumerator.new {|y| Plugin.filtering(:intent_select_by_model_slug, model_slug, y) }.first
  }
end
description_attr_list(attr_list=Pango::AttrList.new, emoji_height: 24) click to toggle source

表示する際に本文に適用すべき装飾オブジェクトを作成する

Return

Pango::AttrList 本文に適用する装飾

# File core/mui/cairo_markup_generator.rb, line 32
def description_attr_list(attr_list=Pango::AttrList.new, emoji_height: 24)
  Plugin[:gtk].score_of(message).inject(0){|start_index, note|
    end_index = start_index + note.description.bytesize
    if UserConfig[:miraclepainter_expand_custom_emoji] && note.respond_to?(:inline_photo)
      end_index += -note.description.bytesize + 1
      rect = Pango::Rectangle.new(0, 0, emoji_height * Pango::SCALE, emoji_height * Pango::SCALE)
      shape = Pango::AttrShape.new(rect, rect, note.inline_photo)
      shape.start_index = start_index
      shape.end_index = end_index
      attr_list.insert(shape)
    elsif clickable?(note)
      underline = Pango::AttrUnderline.new(Pango::Underline::SINGLE)
      underline.start_index = start_index
      underline.end_index = end_index
      attr_list.insert(underline)
    end
    end_index
  }
  attr_list
end
plain_description() click to toggle source

Entityを適用したあとのプレーンテキストを返す。 Pangoの都合上、絵文字は1文字で表現する

# File core/mui/cairo_markup_generator.rb, line 65
def plain_description
  _plain_description[UserConfig[:miraclepainter_expand_custom_emoji]]
end