プロジェクト

全般

プロフィール

機能 #1250 » 0003-change_remain_charcount_options.patch

Shibafu Midorino, 2018-05-21 23:27

差分を表示:

core/mui/gtk_postbox.rb
163 163
    def post_it
164 164
      if postable?
165 165
        return unless before_post
166
        text = widget_post.buffer.text
167
        text += UserConfig[:footer] if use_blind_footer?
168 166
        @posting = Plugin[:gtk].compose(
169 167
          current_world,
170 168
          to_display_only? ? nil : @to.first,
171
          body: text,
172
          visibility: @visibility
169
          **compose_options
173 170
        ).next{
174 171
          destroy
175 172
        }.trap{ |err|
......
326 323
    def remain_charcount
327 324
      if not widget_post.destroyed?
328 325
        current_world, = Plugin.filtering(:world_current, nil)
329
        Plugin[:gtk].spell(:remain_charcount, current_world, text: widget_post.buffer.text + UserConfig[:footer])
326
        Plugin[:gtk].spell(:remain_charcount, current_world, **compose_options)
330 327
      end
331 328
    end
332 329

  
......
374 371
        visibility: @visibility,
375 372
        **@options } end
376 373

  
374
    # compose Spellを呼び出す際のオプションを返す
375
    # ==== Return
376
    # Hash
377
    def compose_options
378
      text = widget_post.buffer.text
379
      text += UserConfig[:footer] if use_blind_footer?
380
      {
381
        body: text,
382
        visibility: @visibility
383
      }
384
    end
385

  
377 386
    # 真を返すなら、 @to の要素はPostBoxの下に表示するのみで、投稿時にリプライにしない
378 387
    # ==== Return
379 388
    # TrueClass|FalseClass
core/plugin/twitter/twitter.rb
239 239
    }
240 240
  end
241 241

  
242
  defspell(:remain_charcount, :twitter) do |twitter, text:|
243
    text = trim_hidden_regions(text)
244
    Twitter::TwitterText::Extractor.extract_urls(text).map{|url|
242
  defspell(:remain_charcount, :twitter) do |twitter, body:|
243
    body = trim_hidden_regions(body)
244
    Twitter::TwitterText::Extractor.extract_urls(body).map{|url|
245 245
      posted_url_length = Plugin.filtering(:tco_url_length, url, 0).last
246 246
      if url.length < posted_url_length
247 247
        -(posted_url_length - url.length)
248 248
      else
249 249
        url.length - posted_url_length
250 250
      end
251
    }.inject(140 - text.size, &:+)
251
    }.inject(140 - body.size, &:+)
252 252
  end
253 253

  
254 254
  def trim_hidden_regions(text)
(3-3/3)