機能 #1250 » 0003-change_remain_charcount_options.patch
core/mui/gtk_postbox.rb | ||
---|---|---|
def post_it
|
||
if postable?
|
||
return unless before_post
|
||
text = widget_post.buffer.text
|
||
text += UserConfig[:footer] if use_blind_footer?
|
||
@posting = Plugin[:gtk].compose(
|
||
current_world,
|
||
to_display_only? ? nil : @to.first,
|
||
body: text,
|
||
visibility: @visibility
|
||
**compose_options
|
||
).next{
|
||
destroy
|
||
}.trap{ |err|
|
||
... | ... | |
def remain_charcount
|
||
if not widget_post.destroyed?
|
||
current_world, = Plugin.filtering(:world_current, nil)
|
||
Plugin[:gtk].spell(:remain_charcount, current_world, text: widget_post.buffer.text + UserConfig[:footer])
|
||
Plugin[:gtk].spell(:remain_charcount, current_world, **compose_options)
|
||
end
|
||
end
|
||
... | ... | |
visibility: @visibility,
|
||
**@options } end
|
||
# compose Spellを呼び出す際のオプションを返す
|
||
# ==== Return
|
||
# Hash
|
||
def compose_options
|
||
text = widget_post.buffer.text
|
||
text += UserConfig[:footer] if use_blind_footer?
|
||
{
|
||
body: text,
|
||
visibility: @visibility
|
||
}
|
||
end
|
||
# 真を返すなら、 @to の要素はPostBoxの下に表示するのみで、投稿時にリプライにしない
|
||
# ==== Return
|
||
# TrueClass|FalseClass
|
core/plugin/twitter/twitter.rb | ||
---|---|---|
}
|
||
end
|
||
defspell(:remain_charcount, :twitter) do |twitter, text:|
|
||
text = trim_hidden_regions(text)
|
||
Twitter::TwitterText::Extractor.extract_urls(text).map{|url|
|
||
defspell(:remain_charcount, :twitter) do |twitter, body:|
|
||
body = trim_hidden_regions(body)
|
||
Twitter::TwitterText::Extractor.extract_urls(body).map{|url|
|
||
posted_url_length = Plugin.filtering(:tco_url_length, url, 0).last
|
||
if url.length < posted_url_length
|
||
-(posted_url_length - url.length)
|
||
else
|
||
url.length - posted_url_length
|
||
end
|
||
}.inject(140 - text.size, &:+)
|
||
}.inject(140 - body.size, &:+)
|
||
end
|
||
def trim_hidden_regions(text)
|