2014-10-25 00:38:30 +02:00
|
|
|
#ifndef _BEMENU_INTERNAL_H_
|
|
|
|
#define _BEMENU_INTERNAL_H_
|
|
|
|
|
2014-03-28 20:33:20 +01:00
|
|
|
#include "bemenu.h"
|
|
|
|
|
2014-10-25 00:38:30 +02:00
|
|
|
#if __GNUC__
|
|
|
|
# define BM_LOG_ATTR(x, y) __attribute__((format(printf, x, y)))
|
|
|
|
#else
|
|
|
|
# define BM_LOG_ATTR(x, y)
|
|
|
|
#endif
|
|
|
|
|
2015-02-02 11:25:56 +01:00
|
|
|
#ifndef __GLIBC__
|
|
|
|
# define secure_getenv getenv
|
2020-02-07 14:56:50 +01:00
|
|
|
#else
|
|
|
|
extern char *secure_getenv(const char *name);
|
2015-02-02 11:25:56 +01:00
|
|
|
#endif
|
|
|
|
|
2020-02-07 14:56:50 +01:00
|
|
|
#include <stddef.h> /* for size_t */
|
2014-10-25 00:38:30 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2021-10-17 08:22:24 +02:00
|
|
|
//minimum allowed window width when setting margin
|
|
|
|
#define WINDOW_MIN_WIDTH 80
|
|
|
|
|
2014-03-28 20:33:20 +01:00
|
|
|
/**
|
2014-10-22 21:46:51 +02:00
|
|
|
* Destructor function pointer for some list calls.
|
|
|
|
*/
|
|
|
|
typedef void (*list_free_fun)(void*);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List type
|
2014-03-28 20:33:20 +01:00
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
struct list {
|
2014-04-10 19:09:34 +02:00
|
|
|
/**
|
2014-10-22 21:46:51 +02:00
|
|
|
* Items in the list.
|
2014-04-10 19:09:34 +02:00
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
void **items;
|
2014-04-10 19:09:34 +02:00
|
|
|
|
2014-04-10 12:23:42 +02:00
|
|
|
/**
|
2014-10-22 21:46:51 +02:00
|
|
|
* Number of items.
|
2014-04-10 12:23:42 +02:00
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
uint32_t count;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of allocated items.
|
|
|
|
*/
|
|
|
|
uint32_t allocated;
|
2014-03-28 21:14:13 +01:00
|
|
|
};
|
2014-03-28 20:33:20 +01:00
|
|
|
|
|
|
|
/**
|
2014-10-22 21:46:51 +02:00
|
|
|
* Internal render api struct.
|
2014-03-28 20:33:20 +01:00
|
|
|
* Renderers should be able to fill this one as they see fit.
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
struct render_api {
|
|
|
|
/**
|
|
|
|
* Create underlying renderer.
|
|
|
|
*/
|
2014-10-22 22:10:11 +02:00
|
|
|
bool (*constructor)(struct bm_menu *menu);
|
2014-10-22 21:46:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Release underlying renderer.
|
|
|
|
*/
|
2014-10-22 22:10:11 +02:00
|
|
|
void (*destructor)(struct bm_menu *menu);
|
2014-10-22 21:46:51 +02:00
|
|
|
|
2014-04-12 17:42:30 +02:00
|
|
|
/**
|
|
|
|
* Get count of displayed items by the underlying renderer.
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
uint32_t (*get_displayed_count)(const struct bm_menu *menu);
|
2014-04-12 17:42:30 +02:00
|
|
|
|
2021-08-14 17:31:28 +02:00
|
|
|
/**
|
|
|
|
* Get height by the underlying renderer;
|
|
|
|
*/
|
|
|
|
uint32_t (*get_height)(const struct bm_menu *menu);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get width by the underlying renderer;
|
|
|
|
*/
|
|
|
|
uint32_t (*get_width)(const struct bm_menu *menu);
|
|
|
|
|
2014-04-10 12:23:42 +02:00
|
|
|
/**
|
|
|
|
* If the underlying renderer is a UI toolkit. (curses, etc...)
|
|
|
|
* There might be possibility to get user input, and this should be thus implemented.
|
|
|
|
*/
|
2014-10-22 22:10:11 +02:00
|
|
|
enum bm_key (*poll_key)(const struct bm_menu *menu, uint32_t *unicode);
|
2014-04-10 12:23:42 +02:00
|
|
|
|
2021-08-14 17:31:28 +02:00
|
|
|
/**
|
|
|
|
* If the underlying renderer is a UI toolkit. (curses, etc...)
|
|
|
|
* There might be possibility to get user pointer, and this should be thus implemented.
|
|
|
|
*/
|
|
|
|
struct bm_pointer (*poll_pointer)(const struct bm_menu *menu);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the underlying renderer is a UI toolkit. (curses, etc...)
|
|
|
|
* There might be possibility to get user touch, and this should be thus implemented.
|
|
|
|
*/
|
|
|
|
struct bm_touch (*poll_touch)(const struct bm_menu *menu);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enforce a release of the touches
|
|
|
|
* There might be possibility to get user touch, and this should be thus implemented.
|
|
|
|
*/
|
|
|
|
void (*release_touch)(const struct bm_menu *menu);
|
|
|
|
|
2014-04-10 12:23:42 +02:00
|
|
|
/**
|
|
|
|
* Tells underlying renderer to draw the menu.
|
|
|
|
*/
|
Fix exiting when an unexpected Wayland error occurs.
If an unexpected error was returned from a Wayland API during rendering (e.g.
from wl_display_flush), the code did set input.sym = XKB_KEY_Escape, so that
the next call to poll_key would return BM_KEY_ESCAPE and bemenu would quit.
However, this has been broken since #135, because input.key_pending was not
set, so the "fake" XKB_KEY_Escape is just ignored, bemenu doesn't quit, but
instead, it enters an infinite loop and keeps a CPU core at 100% usage.
The "quick fix" would be to just set input.key_pending wherever input.sym was
set to XKB_KEY_Escape. However, to make error handling less error-prone,
decouple it from input handling and add an error flag to (bm_menu_)render.
2022-07-31 21:17:56 +02:00
|
|
|
bool (*render)(struct bm_menu *menu);
|
2014-10-25 00:38:30 +02:00
|
|
|
|
2015-01-16 00:59:09 +01:00
|
|
|
/**
|
2021-10-17 18:33:37 +02:00
|
|
|
* Set vertical alignment of the bar.
|
2015-01-16 00:59:09 +01:00
|
|
|
*/
|
2021-10-17 18:33:37 +02:00
|
|
|
void (*set_align)(const struct bm_menu *menu, enum bm_align align);
|
2015-01-16 00:59:09 +01:00
|
|
|
|
2021-10-17 08:22:24 +02:00
|
|
|
/**
|
2021-12-26 17:38:11 +01:00
|
|
|
* Set horizontal margin and relative width factor.
|
2021-10-17 08:22:24 +02:00
|
|
|
*/
|
2021-12-26 17:38:11 +01:00
|
|
|
void (*set_width)(const struct bm_menu *menu, uint32_t margin, float factor);
|
2021-10-17 08:22:24 +02:00
|
|
|
|
2015-01-16 00:59:09 +01:00
|
|
|
/**
|
|
|
|
* Set monitor indeax where menu will appear
|
|
|
|
*/
|
2021-04-04 14:25:06 +02:00
|
|
|
void (*set_monitor)(const struct bm_menu *menu, int32_t monitor);
|
2015-01-16 00:59:09 +01:00
|
|
|
|
2021-02-05 08:50:58 +01:00
|
|
|
/**
|
|
|
|
* Set monitor name where menu will appear
|
|
|
|
*/
|
|
|
|
void (*set_monitor_name)(const struct bm_menu *menu, char *monitor_name);
|
|
|
|
|
2015-01-16 00:59:09 +01:00
|
|
|
/**
|
|
|
|
* Grab/Ungrab keyboard
|
|
|
|
*/
|
|
|
|
void (*grab_keyboard)(const struct bm_menu *menu, bool grab);
|
|
|
|
|
2019-03-25 22:21:17 +01:00
|
|
|
/**
|
|
|
|
* Control overlap with panels
|
|
|
|
*/
|
|
|
|
void (*set_overlap)(const struct bm_menu *menu, bool overlap);
|
|
|
|
|
2014-10-25 00:38:30 +02:00
|
|
|
/**
|
|
|
|
* Version of the plugin.
|
2014-10-25 15:39:39 +02:00
|
|
|
* Should match BM_PLUGIN_VERSION or failure.
|
2014-10-25 00:38:30 +02:00
|
|
|
*/
|
|
|
|
const char *version;
|
|
|
|
|
|
|
|
/**
|
2015-01-17 17:53:29 +01:00
|
|
|
* Priorty of the plugin.
|
2014-10-25 00:38:30 +02:00
|
|
|
* Terminal renderers should be first, then graphicals.
|
|
|
|
*/
|
2015-01-17 17:53:29 +01:00
|
|
|
enum bm_priorty priorty;
|
2014-10-22 21:46:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal bm_renderer struct.
|
|
|
|
*/
|
|
|
|
struct bm_renderer {
|
|
|
|
/**
|
|
|
|
* Name of the renderer.
|
|
|
|
*/
|
|
|
|
char *name;
|
2014-04-10 12:23:42 +02:00
|
|
|
|
|
|
|
/**
|
2014-10-22 21:46:51 +02:00
|
|
|
* File path of the renderer.
|
2014-04-10 12:23:42 +02:00
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
char *file;
|
2014-03-28 20:33:20 +01:00
|
|
|
|
2014-04-10 19:04:06 +02:00
|
|
|
/**
|
2014-10-22 21:46:51 +02:00
|
|
|
* Open handle to the plugin file of this renderer.
|
2014-04-10 19:04:06 +02:00
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
void *handle;
|
2014-04-10 19:04:06 +02:00
|
|
|
|
2014-10-25 00:38:30 +02:00
|
|
|
/**
|
|
|
|
* Data used by the renderer internally.
|
|
|
|
* Nobody else should touch this.
|
|
|
|
*/
|
|
|
|
void *internal;
|
|
|
|
|
2014-04-10 19:04:06 +02:00
|
|
|
/**
|
2014-10-22 21:46:51 +02:00
|
|
|
* API
|
2014-04-10 19:04:06 +02:00
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
struct render_api api;
|
|
|
|
};
|
2014-04-10 19:04:06 +02:00
|
|
|
|
2014-10-22 21:46:51 +02:00
|
|
|
/**
|
|
|
|
* Internal bm_item struct that is not exposed to public.
|
|
|
|
* Represents a single item in menu.
|
|
|
|
*/
|
|
|
|
struct bm_item {
|
2014-04-10 19:04:06 +02:00
|
|
|
/**
|
2014-10-22 21:46:51 +02:00
|
|
|
* Userdata pointer.
|
|
|
|
* This pointer will be passed around with the item untouched.
|
|
|
|
*/
|
|
|
|
void *userdata;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Primary text shown on item as null terminated C "string".
|
|
|
|
* Matching will be done against this text as well.
|
2014-04-10 19:04:06 +02:00
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
char *text;
|
2014-04-10 19:04:06 +02:00
|
|
|
};
|
|
|
|
|
2014-10-25 19:02:34 +02:00
|
|
|
/**
|
|
|
|
* Internal bm_hex_color struct that is not exposed to public.
|
|
|
|
* Represent a color for element.
|
|
|
|
*/
|
|
|
|
struct bm_hex_color {
|
|
|
|
/**
|
|
|
|
* Provided hex for the color.
|
|
|
|
*/
|
|
|
|
char *hex;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RGB values.
|
|
|
|
*/
|
2020-03-16 03:41:42 +01:00
|
|
|
uint8_t r, g, b, a;
|
2014-10-25 19:02:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal bm_font struct that is not exposed to public.
|
|
|
|
* Represent a font for text.
|
|
|
|
*/
|
|
|
|
struct bm_font {
|
|
|
|
/**
|
|
|
|
* Name of the font.
|
|
|
|
*/
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
2014-03-28 20:33:20 +01:00
|
|
|
/**
|
2014-10-22 21:46:51 +02:00
|
|
|
* Internal bm_menu struct that is not exposed to public.
|
2014-03-28 20:33:20 +01:00
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
struct bm_menu {
|
2014-04-10 19:09:34 +02:00
|
|
|
/**
|
|
|
|
* Userdata pointer.
|
|
|
|
* This pointer will be passed around with the menu untouched.
|
|
|
|
*/
|
|
|
|
void *userdata;
|
|
|
|
|
2014-04-10 12:23:42 +02:00
|
|
|
/**
|
|
|
|
* Underlying renderer access.
|
|
|
|
*/
|
2014-10-25 00:38:30 +02:00
|
|
|
struct bm_renderer *renderer;
|
2014-04-10 12:23:42 +02:00
|
|
|
|
|
|
|
/**
|
2014-04-10 19:04:06 +02:00
|
|
|
* Items contained in menu instance.
|
2014-04-10 12:23:42 +02:00
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
struct list items;
|
2014-04-10 12:23:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filtered/displayed items contained in menu instance.
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
struct list filtered;
|
2014-04-10 19:04:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Selected items.
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
struct list selection;
|
2014-04-10 12:23:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Menu instance title.
|
|
|
|
*/
|
|
|
|
char *title;
|
|
|
|
|
2014-10-25 19:02:34 +02:00
|
|
|
/**
|
|
|
|
* Font.
|
|
|
|
*/
|
|
|
|
struct bm_font font;
|
|
|
|
|
2019-05-31 22:32:02 +02:00
|
|
|
/**
|
|
|
|
* Line height.
|
|
|
|
*/
|
|
|
|
uint32_t line_height;
|
|
|
|
|
2021-08-24 19:06:51 +02:00
|
|
|
/**
|
|
|
|
* Cursor height.
|
|
|
|
*/
|
|
|
|
uint32_t cursor_height;
|
|
|
|
|
2022-06-02 18:52:09 +02:00
|
|
|
/**
|
|
|
|
* Cursor width.
|
|
|
|
*/
|
|
|
|
uint32_t cursor_width;
|
|
|
|
|
2022-06-01 16:16:45 +02:00
|
|
|
/**
|
|
|
|
* Horizontal Padding.
|
|
|
|
*/
|
|
|
|
uint32_t hpadding;
|
|
|
|
|
2014-10-25 19:02:34 +02:00
|
|
|
/**
|
|
|
|
* Colors.
|
|
|
|
*/
|
|
|
|
struct bm_hex_color colors[BM_COLOR_LAST];
|
|
|
|
|
2014-10-26 14:42:09 +01:00
|
|
|
/**
|
|
|
|
* Prefix shown for highlighted item.
|
|
|
|
* Vertical mode only.
|
|
|
|
*/
|
|
|
|
char *prefix;
|
|
|
|
|
2014-04-10 12:23:42 +02:00
|
|
|
/**
|
|
|
|
* Text used to filter matches.
|
|
|
|
*/
|
2014-04-12 19:52:29 +02:00
|
|
|
char *filter;
|
2014-04-10 12:23:42 +02:00
|
|
|
|
2014-04-10 22:05:13 +02:00
|
|
|
/**
|
|
|
|
* Used as optimization.
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
char *old_filter;
|
2014-04-10 22:05:13 +02:00
|
|
|
|
2020-02-07 20:54:13 +01:00
|
|
|
/**
|
|
|
|
* Used when selecting the filter text (ex. SHIFT_RETURN)
|
|
|
|
*/
|
|
|
|
struct bm_item *filter_item;
|
|
|
|
|
2014-04-12 19:52:29 +02:00
|
|
|
/**
|
|
|
|
* Size of filter buffer
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
size_t filter_size;
|
2014-04-12 19:52:29 +02:00
|
|
|
|
2014-04-10 12:23:42 +02:00
|
|
|
/**
|
|
|
|
* Current byte offset on filter text.
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
uint32_t cursor;
|
2014-04-10 12:23:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Current column/cursor position on filter text.
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
uint32_t curses_cursor;
|
2014-04-10 12:23:42 +02:00
|
|
|
|
|
|
|
/**
|
2014-04-10 19:04:06 +02:00
|
|
|
* Current filtered/highlighted item index in menu instance.
|
2014-04-10 12:23:42 +02:00
|
|
|
* This index is valid for the list returned by bmMenuGetFilteredItems.
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
uint32_t index;
|
2014-04-10 12:23:42 +02:00
|
|
|
|
2014-10-25 19:02:34 +02:00
|
|
|
/**
|
|
|
|
* Max number of vertical lines to be shown.
|
|
|
|
* Some renderers such as ncurses may ignore this when it does not make sense.
|
|
|
|
*/
|
|
|
|
uint32_t lines;
|
|
|
|
|
2015-01-16 00:59:09 +01:00
|
|
|
/**
|
|
|
|
* Current monitor.
|
|
|
|
*/
|
2021-04-04 14:25:06 +02:00
|
|
|
int32_t monitor;
|
2015-01-16 00:59:09 +01:00
|
|
|
|
2021-02-05 08:50:58 +01:00
|
|
|
/**
|
|
|
|
* Current monitor name. Wayland only.
|
|
|
|
*/
|
|
|
|
char *monitor_name;
|
|
|
|
|
2014-04-10 12:23:42 +02:00
|
|
|
/**
|
|
|
|
* Current filtering method in menu instance.
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
enum bm_filter_mode filter_mode;
|
2014-04-14 18:25:16 +02:00
|
|
|
|
2023-02-18 10:30:55 +01:00
|
|
|
/**
|
|
|
|
* Current fixed height mode.
|
|
|
|
*/
|
|
|
|
bool fixed_height;
|
|
|
|
|
2015-01-18 01:07:30 +01:00
|
|
|
/**
|
|
|
|
* Current Scrollbar display mode.
|
|
|
|
*/
|
|
|
|
enum bm_scrollbar_mode scrollbar;
|
|
|
|
|
2023-06-15 18:28:26 +02:00
|
|
|
/**
|
|
|
|
* Current vim escape exit mode.
|
|
|
|
*/
|
|
|
|
bool vim_esc_exits;
|
|
|
|
|
2022-12-27 09:13:59 +01:00
|
|
|
/**
|
|
|
|
* Current counter display mode.
|
|
|
|
*/
|
|
|
|
bool counter;
|
|
|
|
|
2014-04-14 18:25:16 +02:00
|
|
|
/**
|
|
|
|
* Should selection be wrapped?
|
|
|
|
*/
|
2014-10-22 21:46:51 +02:00
|
|
|
bool wrap;
|
2015-01-16 00:59:09 +01:00
|
|
|
|
2021-08-14 12:07:22 +02:00
|
|
|
/**
|
2021-10-17 18:33:37 +02:00
|
|
|
* Vertical alignment.
|
2015-01-16 00:59:09 +01:00
|
|
|
*/
|
2021-10-17 18:33:37 +02:00
|
|
|
enum bm_align align;
|
2015-01-16 00:59:09 +01:00
|
|
|
|
2021-10-17 08:22:24 +02:00
|
|
|
/**
|
|
|
|
* Horizontal margin.
|
|
|
|
*/
|
|
|
|
uint32_t hmargin_size;
|
|
|
|
|
2021-12-26 17:38:11 +01:00
|
|
|
/**
|
|
|
|
* Relative width factor.
|
|
|
|
*/
|
|
|
|
float width_factor;
|
|
|
|
|
2022-06-01 00:45:20 +02:00
|
|
|
/**
|
|
|
|
* Border size
|
|
|
|
*/
|
|
|
|
uint32_t border_size;
|
|
|
|
|
2022-12-19 21:09:08 +01:00
|
|
|
/**
|
|
|
|
* Border radius
|
|
|
|
*/
|
|
|
|
uint32_t border_radius;
|
|
|
|
|
2015-01-16 00:59:09 +01:00
|
|
|
/**
|
|
|
|
* Is menu grabbed?
|
|
|
|
*/
|
|
|
|
bool grabbed;
|
2019-03-25 22:21:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Should the menu overlap panels
|
|
|
|
*/
|
|
|
|
bool overlap;
|
2021-02-05 05:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Should the input be hidden
|
|
|
|
*/
|
|
|
|
bool password;
|
2021-08-27 23:15:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Should the entry should follow the title spacing
|
|
|
|
*/
|
|
|
|
bool spacing;
|
2021-08-27 13:19:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mask representing a feedback to bring to user
|
|
|
|
*/
|
|
|
|
uint32_t event_feedback;
|
2021-11-03 19:52:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the menu needing a redraw ?
|
|
|
|
*/
|
|
|
|
bool dirty;
|
2022-10-20 03:18:17 +02:00
|
|
|
|
2022-10-20 15:01:36 +02:00
|
|
|
/**
|
|
|
|
* Key binding that should be used.
|
|
|
|
*/
|
2022-10-20 18:40:27 +02:00
|
|
|
enum bm_key_binding key_binding;
|
2022-10-20 15:01:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Vim binding specific variables.
|
|
|
|
*/
|
2022-10-20 03:18:17 +02:00
|
|
|
char vim_mode;
|
|
|
|
uint32_t vim_last_key;
|
2014-03-28 21:14:13 +01:00
|
|
|
};
|
2014-03-28 20:33:20 +01:00
|
|
|
|
2014-10-22 21:46:51 +02:00
|
|
|
/* library.c */
|
2014-10-22 22:10:11 +02:00
|
|
|
bool bm_renderer_activate(struct bm_renderer *renderer, struct bm_menu *menu);
|
2014-04-10 00:09:35 +02:00
|
|
|
|
|
|
|
/* filter.c */
|
2014-10-22 21:46:51 +02:00
|
|
|
struct bm_item** bm_filter_dmenu(struct bm_menu *menu, bool addition, uint32_t *out_nmemb);
|
|
|
|
struct bm_item** bm_filter_dmenu_case_insensitive(struct bm_menu *menu, bool addition, uint32_t *out_nmemb);
|
2014-04-10 19:04:06 +02:00
|
|
|
|
|
|
|
/* list.c */
|
2014-10-22 21:46:51 +02:00
|
|
|
void list_free_list(struct list *list);
|
|
|
|
void list_free_items(struct list *list, list_free_fun destructor);
|
|
|
|
void* list_get_items(const struct list *list, uint32_t *out_nmemb);
|
|
|
|
bool list_set_items_no_copy(struct list *list, void *items, uint32_t nmemb);
|
|
|
|
bool list_set_items(struct list *list, const void *items, uint32_t nmemb, list_free_fun destructor);
|
|
|
|
bool list_grow(struct list *list, uint32_t step);
|
|
|
|
bool list_add_item_at(struct list *list, void *item, uint32_t index);
|
|
|
|
bool list_add_item(struct list *list, void *item);
|
|
|
|
bool list_remove_item_at(struct list *list, uint32_t index);
|
|
|
|
bool list_remove_item(struct list *list, const void *item);
|
2014-10-25 00:38:30 +02:00
|
|
|
void list_sort(struct list *list, int (*compar)(const void *a, const void *b));
|
2014-04-10 00:09:35 +02:00
|
|
|
|
2022-02-19 01:00:22 +01:00
|
|
|
/* util.c
|
|
|
|
* Functions here may be used in renderers also. They will be statically compiled to all units,
|
|
|
|
* so do not mark them as a BM_PUBLIC.
|
|
|
|
*/
|
2022-02-19 00:00:26 +01:00
|
|
|
char* bm_strdup(const char *s);
|
|
|
|
bool bm_resize_buffer(char **in_out_buffer, size_t *in_out_size, size_t nsize);
|
|
|
|
BM_LOG_ATTR(1, 2) char* bm_dprintf(const char *fmt, ...);
|
|
|
|
BM_LOG_ATTR(3, 0) bool bm_vrprintf(char **in_out_buffer, size_t *in_out_len, const char *fmt, va_list args);
|
|
|
|
size_t bm_strip_token(char *string, const char *token, size_t *out_next);
|
|
|
|
int bm_strupcmp(const char *hay, const char *needle);
|
|
|
|
int bm_strnupcmp(const char *hay, const char *needle, size_t len);
|
|
|
|
char* bm_strupstr(const char *hay, const char *needle);
|
|
|
|
int32_t bm_utf8_string_screen_width(const char *string);
|
|
|
|
size_t bm_utf8_rune_next(const char *string, size_t start);
|
|
|
|
size_t bm_utf8_rune_prev(const char *string, size_t start);
|
|
|
|
size_t bm_utf8_rune_width(const char *rune, uint32_t u8len);
|
|
|
|
size_t bm_utf8_rune_remove(char *string, size_t start, size_t *out_rune_width);
|
|
|
|
size_t bm_utf8_rune_insert(char **string, size_t *bufSize, size_t start, const char *rune, uint32_t u8len, size_t *out_rune_width);
|
|
|
|
size_t bm_unicode_insert(char **string, size_t *bufSize, size_t start, uint32_t unicode, size_t *out_rune_width);
|
2022-02-19 01:00:22 +01:00
|
|
|
bool bm_menu_item_is_selected(const struct bm_menu *menu, const struct bm_item *item);
|
2014-04-10 00:09:35 +02:00
|
|
|
|
2014-10-25 00:38:30 +02:00
|
|
|
#endif /* _BEMENU_INTERNAL_H_ */
|
|
|
|
|
2014-03-28 20:33:20 +01:00
|
|
|
/* vim: set ts=8 sw=4 tw=0 :*/
|