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