Skip to content

Instantly share code, notes, and snippets.

@cobodo
Last active November 9, 2018 10:14
Show Gist options
  • Save cobodo/177a59544b5ed9b3d480b4c374014fea to your computer and use it in GitHub Desktop.
Save cobodo/177a59544b5ed9b3d480b4c374014fea to your computer and use it in GitHub Desktop.
スクロール位置が一定値より下なら、古いメッセージを消さないようにする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