2014-10-24 22:38:30 +00:00
|
|
|
#ifndef _BEMENU_H_
|
|
|
|
#define _BEMENU_H_
|
|
|
|
|
2020-12-13 00:54:53 +00:00
|
|
|
/*
|
|
|
|
* When using a compiler with support for GNU C extensions (GCC, Clang),
|
|
|
|
* explicitly mark functions shared across library boundaries as visible.
|
|
|
|
*
|
|
|
|
* This is the default visibility and has no effect when compiling with the
|
|
|
|
* default CFLAGS. When compiling with -fvisibility=hidden, however, this
|
|
|
|
* exports only functions marked BM_PUBLIC and hides all others.
|
|
|
|
*
|
|
|
|
* https://gcc.gnu.org/wiki/Visibility
|
|
|
|
*/
|
|
|
|
#if __GNUC__ >= 4
|
|
|
|
# define BM_PUBLIC __attribute__((visibility ("default")))
|
|
|
|
#else
|
|
|
|
# define BM_PUBLIC
|
|
|
|
#endif
|
|
|
|
|
2014-03-28 19:33:20 +00:00
|
|
|
/**
|
|
|
|
* @file bemenu.h
|
|
|
|
*
|
2014-04-10 14:26:42 +00:00
|
|
|
* Public API header.
|
2014-03-28 19:33:20 +00:00
|
|
|
*/
|
|
|
|
|
2014-10-22 19:46:51 +00:00
|
|
|
struct bm_renderer;
|
|
|
|
struct bm_menu;
|
|
|
|
struct bm_item;
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2014-04-10 14:26:42 +00:00
|
|
|
|
2014-04-12 21:12:31 +00:00
|
|
|
/**
|
|
|
|
* @defgroup Library
|
|
|
|
* @brief Library functions.
|
|
|
|
*
|
|
|
|
* Query library version, etc...
|
|
|
|
*/
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/**
|
|
|
|
* @defgroup Menu
|
|
|
|
* @brief Menu container.
|
|
|
|
*
|
|
|
|
* Holds all the items, runs logic and gets rendered.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup Item
|
|
|
|
* @brief Item container.
|
|
|
|
*
|
|
|
|
* Contains properties for visual representation of item.
|
|
|
|
*/
|
|
|
|
|
2014-04-12 19:12:44 +00:00
|
|
|
/**
|
2014-04-12 21:12:31 +00:00
|
|
|
* @addtogroup Library
|
2014-04-12 19:12:44 +00:00
|
|
|
* @{ */
|
|
|
|
|
2014-10-22 19:46:51 +00:00
|
|
|
/**
|
|
|
|
* @name Library Initialization
|
|
|
|
* @{ */
|
|
|
|
|
|
|
|
/**
|
2015-01-17 16:53:29 +00:00
|
|
|
* Init bemenu, loads up the renderers.
|
|
|
|
*
|
|
|
|
* You can force single renderer with BEMENU_RENDERER env variable,
|
|
|
|
* and directory containing renderers with BEMENU_RENDERERS env variable.
|
2014-10-22 19:46:51 +00:00
|
|
|
*
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_init(void);
|
2014-10-22 19:46:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get list of available renderers.
|
|
|
|
*
|
|
|
|
* @param out_nmemb Reference to uint32_t where total count of returned renderers will be stored.
|
|
|
|
* @return Pointer to array of bm_renderer instances.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC const struct bm_renderer** bm_get_renderers(uint32_t *out_nmemb);
|
2014-10-22 19:46:51 +00:00
|
|
|
|
|
|
|
/** @} Library Initialization */
|
|
|
|
|
2014-04-12 19:12:44 +00:00
|
|
|
/**
|
|
|
|
* @name Library Version
|
|
|
|
* @{ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get version of the library in 'major.minor.patch' format.
|
|
|
|
*
|
|
|
|
* @see @link http://semver.org/ Semantic Versioning @endlink
|
|
|
|
*
|
|
|
|
* @return Null terminated C "string" to version string.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC const char* bm_version(void);
|
2014-04-12 19:12:44 +00:00
|
|
|
|
|
|
|
/** @} Library Version */
|
|
|
|
|
|
|
|
/** @} Library */
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* @addtogroup Renderer
|
2014-04-10 14:26:42 +00:00
|
|
|
* @{ */
|
|
|
|
|
2014-10-24 22:38:30 +00:00
|
|
|
/**
|
|
|
|
* Prioritories for renderer plugins.
|
|
|
|
*/
|
2015-01-17 16:53:29 +00:00
|
|
|
enum bm_priorty {
|
2014-10-24 22:38:30 +00:00
|
|
|
/**
|
|
|
|
* Renderer runs in terminal.
|
|
|
|
*/
|
|
|
|
BM_PRIO_TERMINAL,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renderer runs in GUI.
|
|
|
|
*/
|
|
|
|
BM_PRIO_GUI,
|
|
|
|
};
|
|
|
|
|
2014-03-28 19:33:20 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get name of the renderer.
|
2014-03-28 19:59:34 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param renderer bm_renderer instance.
|
|
|
|
* @return Null terminated C "string" to renderer's name.
|
2014-03-28 19:33:20 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC const char* bm_renderer_get_name(const struct bm_renderer *renderer);
|
2014-10-22 19:46:51 +00:00
|
|
|
|
2014-10-24 22:38:30 +00:00
|
|
|
/**
|
2015-01-17 16:53:29 +00:00
|
|
|
* Get priorty of the renderer.
|
2014-10-24 22:38:30 +00:00
|
|
|
*
|
|
|
|
* @param renderer bm_renderer instance.
|
2015-01-17 16:53:29 +00:00
|
|
|
* @return bm_priorty enum value.
|
2014-10-24 22:38:30 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC enum bm_priorty bm_renderer_get_priorty(const struct bm_renderer *renderer);
|
2014-10-24 22:38:30 +00:00
|
|
|
|
2014-10-22 19:46:51 +00:00
|
|
|
/**
|
|
|
|
* @} Renderer */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Menu
|
|
|
|
* @{ */
|
2014-03-28 19:33:20 +00:00
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Filter mode constants for bm_menu instance filter mode.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @link ::bm_filter_mode BM_FILTER_MODE_LAST @endlink is provided for enumerating filter modes.
|
2014-04-09 22:09:35 +00:00
|
|
|
* Using it as filter mode however provides exactly same functionality as BM_FILTER_MODE_DMENU.
|
|
|
|
*/
|
2014-10-22 19:46:51 +00:00
|
|
|
enum bm_filter_mode {
|
2014-04-09 22:09:35 +00:00
|
|
|
BM_FILTER_MODE_DMENU,
|
|
|
|
BM_FILTER_MODE_DMENU_CASE_INSENSITIVE,
|
|
|
|
BM_FILTER_MODE_LAST
|
2014-10-22 19:46:51 +00:00
|
|
|
};
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2015-01-18 00:07:30 +00:00
|
|
|
/**
|
|
|
|
* Scrollbar display mode constants for bm_menu instance scrollbar.
|
|
|
|
*
|
2020-06-15 06:01:10 +00:00
|
|
|
* - @link ::bm_scrollbar_mode BM_SCROLLBAR_NONE @endlink means that scrollbar is not displayed.
|
2016-12-03 12:17:47 +00:00
|
|
|
* - @link ::bm_scrollbar_mode BM_SCROLLBAR_ALWAYS @endlink means that scrollbar is displayed always.
|
|
|
|
* - @link ::bm_scrollbar_mode BM_SCROLLBAR_AUTOHIDE @endlink means that scrollbar is only displayed when there are more items than lines.
|
2015-01-18 00:07:30 +00:00
|
|
|
*
|
|
|
|
* @link ::bm_scrollbar_mode BM_SCROLLBAR_LAST @endlink is provided for enumerating scrollbar modes.
|
|
|
|
* Using it as scrollbar mode however provides exactly same functionality as BM_SCROLLBAR_NONE.
|
|
|
|
*/
|
|
|
|
enum bm_scrollbar_mode {
|
|
|
|
BM_SCROLLBAR_NONE,
|
|
|
|
BM_SCROLLBAR_ALWAYS,
|
|
|
|
BM_SCROLLBAR_AUTOHIDE,
|
|
|
|
BM_SCROLLBAR_LAST,
|
|
|
|
};
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Result constants from bm_menu_run_with_key function.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* - @link ::bm_run_result BM_RUN_RESULT_RUNNING @endlink means that menu is running and thus should be still renderer && ran.
|
|
|
|
* - @link ::bm_run_result BM_RUN_RESULT_SELECTED @endlink means that menu was closed and items were selected.
|
|
|
|
* - @link ::bm_run_result BM_RUN_RESULT_CANCEL @endlink means that menu was closed and selection was canceled.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2014-10-22 19:46:51 +00:00
|
|
|
enum bm_run_result {
|
2014-04-09 22:09:35 +00:00
|
|
|
BM_RUN_RESULT_RUNNING,
|
|
|
|
BM_RUN_RESULT_SELECTED,
|
|
|
|
BM_RUN_RESULT_CANCEL,
|
2020-08-03 22:09:40 +00:00
|
|
|
BM_RUN_RESULT_CUSTOM_1,
|
|
|
|
BM_RUN_RESULT_CUSTOM_2,
|
|
|
|
BM_RUN_RESULT_CUSTOM_3,
|
|
|
|
BM_RUN_RESULT_CUSTOM_4,
|
|
|
|
BM_RUN_RESULT_CUSTOM_5,
|
|
|
|
BM_RUN_RESULT_CUSTOM_6,
|
|
|
|
BM_RUN_RESULT_CUSTOM_7,
|
|
|
|
BM_RUN_RESULT_CUSTOM_8,
|
|
|
|
BM_RUN_RESULT_CUSTOM_9,
|
|
|
|
BM_RUN_RESULT_CUSTOM_10,
|
2014-10-22 19:46:51 +00:00
|
|
|
};
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Key constants.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @link ::bm_key BM_KEY_LAST @endlink is provided for enumerating keys.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2014-10-22 19:46:51 +00:00
|
|
|
enum bm_key {
|
2014-04-09 22:09:35 +00:00
|
|
|
BM_KEY_NONE,
|
|
|
|
BM_KEY_UP,
|
|
|
|
BM_KEY_DOWN,
|
|
|
|
BM_KEY_LEFT,
|
|
|
|
BM_KEY_RIGHT,
|
|
|
|
BM_KEY_HOME,
|
|
|
|
BM_KEY_END,
|
|
|
|
BM_KEY_PAGE_UP,
|
|
|
|
BM_KEY_PAGE_DOWN,
|
2014-04-12 15:42:30 +00:00
|
|
|
BM_KEY_SHIFT_PAGE_UP,
|
|
|
|
BM_KEY_SHIFT_PAGE_DOWN,
|
2014-04-09 22:09:35 +00:00
|
|
|
BM_KEY_BACKSPACE,
|
|
|
|
BM_KEY_DELETE,
|
|
|
|
BM_KEY_LINE_DELETE_LEFT,
|
|
|
|
BM_KEY_LINE_DELETE_RIGHT,
|
|
|
|
BM_KEY_WORD_DELETE,
|
|
|
|
BM_KEY_TAB,
|
2014-11-02 02:08:40 +00:00
|
|
|
BM_KEY_SHIFT_TAB,
|
2014-04-09 22:09:35 +00:00
|
|
|
BM_KEY_ESCAPE,
|
|
|
|
BM_KEY_RETURN,
|
2014-04-10 17:04:06 +00:00
|
|
|
BM_KEY_SHIFT_RETURN,
|
2014-04-12 15:44:03 +00:00
|
|
|
BM_KEY_CONTROL_RETURN,
|
2020-08-03 22:09:40 +00:00
|
|
|
BM_KEY_CUSTOM_1,
|
|
|
|
BM_KEY_CUSTOM_2,
|
|
|
|
BM_KEY_CUSTOM_3,
|
|
|
|
BM_KEY_CUSTOM_4,
|
|
|
|
BM_KEY_CUSTOM_5,
|
|
|
|
BM_KEY_CUSTOM_6,
|
|
|
|
BM_KEY_CUSTOM_7,
|
|
|
|
BM_KEY_CUSTOM_8,
|
|
|
|
BM_KEY_CUSTOM_9,
|
|
|
|
BM_KEY_CUSTOM_10,
|
2014-04-09 22:09:35 +00:00
|
|
|
BM_KEY_UNICODE,
|
|
|
|
BM_KEY_LAST
|
2014-10-22 19:46:51 +00:00
|
|
|
};
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-10-25 17:02:34 +00:00
|
|
|
/**
|
|
|
|
* Colorable element constants.
|
|
|
|
*
|
|
|
|
* @link ::bm_color BM_COLOR_LAST @endlink is provided for enumerating colors.
|
|
|
|
*/
|
|
|
|
enum bm_color {
|
|
|
|
BM_COLOR_TITLE_BG,
|
|
|
|
BM_COLOR_TITLE_FG,
|
|
|
|
BM_COLOR_FILTER_BG,
|
|
|
|
BM_COLOR_FILTER_FG,
|
|
|
|
BM_COLOR_ITEM_BG,
|
|
|
|
BM_COLOR_ITEM_FG,
|
|
|
|
BM_COLOR_HIGHLIGHTED_BG,
|
|
|
|
BM_COLOR_HIGHLIGHTED_FG,
|
|
|
|
BM_COLOR_SELECTED_BG,
|
|
|
|
BM_COLOR_SELECTED_FG,
|
2015-01-17 23:38:25 +00:00
|
|
|
BM_COLOR_SCROLLBAR_BG,
|
|
|
|
BM_COLOR_SCROLLBAR_FG,
|
2014-10-25 17:02:34 +00:00
|
|
|
BM_COLOR_LAST
|
|
|
|
};
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/**
|
|
|
|
* @name Menu Memory
|
|
|
|
* @{ */
|
2014-03-28 19:33:20 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Create new bm_menu instance.
|
2014-03-28 19:33:20 +00:00
|
|
|
*
|
2015-01-17 16:53:29 +00:00
|
|
|
* If **NULL** is used as renderer, auto-detection will be used or the renderer with the name pointed by BEMENU_BACKEND env variable.
|
|
|
|
* It's good idea to use NULL, if you want user to have control over the renderer with this env variable.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param renderer Name of renderer to be used for this instance, pass **NULL** for auto-detection.
|
|
|
|
* @return bm_menu for new menu instance, **NULL** if creation failed.
|
2014-03-28 19:33:20 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC struct bm_menu* bm_menu_new(const char *renderer);
|
2014-03-28 19:33:20 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Release bm_menu instance.
|
2014-03-28 19:33:20 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance to be freed from memory.
|
2014-03-28 19:33:20 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_free(struct bm_menu *menu);
|
2014-03-28 19:33:20 +00:00
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Release items inside bm_menu instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance which items will be freed from memory.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_free_items(struct bm_menu *menu);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Menu Memory */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Menu Properties
|
|
|
|
* @{ */
|
|
|
|
|
2020-02-08 11:21:36 +00:00
|
|
|
/**
|
|
|
|
* Get the renderer from the bm_menu instance.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance which renderer to get.
|
|
|
|
* @return Pointer to bm_renderer instance.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC const struct bm_renderer* bm_menu_get_renderer(struct bm_menu *menu);
|
2020-02-08 11:21:36 +00:00
|
|
|
|
2014-04-10 17:09:34 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Set userdata pointer to bm_menu instance.
|
2014-04-10 17:09:34 +00:00
|
|
|
* Userdata will be carried unmodified by the instance.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where to set userdata pointer.
|
2014-04-10 17:09:34 +00:00
|
|
|
* @param userdata Pointer to userdata.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_userdata(struct bm_menu *menu, void *userdata);
|
2014-04-10 17:09:34 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get userdata pointer from bm_menu instance.
|
2014-04-10 17:09:34 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance which userdata pointer to get.
|
2014-04-10 17:09:34 +00:00
|
|
|
* @return Pointer for unmodified userdata.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void* bm_menu_get_userdata(struct bm_menu *menu);
|
2014-04-10 17:09:34 +00:00
|
|
|
|
2014-10-26 13:42:09 +00:00
|
|
|
/**
|
|
|
|
* Set highlight prefix.
|
|
|
|
* This is shown on vertical list mode only.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to set highlight prefix.
|
|
|
|
* @param prefix Null terminated C "string" to act as prefix for highlighted item. May be set **NULL** for none.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_prefix(struct bm_menu *menu, const char *prefix);
|
2014-10-26 13:42:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get highlight prefix.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to get highlight prefix.
|
|
|
|
* @param Const pointer to current highlight prefix, may be **NULL** if empty.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC const char* bm_menu_get_prefix(struct bm_menu *menu);
|
2014-10-26 13:42:09 +00:00
|
|
|
|
2014-04-14 16:25:04 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Set filter text to bm_menu instance.
|
2014-04-14 16:25:04 +00:00
|
|
|
*
|
2020-02-03 08:39:35 +00:00
|
|
|
* The cursor will be automatically placed at the end of the new filter text.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where to set filter.
|
2014-10-26 13:42:09 +00:00
|
|
|
* @param filter Null terminated C "string" to act as filter. May be set **NULL** for none.
|
2014-04-14 16:25:04 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_filter(struct bm_menu *menu, const char *filter);
|
2014-04-14 16:25:04 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get filter text from bm_menu instance.
|
2014-04-14 16:25:04 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where to get filter.
|
2014-04-14 16:25:04 +00:00
|
|
|
* @return Const pointer to current filter text, may be **NULL** if empty.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC const char* bm_menu_get_filter(struct bm_menu *menu);
|
2014-04-14 16:25:04 +00:00
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Set active filter mode to bm_menu instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where to set filter mode.
|
|
|
|
* @param mode bm_filter_mode constant.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_filter_mode(struct bm_menu *menu, enum bm_filter_mode mode);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get active filter mode from bm_menu instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where to get filter mode.
|
|
|
|
* @return bm_filter_mode constant.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC enum bm_filter_mode bm_menu_get_filter_mode(const struct bm_menu *menu);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-10-25 17:02:34 +00:00
|
|
|
/**
|
|
|
|
* Set amount of max vertical lines to be shown.
|
|
|
|
* Some renderers such as ncurses may ignore this when it does not make sense.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to set max vertical line amount.
|
|
|
|
* @param lines 0 for single line layout, > 0 to show that many lines.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_lines(struct bm_menu *menu, uint32_t lines);
|
2014-10-25 17:02:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get amount of max vertical lines to be shown.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to get max vertical line amount.
|
|
|
|
* @return uint32_t for max amount of vertical lines to be shown.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC uint32_t bm_menu_get_lines(struct bm_menu *menu);
|
2014-10-25 17:02:34 +00:00
|
|
|
|
2014-04-14 16:25:16 +00:00
|
|
|
/**
|
|
|
|
* Set selection wrapping on/off.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where to toggle selection wrapping.
|
2014-10-25 17:02:34 +00:00
|
|
|
* @param wrap true/false.
|
2014-04-14 16:25:16 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_wrap(struct bm_menu *menu, bool wrap);
|
2014-04-14 16:25:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get selection wrapping state.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where to get selection wrapping state.
|
2014-04-14 16:25:16 +00:00
|
|
|
* @return int for wrap state.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_get_wrap(const struct bm_menu *menu);
|
2014-04-14 16:25:16 +00:00
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Set title to bm_menu instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where to set title.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @param title C "string" to set as title, can be **NULL** for empty title.
|
2014-10-22 19:46:51 +00:00
|
|
|
* @return true if set was succesful, false if out of memory.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_set_title(struct bm_menu *menu, const char *title);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get title from bm_menu instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where to get title from.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @return Pointer to null terminated C "string", can be **NULL** for empty title.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC const char* bm_menu_get_title(const struct bm_menu *menu);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-10-25 17:02:34 +00:00
|
|
|
/**
|
2015-01-17 13:25:50 +00:00
|
|
|
* Set font description to bm_menu instance.
|
2014-10-25 17:02:34 +00:00
|
|
|
*
|
2015-01-17 13:25:50 +00:00
|
|
|
* @param menu bm_menu instance where to set font.
|
|
|
|
* @param font C "string" for a **pango style font description**, can be **NULL** for default (Terminus 9).
|
2014-10-25 17:02:34 +00:00
|
|
|
* @return true if set was succesful, false if out of memory.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_set_font(struct bm_menu *menu, const char *font);
|
2014-10-25 17:02:34 +00:00
|
|
|
|
|
|
|
/**
|
2015-01-17 13:25:50 +00:00
|
|
|
* Get font description from bm_menu instance.
|
2014-10-25 17:02:34 +00:00
|
|
|
*
|
2015-01-17 13:25:50 +00:00
|
|
|
* @param menu bm_menu instance where to get font description from.
|
2014-10-25 17:02:34 +00:00
|
|
|
* @return Pointer to null terminated C "string".
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC const char* bm_menu_get_font(const struct bm_menu *menu);
|
2014-10-25 17:02:34 +00:00
|
|
|
|
2019-05-31 20:32:02 +00:00
|
|
|
/**
|
|
|
|
* Set size of line in pixels.
|
|
|
|
* Some renderers such as ncurses may ignore this when it does not make sense.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to set line height.
|
|
|
|
* @param line_height 0 for default line height, > 0 for that many pixels.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_line_height(struct bm_menu *menu, uint32_t line_height);
|
2019-05-31 20:32:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get size of line in pixels.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to get line height.
|
|
|
|
* @return uint32_t for max amount of vertical lines to be shown.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC uint32_t bm_menu_get_line_height(struct bm_menu *menu);
|
2019-05-31 20:32:02 +00:00
|
|
|
|
2014-10-25 17:02:34 +00:00
|
|
|
/**
|
|
|
|
* Set a hexadecimal color for element.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to set color.
|
|
|
|
* @param color bm_color type.
|
|
|
|
* @param hex Color in hexadecimal format starting with '#'.
|
|
|
|
* @return true if set was succesful, false if out of memory.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_set_color(struct bm_menu *menu, enum bm_color color, const char *hex);
|
2014-10-25 17:02:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get hexadecimal color for element.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to get color from.
|
|
|
|
* @param color bm_color type.
|
|
|
|
* @return Pointer to null terminated C "string".
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC const char* bm_menu_get_color(const struct bm_menu *menu, enum bm_color color);
|
2014-10-25 17:02:34 +00:00
|
|
|
|
2015-01-17 22:59:44 +00:00
|
|
|
/**
|
2015-01-18 00:07:30 +00:00
|
|
|
* Set scrollbar display mode.
|
2015-01-17 22:59:44 +00:00
|
|
|
*
|
|
|
|
* @param menu bm_menu instance to set scrollbar for.
|
2015-01-18 00:07:30 +00:00
|
|
|
* @param mode bm_scrollbar_mode constant.
|
2015-01-17 22:59:44 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_scrollbar(struct bm_menu *menu, enum bm_scrollbar_mode mode);
|
2015-01-17 22:59:44 +00:00
|
|
|
|
|
|
|
/**
|
2015-01-18 00:07:30 +00:00
|
|
|
* Return current scrollbar display mode.
|
2015-01-17 22:59:44 +00:00
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to get scrollbar display state from.
|
2015-01-18 00:07:30 +00:00
|
|
|
* @return bm_scrollbar_mode constant.
|
2015-01-17 22:59:44 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC enum bm_scrollbar_mode bm_menu_get_scrollbar(struct bm_menu *menu);
|
2015-01-17 22:59:44 +00:00
|
|
|
|
2015-01-15 23:59:09 +00:00
|
|
|
/**
|
|
|
|
* Display menu at bottom of the screen.
|
|
|
|
* This may be no-op on some renderers (curses, wayland)
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance to set bottom mode for.
|
|
|
|
* @param bottom true for bottom mode, false for top mode.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_bottom(struct bm_menu *menu, bool bottom);
|
2015-01-15 23:59:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is menu being displayed at bottom of the screen?
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to get bottom mode from.
|
|
|
|
* @return true if bottom mode, false otherwise.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_get_bottom(struct bm_menu *menu);
|
2015-01-15 23:59:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Display menu at monitor index.
|
2021-04-04 12:25:06 +00:00
|
|
|
* Indices start at 0, a value of -1 can be passed for the active monitor (default).
|
2015-01-15 23:59:09 +00:00
|
|
|
* If index is more than amount of monitors, the monitor with highest index will be selected.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance to set monitor for.
|
2021-04-04 12:25:06 +00:00
|
|
|
* @param monitor Monitor index starting from 0, or -1 for the active monitor.
|
2015-01-15 23:59:09 +00:00
|
|
|
*/
|
2021-04-04 12:25:06 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_monitor(struct bm_menu *menu, int32_t monitor);
|
2015-01-15 23:59:09 +00:00
|
|
|
|
2021-02-05 07:50:58 +00:00
|
|
|
/**
|
|
|
|
* Display menu with monitor_name.
|
|
|
|
* Only works for Wayland.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance to set monitor for.
|
|
|
|
* @param monitor_name Monitor name passed in.
|
|
|
|
*/
|
|
|
|
BM_PUBLIC void bm_menu_set_monitor_name(struct bm_menu *menu, char *monitor_name);
|
|
|
|
|
2015-01-15 23:59:09 +00:00
|
|
|
/**
|
|
|
|
* Return index for current monitor.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to get current monitor from.
|
|
|
|
* @return Monitor index starting from 1.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC uint32_t bm_menu_get_monitor(struct bm_menu *menu);
|
2015-01-15 23:59:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tell renderer to grab keyboard.
|
|
|
|
* This only works with x11 renderer.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance to set grab for.
|
|
|
|
* @param grab true for grab, false for ungrab.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_grab_keyboard(struct bm_menu *menu, bool grab);
|
2015-01-15 23:59:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is keyboard grabbed for bm_menu?
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to check grab status from.
|
|
|
|
* @return true if grabbed, false if not.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_is_keyboard_grabbed(struct bm_menu *menu);
|
2014-10-25 17:02:34 +00:00
|
|
|
|
2019-03-25 21:21:17 +00:00
|
|
|
/**
|
|
|
|
* Tell the renderer to position the menu that it can overlap panels.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_set_panel_overlap(struct bm_menu *menu, bool overlap);
|
2019-03-25 21:21:17 +00:00
|
|
|
|
2021-02-05 04:12:48 +00:00
|
|
|
/**
|
|
|
|
* Replace input with asterisks.
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance to set password mode for.
|
|
|
|
* @param password true for password mode, false for deafault behavior.
|
|
|
|
*/
|
|
|
|
BM_PUBLIC void bm_menu_set_password(struct bm_menu *menu, bool password);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is password mode activated and input hidden?
|
|
|
|
*
|
|
|
|
* @param menu bm_menu instance where to get password mode from.
|
|
|
|
* @return true if password mode, false otherwise.
|
|
|
|
*/
|
|
|
|
BM_PUBLIC bool bm_menu_get_password(struct bm_menu *menu);
|
|
|
|
|
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Properties */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Menu Items
|
|
|
|
* @{ */
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Add item to bm_menu instance at specific index.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where item will be added.
|
|
|
|
* @param item bm_item instance to add.
|
2014-04-09 22:09:35 +00:00
|
|
|
* @param index Index where item will be added.
|
2014-10-22 19:46:51 +00:00
|
|
|
* @return true on successful add, false on failure.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_add_item_at(struct bm_menu *menu, struct bm_item *item, uint32_t index);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Add item to bm_menu instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where item will be added.
|
|
|
|
* @param item bm_item instance to add.
|
|
|
|
* @return true on successful add, false on failure.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_add_item(struct bm_menu *menu, struct bm_item *item);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Remove item from bm_menu instance at specific index.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @warning The item won't be freed, use bm_item_free to do that.
|
2014-04-10 14:26:42 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance from where item will be removed.
|
2014-04-09 22:09:35 +00:00
|
|
|
* @param index Index of item to remove.
|
2014-10-22 19:46:51 +00:00
|
|
|
* @return true on successful add, false on failure.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_remove_item_at(struct bm_menu *menu, uint32_t index);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Remove item from bm_menu instance.
|
2014-04-10 14:26:42 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @warning The item won't be freed, use bm_item_free to do that.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance from where item will be removed.
|
|
|
|
* @param item bm_item instance to remove.
|
|
|
|
* @return true on successful add, false on failure.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_remove_item(struct bm_menu *menu, struct bm_item *item);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-04-10 17:04:06 +00:00
|
|
|
* Highlight item in menu by index.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance from where to highlight item.
|
2014-04-10 17:12:42 +00:00
|
|
|
* @param index Index of item to highlight.
|
2014-10-22 19:46:51 +00:00
|
|
|
* @return true on successful highlight, false on failure.
|
2014-04-10 17:04:06 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_set_highlighted_index(struct bm_menu *menu, uint32_t index);
|
2014-04-10 17:04:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Highlight item in menu.
|
2014-04-10 14:26:42 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance from where to highlight item.
|
|
|
|
* @param item bm_item instance to highlight.
|
|
|
|
* @return true on successful highlight, false on failure.
|
2014-04-10 17:04:06 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_set_highlighted_item(struct bm_menu *menu, struct bm_item *item);
|
2014-04-10 17:04:06 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get highlighted item from bm_menu instance.
|
2014-04-10 17:04:06 +00:00
|
|
|
*
|
2014-04-10 17:19:15 +00:00
|
|
|
* @warning The pointer returned by this function may be invalid after items change.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance from where to get highlighted item.
|
|
|
|
* @return Selected bm_item instance, **NULL** if none highlighted.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC struct bm_item* bm_menu_get_highlighted_item(const struct bm_menu *menu);
|
2014-04-10 17:04:06 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Set selected items to bm_menu instance.
|
2014-04-10 17:04:06 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where items will be set.
|
|
|
|
* @param items Array of bm_item pointers to set.
|
2014-04-10 17:04:06 +00:00
|
|
|
* @param nmemb Total count of items in array.
|
2014-10-22 19:46:51 +00:00
|
|
|
* @return true on successful set, false on failure.
|
2014-04-10 17:04:06 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_set_selected_items(struct bm_menu *menu, struct bm_item **items, uint32_t nmemb);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get selected items from bm_menu instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-04-10 17:19:15 +00:00
|
|
|
* @warning The pointer returned by this function may be invalid after selection or items change.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance from where to get selected items.
|
|
|
|
* @param out_nmemb Reference to uint32_t where total count of returned items will be stored.
|
|
|
|
* @return Pointer to array of bm_item pointers.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC struct bm_item** bm_menu_get_selected_items(const struct bm_menu *menu, uint32_t *out_nmemb);
|
2014-04-10 17:11:41 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Set items to bm_menu instance.
|
|
|
|
* Will replace all the old items on bm_menu instance.
|
2014-04-10 17:11:41 +00:00
|
|
|
*
|
|
|
|
* If items is **NULL**, or nmemb is zero, all items will be freed from the menu.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance where items will be set.
|
|
|
|
* @param items Array of bm_item pointers to set.
|
2014-04-10 17:11:41 +00:00
|
|
|
* @param nmemb Total count of items in array.
|
2014-10-22 19:46:51 +00:00
|
|
|
* @return true on successful set, false on failure.
|
2014-04-10 17:11:41 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_menu_set_items(struct bm_menu *menu, const struct bm_item **items, uint32_t nmemb);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-04-10 17:04:06 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get items from bm_menu instance.
|
2014-04-10 17:04:06 +00:00
|
|
|
*
|
|
|
|
* @warning The pointer returned by this function may be invalid after removing or adding new items.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance from where to get items.
|
|
|
|
* @param out_nmemb Reference to uint32_t where total count of returned items will be stored.
|
|
|
|
* @return Pointer to array of bm_item pointers.
|
2014-04-10 17:04:06 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC struct bm_item** bm_menu_get_items(const struct bm_menu *menu, uint32_t *out_nmemb);
|
2014-04-10 17:04:06 +00:00
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get filtered (displayed) items from bm_menu instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-04-10 17:11:41 +00:00
|
|
|
* @warning The pointer returned by this function _will_ be invalid when menu internally filters its list again.
|
|
|
|
* Do not store this pointer.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance from where to get filtered items.
|
|
|
|
* @param out_nmemb Reference to uint32_t where total count of returned items will be stored.
|
|
|
|
* @return Pointer to array of bm_item pointers.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC struct bm_item** bm_menu_get_filtered_items(const struct bm_menu *menu, uint32_t *out_nmemb);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Menu Items */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Menu Logic
|
|
|
|
* @{ */
|
|
|
|
|
2014-03-28 19:33:20 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Render bm_menu instance using chosen renderer.
|
2014-03-28 19:33:20 +00:00
|
|
|
*
|
2015-01-15 23:59:09 +00:00
|
|
|
* This function may block on **wayland** and **x11** renderer.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance to be rendered.
|
2014-03-28 19:33:20 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_render(const struct bm_menu *menu);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-04-10 20:05:13 +00:00
|
|
|
/**
|
|
|
|
* Trigger filtering of menu manually.
|
|
|
|
* This is useful when adding new items and want to dynamically see them filtered.
|
|
|
|
*
|
|
|
|
* Do note that filtering might be heavy, so you should only call it after batch manipulation of items.
|
|
|
|
* Not after manipulation of each single item.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance which to filter.
|
2014-04-10 20:05:13 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_menu_filter(struct bm_menu *menu);
|
2014-04-10 20:05:13 +00:00
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
|
|
|
* Poll key and unicode from underlying UI toolkit.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* This function will block on **curses** renderer.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance from which to poll.
|
|
|
|
* @param out_unicode Reference to uint32_t.
|
|
|
|
* @return bm_key for polled key.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC enum bm_key bm_menu_poll_key(struct bm_menu *menu, uint32_t *out_unicode);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Advances menu logic with key and unicode as input.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param menu bm_menu instance to be advanced.
|
2014-04-10 10:08:38 +00:00
|
|
|
* @param key Key input that will advance menu logic.
|
|
|
|
* @param unicode Unicode input that will advance menu logic.
|
2014-10-22 19:46:51 +00:00
|
|
|
* @return bm_run_result for menu state.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC enum bm_run_result bm_menu_run_with_key(struct bm_menu *menu, enum bm_key key, uint32_t unicode);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Menu Logic */
|
|
|
|
|
|
|
|
/** @} Menu */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Item
|
|
|
|
* @{ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Item Memory
|
|
|
|
* @{ */
|
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
|
|
|
* Allocate a new item.
|
|
|
|
*
|
2014-04-10 14:26:42 +00:00
|
|
|
* @param text Pointer to null terminated C "string", can be **NULL** for empty text.
|
2014-10-22 19:46:51 +00:00
|
|
|
* @return bm_item for new item instance, **NULL** if creation failed.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC struct bm_item* bm_item_new(const char *text);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Release bm_item instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param item bm_item instance to be freed from memory.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_item_free(struct bm_item *item);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Item Memory */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Item Properties
|
|
|
|
* @{ */
|
|
|
|
|
2014-04-10 17:09:34 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Set userdata pointer to bm_item instance.
|
2014-04-10 17:09:34 +00:00
|
|
|
* Userdata will be carried unmodified by the instance.
|
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param item bm_item instance where to set userdata pointer.
|
2014-04-10 17:09:34 +00:00
|
|
|
* @param userdata Pointer to userdata.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void bm_item_set_userdata(struct bm_item *item, void *userdata);
|
2014-04-10 17:09:34 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get userdata pointer from bm_item instance.
|
2014-04-10 17:09:34 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param item bm_item instance which userdata pointer to get.
|
2014-04-10 17:09:34 +00:00
|
|
|
* @return Pointer for unmodified userdata.
|
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC void* bm_item_get_userdata(struct bm_item *item);
|
2014-04-10 17:09:34 +00:00
|
|
|
|
2014-04-09 22:09:35 +00:00
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Set text to bm_item instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param item bm_item instance where to set text.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @param text C "string" to set as text, can be **NULL** for empty text.
|
2014-10-22 19:46:51 +00:00
|
|
|
* @return true if set was succesful, false if out of memory.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC bool bm_item_set_text(struct bm_item *item, const char *text);
|
2014-04-09 22:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-22 19:46:51 +00:00
|
|
|
* Get text from bm_item instance.
|
2014-04-09 22:09:35 +00:00
|
|
|
*
|
2014-10-22 19:46:51 +00:00
|
|
|
* @param item bm_item instance where to get text from.
|
2014-04-10 14:26:42 +00:00
|
|
|
* @return Pointer to null terminated C "string", can be **NULL** for empty text.
|
2014-04-09 22:09:35 +00:00
|
|
|
*/
|
2020-12-13 00:54:53 +00:00
|
|
|
BM_PUBLIC const char* bm_item_get_text(const struct bm_item *item);
|
2014-03-28 19:33:20 +00:00
|
|
|
|
2014-04-10 14:26:42 +00:00
|
|
|
/** @} Item Properties */
|
|
|
|
|
|
|
|
/** @} Item */
|
|
|
|
|
2014-10-24 22:38:30 +00:00
|
|
|
#endif /* _BEMENU_H_ */
|
|
|
|
|
2014-03-28 19:33:20 +00:00
|
|
|
/* vim: set ts=8 sw=4 tw=0 :*/
|