Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.7 KiB

  1. static Clr **statusscheme;
  2. int
  3. width_pwrl_status(Bar *bar, BarArg *a)
  4. {
  5. #if BAR_STATUSCMD_PATCH
  6. return widthpowerlinestatus(rawstext);
  7. #else
  8. return widthpowerlinestatus(stext);
  9. #endif // BAR_STATUSCMD_PATCH
  10. }
  11. #if BAR_EXTRASTATUS_PATCH
  12. int
  13. width_pwrl_status_es(Bar *bar, BarArg *a)
  14. {
  15. #if BAR_STATUSCMD_PATCH
  16. return widthpowerlinestatus(rawestext);
  17. #else
  18. return widthpowerlinestatus(estext);
  19. #endif // BAR_STATUSCMD_PATCH
  20. }
  21. #endif // BAR_EXTRASTATUS_PATCH
  22. int
  23. draw_pwrl_status(Bar *bar, BarArg *a)
  24. {
  25. #if BAR_STATUSCMD_PATCH
  26. return drawpowerlinestatus(a->x + a->w, rawstext, a);
  27. #else
  28. return drawpowerlinestatus(a->x + a->w, stext, a);
  29. #endif // BAR_STATUSCMD_PATCH
  30. }
  31. #if BAR_EXTRASTATUS_PATCH
  32. int
  33. draw_pwrl_status_es(Bar *bar, BarArg *a)
  34. {
  35. #if BAR_STATUSCMD_PATCH
  36. return drawpowerlinestatus(a->x + a->w, rawestext, a);
  37. #else
  38. return drawpowerlinestatus(a->x + a->w, estext, a);
  39. #endif // BAR_STATUSCMD_PATCH
  40. }
  41. #endif // BAR_EXTRASTATUS_PATCH
  42. int
  43. click_pwrl_status(Bar *bar, Arg *arg, BarArg *a)
  44. {
  45. return ClkStatusText;
  46. }
  47. int
  48. widthpowerlinestatus(char *stext)
  49. {
  50. char status[512];
  51. int w = 0, i, n = strlen(stext);
  52. int plw = drw->fonts->h / 2 + 1;
  53. char *bs, bp = '|';
  54. strcpy(status, stext);
  55. for (i = n, bs = &status[n-1]; i >= 0; i--, bs--) {
  56. if (*bs == '<' || *bs == '/' || *bs == '\\' || *bs == '>' || *bs == '|') { /* block start */
  57. if (bp != '|')
  58. w += plw;
  59. w += TEXTW(bs+2);
  60. bp = *bs;
  61. *bs = 0;
  62. }
  63. }
  64. if (bp != '|')
  65. w += plw * 2;
  66. return w;
  67. }
  68. int
  69. drawpowerlinestatus(int xpos, char *stext, BarArg *barg)
  70. {
  71. char status[512];
  72. int i, n = strlen(stext), cn = 0;
  73. int x = xpos, w = 0;
  74. int plw = drw->fonts->h / 2 + 1;
  75. char *bs, bp = '|';
  76. Clr *prevscheme = statusscheme[0], *nxtscheme;
  77. strcpy(status, stext);
  78. for (i = n, bs = &status[n-1]; i >= 0; i--, bs--) {
  79. if (*bs == '<' || *bs == '/' || *bs == '\\' || *bs == '>' || *bs == '|') { /* block start */
  80. cn = ((int) *(bs+1)) - 1;
  81. if (cn < LENGTH(statuscolors)) {
  82. drw_settrans(drw, prevscheme, (nxtscheme = statusscheme[cn]));
  83. } else {
  84. drw_settrans(drw, prevscheme, (nxtscheme = statusscheme[0]));
  85. }
  86. if (bp != '|') {
  87. drw_arrow(drw, x - plw, barg->y, plw, barg->h, bp == '\\' || bp == '>' ? 1 : 0, bp == '<' ? 0 : 1);
  88. x -= plw;
  89. }
  90. drw_setscheme(drw, nxtscheme);
  91. w = TEXTW(bs+2);
  92. drw_text(drw, x - w, barg->y, w, barg->h, lrpad / 2, bs+2, 0, False);
  93. x -= w;
  94. bp = *bs;
  95. *bs = 0;
  96. prevscheme = nxtscheme;
  97. }
  98. }
  99. if (bp != '|') {
  100. drw_settrans(drw, prevscheme, scheme[SchemeNorm]);
  101. drw_arrow(drw, x - plw, barg->y, plw, barg->h, bp == '\\' || bp == '>' ? 1 : 0, bp == '<' ? 0 : 1);
  102. drw_rect(drw, x - 2 * plw, barg->y, plw, barg->h, 1, 1);
  103. x -= plw * 2;
  104. }
  105. return xpos - x;
  106. }