tmux.tin 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #alias {tmux.UpdateCharData} {
  2. #if { "$char[档案][账号]" == "" } {
  3. #return;
  4. };
  5. #local id {#[fg=brightwhite]$char[档案][账号]#[default]};
  6. #local name {$char[档案][彩色大名]};
  7. #if { "$name" == "" } {#local name {$char[档案][大名]}};
  8. #local name {@tmux.ConvertFromANSI{{$name}}};
  9. #local title {$char[档案][彩色头衔]};
  10. #if { "$title" == "" } {#local title {$char[档案][头衔]}};
  11. #local title {@tmux.ConvertFromANSI{{$title}}};
  12. #local file {tmux/$char[档案][账号]/char-data};
  13. #script {tmp} {echo "ID: [$id] 大名: [$name] 头衔: [$title]" > $file};
  14. #script {tmp} {tmux refresh};
  15. };
  16. #function {tmux.ConvertFromANSI} {
  17. #local title {%1};
  18. #local {mode} {TEXT};
  19. #local output {};
  20. #local pending {};
  21. #local ch {};
  22. #parse {$title} {ch} {
  23. #switch {"$mode"} {
  24. #case {"TEXT"} {
  25. #switch {"$ch"} {
  26. #case {"\e"} {#local mode {ESC}};
  27. #case {";"} {#cat output { }};
  28. #default {#cat output {$ch}};
  29. };
  30. };
  31. #case {"ESC"} {
  32. #switch {"$ch"} {
  33. #case {"["} {#cat output {#[}; #local mode {SGR}};
  34. #default {#cat output {$ch}; #local mode {TEXT}};
  35. };
  36. };
  37. #case {"SGR"} {
  38. #switch {"$ch"} {
  39. #case {"0"} {#cat output {default}};
  40. #case {"1"} {#cat output {bold}};
  41. #case {"2"} {#cat output {dim}};
  42. #case {"3"} {#local mode {PENDING3}};
  43. #case {"4"} {#local mode {PENDING4}};
  44. #case {"5"} {#cat output {blink}};
  45. #case {";"} {#cat output { }};
  46. #default {
  47. #if { "$pending" == "[" } {#cat output {default}};
  48. #cat output {]};
  49. #local mode {TEXT};
  50. };
  51. };
  52. };
  53. #case {"PENDING3"} {
  54. #switch {"$ch"} {
  55. #case {"%d"} {#cat output {fg=colour$ch}; #local mode {SGR}};
  56. #case {";"} {#cat output {italics }; #local mode {SGR}};
  57. #case {"m"} {#cat output {italics]}; #local mode {TEXT}};
  58. #default {#cat output {$ch]}; #local mode {TEXT}};
  59. };
  60. };
  61. #case {"PENDING4"} {
  62. #switch {"$ch"} {
  63. #case {"%d"} {#cat output {bg=colour$ch}; #local mode {SGR}};
  64. #case {";"} {#cat output {underscore }; #local mode {SGR}};
  65. #case {"m"} {#cat output {underscore]}; #local mode {TEXT}};
  66. #default {#cat output {$ch]}; #local mode {TEXT}};
  67. };
  68. };
  69. };
  70. #local {pending} {$ch};
  71. };
  72. #return {$output};
  73. };
  74. load-lib event;
  75. event.Handle {char/status} {tmux} {ui} {tmux.UpdateCharData};