beautify.tin 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #var lib_ui_beautify[META] {
  2. {NAME} {美化插件}
  3. {DESC} {美化你的 TinTin++,对齐你的表格。}
  4. {AUTHOR} {担子炮}
  5. };
  6. #func {lib_ui_beautify.Init} {
  7. #class data/lib/ui/beautify open;
  8. #var beautify-switch {OFF};
  9. #var beautify-eol-mark {<299><g03>.};
  10. #class data/lib/ui/beautify close;
  11. beautify.On;
  12. #return true;
  13. };
  14. #var beautify-table {
  15. {┌|┎|╭|╓|└|┖|╰|╙} {─}
  16. {─|┬|┭|┰|┱|╥} {─}
  17. {├|┞|┟|┠|╟} {─}
  18. {┼|╁|╀|╂|┽|╃|╅|╉|╫} {─}
  19. {┴|┵|┸|┹|╨} {─}
  20. {┏|┍|┗|┕} {━}
  21. {━|┳|┲|┯|┮} {━}
  22. {┣|┢|┡|┝} {━}
  23. {╋|╇|╈|┿|╊|╆|╄|┾} {━}
  24. {┻|┺|┷|┶} {━}
  25. {╔|╦|╠|╬|╚|╩|═|╒|╤|╞|╪|╘|╧} {═}
  26. {│|┃|║|┆|┇|┊|┋|┤|┨|┫|╣|╢|╡|▕} {left-align}
  27. {┐|┓|┒|╮|╗|┘|┛|┚|╯|╝|╲|╱|∕} {left-align}
  28. {■|‖|▉|▊|▋|▌|▍|▎|▏|◢|◣|◥|◤|▓} {left-align}
  29. {▁|▂|▃|▄|▅|▆|▇|█|▀|▔|┄|┅|┈|┉|—|ˉ} {double}
  30. {▼|▲|△|▽|□|◇|◆|☆|★} {left-align}
  31. {•|◎|⊙|☉|○|●|Θ|⊕|Ο} {left-align}
  32. {·|∶|∴|∷|˙|¨|ō|ó|ǒ|ò} {left-align}
  33. {≤|≧|≥|≮|≯|∨|∧|≌|╳|×} {left-align}
  34. {↙|↘|↗|↖|←|↑|→|↓} {left-align}
  35. {※|Ψ|Ж|ξ|ф|∩|⊥|♀|∞|≈|√|⌒|Ω|¤||ψ|ζ|∽} {left-align}
  36. {①|②|③|④|⑤|⑥|⑦|⑧|⑨|⑩} {left-align}
  37. {“|‘} {right-align}
  38. {”|’|…} {left-align}
  39. {⭕️|🐎|🌊|🔥|🎭|🐀|🔅} {left-align}
  40. };
  41. option.Define {HighlightBlue} {Bool} {是否加亮幽蓝色} {true};
  42. #alias {beautify.On} {
  43. #class beautify-sub kill;
  44. #class beautify-sub open;
  45. #local charset {};
  46. #foreach {*{beautify-table[]}} {charset} {
  47. #local type {${beautify-table[$charset]}};
  48. #switch {"$type"} {
  49. #case {"double"} {#substitute {{$charset}} {%%1%%1}};
  50. #case {"left-align"} {#substitute {{$charset}} {%%1 }};
  51. #case {"right-align"} {#substitute {{$charset}} { %%1}};
  52. #default {#line sub var #substitute {{$charset}} {%%1$type}};
  53. };
  54. };
  55. #substitute {%S%!s{https?://[[:graph:]]+}\s*{\S|$}} {%%1 %%2 %%3};
  56. #nop 行尾空格因为肉眼不可见因此常常导致无法匹配触发。这里把它可视化一下。;
  57. #action {~^%*%+1S%+1..s%c{|ID=beautify}$} {
  58. #line ignore #showme {@Beautify{{%%1%%2%%3}}$beautify-eol-mark};
  59. #line gag;
  60. } {9.999};
  61. #subst {~\e[34m} {@if{@option.IsEnable{HighlightBlue};\e[94m;\e[34m}};
  62. #class beautify-sub close;
  63. #var beautify-switch {ON};
  64. okLog 宽字符美化已启用。;
  65. warnLog 出于美化需要,接下来你在屏幕上看到的内容可能和服务器实际传送的内容不一致。;
  66. warnLog 这可能会给编写触发带来困扰,此时你可以通过快捷键或者 beautify.Off 暂时禁用美化。;
  67. prompt.Set {{beautify}{<129>已启用}};
  68. prompt.refresh;
  69. };
  70. #alias {beautify.Off} {
  71. #class beautify-sub kill;
  72. #var beautify-switch {OFF};
  73. warnLog 宽字符美化已禁用。你可以通过快捷键或者 beautify.On 重新启用。;
  74. prompt.Set {{beautify}{<119>已禁用}};
  75. prompt.refresh;
  76. };
  77. #func {Beautify} {
  78. #local text {%1};
  79. #if { "${beautify-switch}" != "ON" } {
  80. #return {$text};
  81. };
  82. #local charset {};
  83. #foreach {*{beautify-table[]}} {charset} {
  84. #local type {${beautify-table[$charset]}};
  85. #switch {"$type"} {
  86. #case {"double"} {#replace {text} {{$charset}} {&1&1}};
  87. #case {"left-align"} {#replace {text} {{$charset}} {&1 }};
  88. #case {"right-align"} {#replace {text} {{$charset}} { &1}};
  89. #default {#line sub var #replace {text} {{$charset}} {&1$type}};
  90. };
  91. };
  92. #return {$text};
  93. };
  94. #alias {beautify.SetEolMark} {
  95. #local mark {%1};
  96. #if { "$mark" == "" } {
  97. #local mark {<g03>.};
  98. };
  99. #var beautify-eol-mark {$mark};
  100. };
  101. #alias {beautify.ToggleSwitch} {
  102. #if { "${beautify-switch}" == "ON" } {
  103. beautify.Off;
  104. };
  105. #else {
  106. beautify.On;
  107. };
  108. };