nconf.h 1.9 KB

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