pretty.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* vccd/include/vcc/pretty.h
  2. *
  3. * This file is part of vcc.
  4. *
  5. * vcc is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * vcc is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with vcc. If not, see <https://www.gnu.org/licenses/>
  17. */
  18. #ifndef __VCC_PRETTY_H
  19. #define __VCC_PRETTY_H
  20. #include <stdio.h>
  21. #define FG_BLACK 30
  22. #define FG_RED 31
  23. #define FG_GREEN 32
  24. #define FG_YELLOW 33
  25. #define FG_BLUE 34
  26. #define FG_MAGENTA 35
  27. #define FG_LIGHTBLUE 36
  28. #define FG_WHITE 37
  29. #define FG_GRAY 90
  30. #define BG_BLACK 40
  31. #define BG_RED 41
  32. #define BG_GREEN 42
  33. #define BG_YELLOW 43
  34. #define BG_BLUE 44
  35. #define BG_MAGENTA 45
  36. #define BG_LIGHTBLUE 46
  37. #define BG_WHITE 47
  38. #define BG_GRAY 100
  39. #define MODE_DEFAULT 0
  40. #define MODE_HIGHLIGHT 1
  41. #define MODE_LINE 4
  42. #define ansi_csi_st(strm, m, fg, bg) \
  43. fprintf(strm, "\033[%d;%d;%dm", m, fg, bg)
  44. #define ansi_csi_ed(strm) \
  45. fprintf(strm, "\033[0m")
  46. #define setcolor(strm, c) \
  47. ansi_csi_st(strm, (c)->mode, (c)->fg, (c)->bg)
  48. struct color {
  49. int fg;
  50. int bg;
  51. int mode;
  52. };
  53. struct theme {
  54. struct color usrname,
  55. sysusername,
  56. msg,
  57. sysmsg,
  58. time,
  59. errmsg,
  60. helpcmd,
  61. helpmsg;
  62. };
  63. int pretty_new_msg(char *usrname, char *msg);
  64. int pretty_prompt(char *usrname);
  65. int pretty_unknow_cmd(char *cmd);
  66. int pretty_cmd_help(char *cmd, char *msg);
  67. #endif