Skip to content

Instantly share code, notes, and snippets.

@cobodo

cobodo/timeline_dam.rb

Last active Nov 9, 2018
Embed
What would you like to do?
スクロール位置が一定値より下なら、古いメッセージを消さないようにするmikutterプラグイン。
Plugin.create(:timeline_dam) do
UserConfig[:timeline_dam_criteria] ||= 80
unless Gtk::TimeLine.method_defined?(:timeline_dam_original_add)
class Gtk::TimeLine
alias :timeline_dam_original_add :_add
def _add(message)
@timeline_max ||= UserConfig[:timeline_max]
criteria = UserConfig[:timeline_dam_criteria] / 100.0
if @tl.vadjustment.value < criteria
@timeline_max = [@timeline_max * criteria, UserConfig[:timeline_max]].max
elsif size >= @timeline_max
@timeline_max += 1
end
timeline_dam_original_add(message)
end
end
end
settings "TLダム" do
adjustment "スクロール位置の割合が右のパーセンテージ以上ならメッセージの削除をやめる", :timeline_dam_criteria, 0, 100
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment