2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __STC_IPT_MENU_H__
18 #define __STC_IPT_MENU_H__
22 #define LOG_END "\e[0m"
24 #define LOG_BLACK "\e[0;30m"
25 #define LOG_RED "\e[0;31m"
26 #define LOG_GREEN "\e[0;32m"
27 #define LOG_BROWN "\e[0;33m"
28 #define LOG_BLUE "\e[0;34m"
29 #define LOG_MAGENTA "\e[0;35m"
30 #define LOG_CYAN "\e[0;36m"
31 #define LOG_LIGHTGRAY "\e[0;37m"
33 #define LOG_DARKGRAY "\e[1;30m"
34 #define LOG_LIGHTRED "\e[1;31m"
35 #define LOG_LIGHTGREEN "\e[1;32m"
36 #define LOG_YELLOW "\e[1;33m"
37 #define LOG_LIGHTBLUE "\e[1;34m"
38 #define LOG_LIGHTMAGENTA "\e[1;35m"
39 #define LOG_LIGHTCYAN "\e[1;36m"
40 #define LOG_WHITE "\e[1;37m"
43 #define msg(fmt,args...) do { fprintf(stdout, fmt "\n", ##args); \
44 fflush(stdout); } while (0)
45 #define msgn(fmt,args...) do { fprintf(stdout, fmt, ##args); \
46 fflush(stdout); } while (0)
49 #define msgb(fmt,args...) do { fprintf(stdout, LOG_LIGHTGREEN fmt \
50 LOG_END "\n", ##args); fflush(stdout); } while (0)
52 /* Property message */
53 #define msgp(fmt,args...) do { fprintf(stdout, LOG_LIGHTMAGENTA fmt \
54 LOG_END "\n", ##args); fflush(stdout); } while (0)
56 #define msgt(n,fmt,args...) do { fprintf(stdout, "\e[%dC" fmt "\n", \
57 3 + ((n) * 2), ##args); fflush(stdout); } while (0)
59 #define pmsg(fmt,args...) do { \
60 if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
61 fprintf(stdout, fmt "\n", ##args); fflush(stdout); } while (0)
63 #define pmsgb(fmt,args...) do { \
64 if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
65 fprintf(stdout, LOG_LIGHTGREEN fmt \
66 LOG_END "\n", ##args); fflush(stdout); } while (0)
68 #define pmsgt(n,fmt,args...) do { \
69 if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
70 fprintf(stdout, "\e[%dC" fmt "\n", \
71 3 + ((n) * 2), ##args); fflush(stdout); } while (0)
73 #define MENU_DATA_SIZE 255
78 * Horizontal Line - width: 65
79 * .12345678901234567890123456789012345678901234567890.
81 #define HR_SINGLE "----------------------------------------" \
82 "-------------------------"
83 #define HR_DOUBLE "========================================" \
84 "========================="
85 #define HR_SINGLE2 " ---------------------------------------" \
86 "------------------------ "
88 #define MAX_WIDTH strlen (HR_SINGLE)
89 #define MAX_TITLE ((MAX_WIDTH) - 10)
90 #define POS_MORE ((MAX_WIDTH) - 3)
92 #define RET_FAILURE -1
94 typedef struct menu_manager MManager;
99 struct menu_data *sub_menu;
100 int (*callback)(MManager *mm, struct menu_data *menu);
104 MManager* menu_manager_new(struct menu_data items[], GMainLoop *mainloop);
105 int menu_manager_run(MManager *mm);
106 int menu_manager_set_user_data(MManager *mm, void *user_data);
107 void* menu_manager_ref_user_data(MManager *mm);
109 gboolean on_menu_manager_keyboard(GIOChannel *src, GIOCondition con,
116 void menu_print_dump(int data_len, void *data);
120 #endif /* __STC_IPT_MENU_H__ */