pretty.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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_WHITE 35
  27. #define FG_LIGHTBLUE 36
  28. #define BG_BLACK 40
  29. #define BG_RED 41
  30. #define BG_GREEN 42
  31. #define BG_YELLOW 43
  32. #define BG_BLUE 44
  33. #define BG_WHITE 47
  34. #define MODE_DEFAULT 0
  35. #define MODE_HIGHLIGHT 1
  36. #define MODE_LINE 4
  37. #define ansi_csi_st(strm, m, fg, bg) \
  38. fprintf(strm, "\033[%d;%d;%dm", m, fg, bg)
  39. #define ansi_csi_ed(strm) \
  40. fprintf(strm, "\033[0m")
  41. #define setcolor(strm, c) \
  42. ansi_csi_st(strm, (c)->mode, (c)->fg, (c)->bg)
  43. struct color {
  44. int fg;
  45. int bg;
  46. int mode;
  47. };
  48. struct theme {
  49. struct color usrname,
  50. sysusername,
  51. msg,
  52. sysmsg,
  53. time,
  54. errmsg,
  55. helpcmd,
  56. helpmsg;
  57. };
  58. int pretty_new_msg(char *usrname, char *msg);
  59. int pretty_prompt(char *usrname);
  60. int pretty_unknow_cmd(char *cmd);
  61. int pretty_cmd_help(char *cmd, char *msg);
  62. #endif