--- lbbs/include/menu.h 2025/05/19 06:26:07 1.21 +++ lbbs/include/menu.h 2026/01/03 10:27:14 1.37 @@ -1,39 +1,33 @@ -/*************************************************************************** - menu.h - description - ------------------- - Copyright : (C) 2004-2025 by Leaflet - Email : leaflet@leafok.com - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * menu + * - configurable user interactive menu feature + * + * Copyright (C) 2004-2026 Leaflet + */ #ifndef _MENU_H_ #define _MENU_H_ +#include "bbs_cmd.h" #include "common.h" #include "trie_dict.h" -#include "bbs_cmd.h" #include -#include -#define MAX_MENU_NAME_LENGTH 30 -#define MAX_ITEMS_PER_MENU 256 -#define MAX_MENUITEM_NAME_LENGTH 256 -#define MAX_MENUITEM_TEXT_LENGTH 100 -#define MAX_MENUITEM_ACTION_LENGTH 30 -#define MAX_MENUTITLE_TEXT_LENGTH 50 -#define MAX_MENU_SCR_NAME_LENGTH 20 -#define MAX_MENU_SCR_BUF_LENGTH 2000 -#define MAX_MENUS 256 -#define MAX_MENUITEMS 5120 -#define MAX_MENU_DEPTH 50 +enum menu_constant_t +{ + MAX_MENU_NAME_LENGTH = 30, + MAX_ITEMS_PER_MENU = 256, + MAX_MENUITEM_NAME_LENGTH = 256, + MAX_MENUITEM_TEXT_LENGTH = 200, + MAX_MENUITEM_ACTION_LENGTH = 30, + MAX_MENUTITLE_TEXT_LENGTH = 100, + MAX_MENU_SCR_NAME_LENGTH = 20, + MAX_MENU_SCR_BUF_LENGTH = 2000, + MAX_MENUS = 256, + MAX_MENUITEMS = 5120, + MAX_MENU_DEPTH = 50, +}; typedef uint64_t MENU_ID; typedef uint64_t MENU_ITEM_ID; @@ -80,12 +74,15 @@ struct menu_t int16_t item_count; int16_t page_row, page_col; int16_t page_item_limit; + int8_t use_filter; + bbs_cmd_handler filter_handler; }; typedef struct menu_t MENU; struct menu_set_t { - int shmid; + char shm_name[FILE_NAME_LEN]; + size_t shm_size; void *p_reserved; void *p_menu_pool; void *p_menu_item_pool; @@ -104,17 +101,21 @@ struct menu_set_t int16_t menu_item_r_row[MAX_ITEMS_PER_MENU]; int16_t menu_item_r_col[MAX_ITEMS_PER_MENU]; int16_t menu_item_page_id[MAX_ITEMS_PER_MENU]; + int8_t allow_exit; }; typedef struct menu_set_t MENU_SET; -extern MENU_SET *p_bbs_menu; +extern MENU_SET bbs_menu; +extern MENU_SET top10_menu; extern int load_menu(MENU_SET *p_menu_set, const char *conf_file); extern int unload_menu(MENU_SET *p_menu_set); -extern int load_menu_shm(MENU_SET *p_menu_set); -extern int unload_menu_shm(MENU_SET *p_menu_set); +extern int get_menu_shm_readonly(MENU_SET *p_menu_set); +extern int set_menu_shm_readonly(MENU_SET *p_menu_set); +extern int detach_menu_shm(MENU_SET *p_menu_set); +extern int display_menu_cursor(MENU_SET *p_menu_set, int show); extern int menu_control(MENU_SET *p_menu_set, int key); extern int display_menu(MENU_SET *p_menu_set); @@ -134,7 +135,7 @@ inline MENU *get_menu_by_id(MENU_SET *p_ return NULL; } - return (p_menu_set->p_menu_pool + sizeof(MENU) * menu_id); + return (MENU *)((char *)(p_menu_set->p_menu_pool) + sizeof(MENU) * menu_id); } inline MENU_ITEM *get_menu_item_by_id(MENU_SET *p_menu_set, MENU_ITEM_ID menu_item_id) @@ -144,7 +145,7 @@ inline MENU_ITEM *get_menu_item_by_id(ME return NULL; } - return (p_menu_set->p_menu_item_pool + sizeof(MENU_ITEM) * menu_item_id); + return (MENU_ITEM *)((char *)(p_menu_set->p_menu_item_pool) + sizeof(MENU_ITEM) * menu_item_id); } inline MENU_SCREEN *get_menu_screen_by_id(MENU_SET *p_menu_set, MENU_SCREEN_ID menu_screen_id) @@ -154,7 +155,7 @@ inline MENU_SCREEN *get_menu_screen_by_i return NULL; } - return (p_menu_set->p_menu_screen_pool + sizeof(MENU_ITEM) * menu_screen_id); + return (MENU_SCREEN *)((char *)(p_menu_set->p_menu_screen_pool) + sizeof(MENU_ITEM) * menu_screen_id); } #endif //_MENU_H_