Skip to content

Instantly share code, notes, and snippets.

@primenumber
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save primenumber/df71429a1a9a8c23d450 to your computer and use it in GitHub Desktop.
Save primenumber/df71429a1a9a8c23d450 to your computer and use it in GitHub Desktop.
勝手に短冊になるmikutterプラグイン
#-*- coding: utf-8
Plugin.create(:tanzaku) do
filter_gui_postbox_post do |gui_postbox|
buf = Plugin.create(:gtk).widgetof(gui_postbox).widget_post.buffer
text = buf.text
str = "┏┷┓\n┃ ┃\n┃"
text.each_char {|char| str += char + "┃\n┃"}
str += " ┃\n┗━┛\n"
buf.text = str
[gui_postbox]
end
end
@nna774
Copy link

nna774 commented Jul 6, 2014

#-*- coding: utf-8

Plugin.create(:tanzaku) do
  UserConfig[:tanzaku_ni_suru] ||= true

  settings "短冊" do
    boolean '短冊にする', :tanzaku_ni_suru
  end 
  filter_gui_postbox_post do |gui_postbox|
    buf = Plugin.create(:gtk).widgetof(gui_postbox).widget_post.buffer
    text = buf.text
    if UserConfig[:tanzaku_ni_suru]
      str = "┏┷┓\n┃ ┃\n┃"
      text.each_char {|char| str += char + "┃\n┃"}
      str += " ┃\n┗━┛\n"
      buf.text = str
    end
    [gui_postbox]
  end
end

設定つけました

@nna774
Copy link

nna774 commented Jul 6, 2014

#-*- coding: utf-8

Plugin.create(:tanzaku) do
  UserConfig[:tanzaku_ni_suru] ||= true

  settings "短冊" do
    boolean '短冊にする', :tanzaku_ni_suru
  end 
  filter_gui_postbox_post do |gui_postbox|
    buf = Plugin.create(:gtk).widgetof(gui_postbox).widget_post.buffer
    text = buf.text
    if UserConfig[:tanzaku_ni_suru]
      to = nil
      if /^@[a-zA-Z0-9_]* / =~ text
         tmp = text.split(" ", 2)
         to = tmp[0]
         text = tmp[1]
      end
      str = ""
      str = to unless to.nil?
      str += "\n" unless to.nil?
      str += "┏┷┓\n┃ ┃\n┃"
      text.each_char {|char| str += char + "┃\n┃"}
      str += " ┃\n┗━┛\n"
      buf.text = str
    end
    [gui_postbox]
  end
end

リプライだと変更しないようにしました

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment