main.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package main
  2. import (
  3. "fmt"
  4. "git.swzry.com/zry/go-hhc-cli/hhc_common"
  5. "github.com/ttacon/chalk"
  6. )
  7. func main() {
  8. pm := []hhc_common.PrintableMessage{
  9. {
  10. Text: "Hakurei Reimu ",
  11. Style: chalk.Red.NewStyle().WithTextStyle(chalk.Underline),
  12. },
  13. {
  14. Text: "is a girl in gensokyo, ",
  15. Style: chalk.Blue.NewStyle().WithTextStyle(chalk.Italic),
  16. },
  17. {
  18. Text: "she is the miko of ",
  19. Style: chalk.Cyan.NewStyle(),
  20. },
  21. {
  22. Text: "Hakurei Shirine ",
  23. Style: chalk.Green.NewStyle().WithTextStyle(chalk.Bold),
  24. },
  25. {
  26. Text: ". She loves money and has no ",
  27. Style: chalk.White.NewStyle(),
  28. },
  29. {
  30. Text: "ethics.",
  31. Style: chalk.Magenta.NewStyle(),
  32. },
  33. {
  34. Text: "博丽灵梦",
  35. Style: chalk.Red.NewStyle().WithTextStyle(chalk.Underline),
  36. },
  37. {
  38. Text: "是一个幻想乡中的女孩,",
  39. Style: chalk.Blue.NewStyle().WithTextStyle(chalk.Italic),
  40. },
  41. {
  42. Text: "她是",
  43. Style: chalk.Cyan.NewStyle(),
  44. },
  45. {
  46. Text: "博丽神社",
  47. Style: chalk.Green.NewStyle().WithTextStyle(chalk.Bold),
  48. },
  49. {
  50. Text: "的一名巫女,她喜欢钱而且没有",
  51. Style: chalk.White.NewStyle(),
  52. },
  53. {
  54. Text: "节操。",
  55. Style: chalk.Magenta.NewStyle(),
  56. },
  57. }
  58. Pr(80, true, pm)
  59. Pr(80, false, pm)
  60. Pr(40, true, pm)
  61. Pr(40, false, pm)
  62. Pr(20, true, pm)
  63. Pr(20, false, pm)
  64. Pr(10, true, pm)
  65. Pr(10, false, pm)
  66. Pr(1, true, pm)
  67. Pr(1, false, pm)
  68. fmt.Println("=====================================")
  69. test2 := "Hakurei Reimu is a girl in gensokyo, she is the miko of Hakurei Shirine . She loves money and has no ethics. 博丽灵梦是一个幻想乡中的女孩,她是博丽神社的一名巫女,她喜欢钱而且没有节操。"
  70. Ps(80, test2)
  71. Ps(40, test2)
  72. Ps(20, test2)
  73. Ps(10, test2)
  74. Ps(1, test2)
  75. }
  76. func Pr(w int, c bool, pms []hhc_common.PrintableMessage) {
  77. lines := hhc_common.PrintPrintablMessagesIntoLines(pms, w, c)
  78. fmt.Println("TermWidth", w, "Colorful", c)
  79. for _, v := range lines {
  80. fmt.Println(v)
  81. }
  82. }
  83. func Ps(w int, s string) {
  84. lines := hhc_common.PrintStringIntoLines(s, w)
  85. fmt.Println("TermWidth", w)
  86. for _, v := range lines {
  87. fmt.Println(v)
  88. }
  89. }