rofi/include/mode-private.h
Dave Davenport d27cee89fa Merging in the Recursive file browser.
Squashed commit of the following:

commit 92e730076d461622dc81e44e87ec456317514904
Author: Dave Davenport <qball@gmpclient.org>
Date:   Sun Jun 11 18:17:12 2023 +0200

    [Doc] Add regex filtering to recursivebrowser.

commit ee80c8487f9765b1e6e8ab8219a6baea089cf5af
Author: Dave Davenport <qball@gmpclient.org>
Date:   Sun Jun 11 17:49:29 2023 +0200

    [recursivebrowser] Update manpage.

commit a24b68f52362aaf1461935c2340e3bf5e31da59d
Author: Dave Davenport <qball@gmpclient.org>
Date:   Sun Jun 11 17:37:56 2023 +0200

    [Mode] Add some extra validating of the mode selected to complete.

commit cf497e8685e806521c0f61922827687adce268c9
Author: Dave Davenport <qball@gmpclient.org>
Date:   Sun Jun 4 15:12:31 2023 +0200

    [Recursive browser] Make completer selectable.

commit 722f07a803c28a406d8a610f31a24b3f7247b9ba
Author: Dave Davenport <qball@gmpclient.org>
Date:   Sun Jun 4 14:36:14 2023 +0200

    Add methods for completer to modes.

commit 7972420c30275514751802d1ed517a45bbd83da1
Author: Qball Cow <qball@blame.services>
Date:   Thu Jun 1 21:56:06 2023 +0200

    Prepare updates for new APIs.

commit dd3035a1a61f8196d394f6867701a0e1b3af30ac
Author: Dave Davenport <qball@gmpclient.org>
Date:   Wed May 10 19:24:48 2023 +0200

    [RB] Fix regex and cleanups

commit 4d2941caf32dfb946aee54c467c1319c7a89804a
Author: Dave Davenport <qball@blame.services>
Date:   Wed May 10 18:09:54 2023 +0200

    [RB] Add (unfinished regex test)

commit 848277001fc8cf9afc538067f2afa24a174f8c7f
Author: Dave Davenport <qball@blame.services>
Date:   Wed May 10 17:49:16 2023 +0200

    [RB] Pull the scanning into a separate thread.

commit f369a7f63f618bbcad10c18e73f7e2b117c515f1
Author: Dave Davenport <qball@gmpclient.org>
Date:   Wed May 3 18:35:15 2023 +0200

    [Recursive File Browser] First test version.
2023-06-12 19:07:00 +02:00

256 lines
6.7 KiB
C

