| 1 |
|
| 2 |
|
| 3 |
require_relative 'pane' |
| 4 |
require_relative 'cuscadable' |
| 5 |
require_relative 'hierarchy_child' |
| 6 |
require_relative 'tab' |
| 7 |
require_relative 'widget' |
| 8 |
|
| 9 |
class Plugin::GUI::Timeline |
| 10 |
|
| 11 |
include Plugin::GUI::Cuscadable |
| 12 |
include Plugin::GUI::HierarchyChild |
| 13 |
include Plugin::GUI::HierarchyParent |
| 14 |
include Plugin::GUI::Widget |
| 15 |
|
| 16 |
include Enumerable |
| 17 |
|
| 18 |
role :timeline |
| 19 |
|
| 20 |
set_parent_event :gui_timeline_join_tab |
| 21 |
|
| 22 |
def initialize(*args) |
| 23 |
super |
| 24 |
Plugin.call(:timeline_created, self) |
| 25 |
end |
| 26 |
|
| 27 |
def <<(argument) |
| 28 |
messages = argument.is_a?(Enumerable) ? argument : Array[argument] |
| 29 |
Plugin.call(:gui_timeline_add_messages, self, messages) |
| 30 |
end |
| 31 |
|
| 32 |
の中のツイートを全て削除する |
| 33 |
def clear |
| 34 |
Plugin.call(:gui_timeline_clear, self) end |
| 35 |
|
| 36 |
ンの一番上にスクロール |
| 37 |
def scroll_to_top |
| 38 |
Plugin.call(:gui_timeline_scroll_to_top, self) end |
| 39 |
|
| 40 |
ブにする。また、子のPostboxは非アクティブにする |
| 41 |
|
| 42 |
|
| 43 |
def active!(just_this=true, by_toolkit=false) |
| 44 |
set_active_child(nil, by_toolkit) if just_this |
| 45 |
super end |
| 46 |
|
| 47 |
が含まれているなら真を返す |
| 48 |
|
| 49 |
ブジェクト。配列や引数で複数指定した場合は、それら全てが含まれているかを返す |
| 50 |
|
| 51 |
れているなら真 |
| 52 |
def include?(*messages) |
| 53 |
args = messages.flatten.freeze |
| 54 |
detected = Plugin.filtering(:gui_timeline_select_messages, self, args) |
| 55 |
detected.is_a? Array and detected[1].size == args.size end |
| 56 |
|
| 57 |
れているMessageを返す |
| 58 |
|
| 59 |
まれているか確認するMessage |
| 60 |
|
| 61 |
中で、selfに含まれるもの |
| 62 |
def in_message(messages) |
| 63 |
detected = Plugin.filtering(:gui_timeline_select_messages, self, messages) |
| 64 |
if detected.is_a? Enumerable |
| 65 |
detected[1] |
| 66 |
else |
| 67 |
[] end end |
| 68 |
|
| 69 |
れていないMessageを返す |
| 70 |
|
| 71 |
ているか確認するMessageオブジェクト |
| 72 |
|
| 73 |
で、selfに含まれていないもの |
| 74 |
def not_in_message(messages) |
| 75 |
detected = Plugin.filtering(:gui_timeline_reject_messages, self, messages) |
| 76 |
if detected.is_a? Enumerable |
| 77 |
detected[1] |
| 78 |
else |
| 79 |
[] end end |
| 80 |
|
| 81 |
いるMessageを返す |
| 82 |
|
| 83 |
ているMessage |
| 84 |
def selected_messages |
| 85 |
messages = Plugin.filtering(:gui_timeline_selected_messages, self, []) |
| 86 |
messages[1] if messages.is_a? Array end |
| 87 |
|
| 88 |
るPostboxを作成してタイムライン上に表示する |
| 89 |
|
| 90 |
イ先のツイート |
| 91 |
プション |
| 92 |
def create_reply_postbox(in_reply_to_message, options = {}) |
| 93 |
create_postbox(options.merge(to: [in_reply_to_message], |
| 94 |
header: "@#{in_reply_to_message.user.idname} ")) |
| 95 |
end |
| 96 |
|
| 97 |
るPostboxを作成してタイムライン上に表示する |
| 98 |
|
| 99 |
プション |
| 100 |
def create_postbox(options = {}) |
| 101 |
i_postbox = Plugin::GUI::Postbox.instance |
| 102 |
i_postbox.options = options |
| 103 |
self.add_child i_postbox |
| 104 |
end |
| 105 |
|
| 106 |
てこの中に入れる |
| 107 |
|
| 108 |
定値 |
| 109 |
|
| 110 |
成したPostbox |
| 111 |
def postbox(options = {}) |
| 112 |
postbox = Plugin::GUI::Postbox.instance |
| 113 |
postbox.options = options |
| 114 |
self.add_child postbox |
| 115 |
postbox |
| 116 |
end |
| 117 |
|
| 118 |
の部分文字列が選択されている場合それを返す。 |
| 119 |
ていない場合はnilを返す |
| 120 |
|
| 121 |
のインスタンス |
| 122 |
|
| 123 |
れたテキスト |
| 124 |
def selected_text(message) |
| 125 |
result = Plugin.filtering(:gui_timeline_selected_text, self, message, nil) |
| 126 |
result.last if result end |
| 127 |
|
| 128 |
数値で返すブロックを設定する |
| 129 |
|
| 130 |
び順 |
| 131 |
|
| 132 |
|
| 133 |
def order(&block) |
| 134 |
Plugin.call(:gui_timeline_set_order, self, block) |
| 135 |
end |
| 136 |
|
| 137 |
_message_ を繰り返し処理する |
| 138 |
def each(&block) |
| 139 |
if block |
| 140 |
Plugin.collect(:gui_timeline_each_messages, self).each(&block) |
| 141 |
else |
| 142 |
Plugin.collect(:gui_timeline_each_messages, self) |
| 143 |
end |
| 144 |
end |
| 145 |
|
| 146 |
def size |
| 147 |
to_a.size |
| 148 |
end |
| 149 |
|
| 150 |
取得する |
| 151 |
def timeline_max |
| 152 |
Plugin.filtering(:gui_timeline_get_timeline_max, self, nil)[1] || UserConfig[:timeline_max] |
| 153 |
end |
| 154 |
|
| 155 |
設定する |
| 156 |
def timeline_max=(n) |
| 157 |
Plugin.filtering(:gui_timeline_set_timeline_max, self, n) |
| 158 |
end |
| 159 |
end |