nconf.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
  3. * Released under the terms of the GNU GPL v2.0.
  4. *
  5. * Derived from menuconfig.
  6. *
  7. */
  8. #include <ctype.h>
  9. #include <errno.h>
  10. #include <fcntl.h>
  11. #include <limits.h>
  12. #include <stdarg.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include <unistd.h>
  16. #include <locale.h>
  17. #include <ncurses.h>
  18. #include <menu.h>
  19. #include <panel.h>
  20. #include <form.h>
  21. #include <stdio.h>
  22. #include <time.h>
  23. #include <sys/time.h>
  24. #define max(a, b) ({\
  25. typeof(a) _a = a;\
  26. typeof(b) _b = b;\
  27. _a > _b ? _a : _b; })
  28. #define min(a, b) ({\
  29. typeof(a) _a = a;\
  30. typeof(b) _b = b;\
  31. _a < _b ? _a : _b; })
  32. typedef enum {
  33. NORMAL = 1,
  34. MAIN_HEADING,
  35. MAIN_MENU_BOX,
  36. MAIN_MENU_FORE,
  37. MAIN_MENU_BACK,
  38. MAIN_MENU_GREY,
  39. MAIN_MENU_HEADING,
  40. SCROLLWIN_TEXT,
  41. SCROLLWIN_HEADING,
  42. SCROLLWIN_BOX,
  43. DIALOG_TEXT,
  44. DIALOG_MENU_FORE,
  45. DIALOG_MENU_BACK,
  46. DIALOG_BOX,
  47. INPUT_BOX,
  48. INPUT_HEADING,
  49. INPUT_TEXT,
  50. INPUT_FIELD,
  51. FUNCTION_TEXT,
  52. FUNCTION_HIGHLIGHT,
  53. ATTR_MAX
  54. } attributes_t;
  55. extern attributes_t attributes[];
  56. typedef enum {
  57. F_HELP = 1,
  58. F_SYMBOL = 2,
  59. F_INSTS = 3,
  60. F_CONF = 4,
  61. F_BACK = 5,
  62. F_SAVE = 6,
  63. F_LOAD = 7,
  64. F_SEARCH = 8,
  65. F_EXIT = 9,
  66. } function_key;
  67. void set_colors(void);
  68. /* this changes the windows attributes !!! */
  69. void print_in_middle(WINDOW *win,
  70. int starty,
  71. int startx,
  72. int width,
  73. const char *string,
  74. chtype color);
  75. int get_line_length(const char *line);
  76. int get_line_no(const char *text);
  77. const char *get_line(const char *text, int line_no);
  78. void fill_window(WINDOW *win, const char *text);
  79. int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
  80. int dialog_inputbox(WINDOW *main_window,
  81. const char *title, const char *prompt,
  82. const char *init, char **resultp, int *result_len);
  83. void refresh_all_windows(WINDOW *main_window);
  84. void show_scroll_win(WINDOW *main_window,
  85. const char *title,
  86. const char *text);