クリップボードの文字列を、「突然の死」テンプレートに置き換えるやつ
元ネタ
「突然の死」をTwitterへ簡単に送り出せる「突然の死ジェネレータ」 - GIGAZINE
http://gigazine.net/news/20120703-suddenly-death/
突然の死ジェネレータ
クリップボードの文字列を、「突然の死」テンプレートに置き換えます(マルチライン対応)。
Totsuzen.fs
open System open System.Text open System.Windows.Forms let rc = "\r\n" let length s = Encoding.GetEncoding(932).GetByteCount(s:string) |> fun len -> if len % 2 = 1 then (len + 1) / 2 else len / 2 let split (separator:string) (text:string) = text.Split([|separator|], StringSplitOptions.None) let repeat s i = [1..i] |> Seq.map (fun _ -> s) |> Seq.fold (+) "" let width f lines = lines |> Seq.map(fun s -> f s) |> Seq.max let centerAlign lines = let f line = let len = length line let lw, rw, pad = let maxw = width length lines let lw = (maxw - len) / 2 lw, maxw - lw - len, repeat " " pad lw + line + pad rw lines |> Seq.map f let border lines = let header = "_" + repeat "人" (width length lines + 2) + "_" let footer = " ̄" + repeat "Y^" (width length lines) + "Y ̄" let side lines = let f line = "> " + line + " <" + rc Seq.map f lines |> Seq.reduce (+) header + rc + (centerAlign lines |> side) + footer [<STAThread>] [<EntryPoint>] let main args = let (!) = function | "" -> "突然の死" | s -> s !Clipboard.GetText() |> split rc |> border |> Clipboard.SetText 0
_人人人人人人人人人人人人_ > 暇つぶしにちょっと < > やってみたかっただけ <  ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ̄
とてもゴガツビョウです\(^o^)/