/*
* rofi
*
* MIT/X11 License
* Copyright © 2013-2023 Qball Cow <qball@gmpclient.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef ROFI_MODE_PRIVATE_H
#define ROFI_MODE_PRIVATE_H
#include "mode.h"
#include <gmodule.h>
G_BEGIN_DECLS
/** ABI version to check if loaded plugin is compatible. */
#define ABI_VERSION 7u
typedef enum {
/** Mode type is not set */
MODE_TYPE_UNSET = 0b0000,
/** A normal mode. */
MODE_TYPE_SWITCHER = 0b0001,
/** A mode that can be used to completer */
MODE_TYPE_COMPLETER = 0b0010,
} ModeType;
/**
* @param data Pointer to #Mode object.
*
* Mode free function.
*/
typedef void (*_mode_free)(Mode *data);
/**
* @param sw The #Mode pointer
* @param selected_line The selected line
* @param state The state to display [out]
* @param attribute_list List of extra (pango) attribute to apply when
* displaying. [out][null]
* @param get_entry if it should only return the state
*
* Get the value for displaying.
*
* @return the string and state for displaying.
*/
typedef char *(*_mode_get_display_value)(const Mode *sw,
unsigned int selected_line, int *state,
GList **attribute_list, int get_entry);
/**
* @param sw The #Mode pointer
* @param selected_line The selected line
* @param height The height of the icon
*
* Obtains the icon if available
*
* @return Get the icon
*/
typedef cairo_surface_t *(*_mode_get_icon)(const Mode *sw,
unsigned int selected_line,
unsigned int height);
/**
* @param sw The #Mode pointer
* @param selected_line The selected line
*
* Obtains the string to complete.
*
* @return Get the completion string
*/
typedef char *(*_mode_get_completion)(const Mode *sw,
unsigned int selected_line);
/**
* @param data The #Mode pointer
* @param tokens List of (input) tokens to match.
* @param index The current selected index.
*
* Function prototype for the matching algorithm.
*
* @returns 1 when it matches, 0 if not.
*/
typedef int (*_mode_token_match)(const Mode *data, rofi_int_matcher **tokens,
unsigned int index);
/**
* @param sw The #Mode pointer
*
* Initialize the mode.
*
* @returns TRUE is successful
*/
typedef int (*__mode_init)(Mode *sw);
/**
* @param sw The #Mode pointer
*
* Get the number of entries.
*
* @returns the number of entries
*/
typedef unsigned int (*__mode_get_num_entries)(const Mode *sw);
/**
* @param sw The #Mode pointer
*
* Destroy the current mode. Still ready to restart.
*
*/
typedef void (*__mode_destroy)(Mode *sw);
/**
* @param sw The #Mode pointer
* @param menu_retv The return value
* @param input The input string
* @param selected_line The selected line
*
* Handle the user accepting an entry.
*
* @returns the next action to take
*/
typedef ModeMode (*_mode_result)(Mode *sw, int menu_retv, char **input,
unsigned int selected_line);
/**
* @param sw The #Mode pointer
* @param input The input string
*
* Preprocess the input for sorting.
*
* @returns Entry stripped from markup for sorting
*/
typedef char *(*_mode_preprocess_input)(Mode *sw, const char *input);
/**
* @param sw The #Mode pointer
*
* Message to show in the message bar.
*
* @returns the (valid pango markup) message to display.
*/
typedef char *(*_mode_get_message)(const Mode *sw);
/**
* Create a new instance of this mode.
* Free (free) result after use, after using mode_destroy.
*
* @returns Instantiate a new instance of this mode.
*/
typedef Mode *(*_mode_create)( void );
/**
* @param sw The #Mode pointer
* @param menu_retv The return value
* @param input The input string
* @param selected_line The selected line
* @param the path that was completed
*
* Handle the user accepting an entry in completion mode.
*
* @returns the next action to take
*/
typedef ModeMode (*_mode_completer_result)(Mode *sw, int menu_retv, char **input,
unsigned int selected_line, char **path);
/**
* Structure defining a switcher.
* It consists of a name, callback and if enabled
* a textbox for the sidebar-mode.
*/
struct rofi_mode {
/** Used for external plugins. */
unsigned int abi_version;
/** Name (max 31 char long) */
char *name;
char cfg_name_key[128];
char *display_name;
/**
* A switcher normally consists of the following parts:
*/
/** Initialize the Mode */
__mode_init _init;
/** Destroy the switcher, e.g. free all its memory. */
__mode_destroy _destroy;
/** Get number of entries to display. (unfiltered). */
__mode_get_num_entries _get_num_entries;
/** Process the result of the user selection. */
_mode_result _result;
/** Token match. */
_mode_token_match _token_match;
/** Get the string to display for the entry. */
_mode_get_display_value _get_display_value;
/** Get the icon for the entry. */
_mode_get_icon _get_icon;
/** Get the 'completed' entry. */
_mode_get_completion _get_completion;
_mode_preprocess_input _preprocess_input;
_mode_get_message _get_message;
/** Pointer to private data. */
void *private_data;
/**
* Free SWitcher
* Only to be used when the switcher object itself is dynamic.
* And has data in `ed`
*/
_mode_free free;
/**
* Create mode.
*/
_mode_create _create;
/**
* If this mode is used as completer.
*/
_mode_completer_result _completer_result;
/** Extra fields for script */
void *ed;
/** Module */
GModule *module;
/** Fallack icon.*/
uint32_t fallback_icon_fetch_uid;
uint32_t fallback_icon_not_found;
/** type */
ModeType type;
};
G_END_DECLS
#endif // ROFI_MODE_PRIVATE_H