types.h 7.28 KB
Newer Older
1
/* SPDX-License-Identifier: Zlib */
2 3 4 5

#ifndef GIRARA_TYPES_H
#define GIRARA_TYPES_H

6
#include "girara-version.h"
Sebastian Ramacher's avatar
Sebastian Ramacher committed
7 8
#include <stdbool.h>

9 10 11
typedef struct girara_tree_node_s girara_tree_node_t;
typedef struct girara_list_s girara_list_t;
typedef struct girara_list_iterator_s girara_list_iterator_t;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
12 13
typedef struct girara_setting_s girara_setting_t;
typedef struct girara_session_s girara_session_t;
14
typedef struct girara_session_private_s girara_session_private_t;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
typedef struct girara_command_s girara_command_t;
typedef struct girara_mouse_event_s girara_mouse_event_t;
typedef struct girara_config_handle_s girara_config_handle_t;
typedef struct girara_mode_string_s girara_mode_string_t;
typedef struct girara_tab_s girara_tab_t;
typedef struct girara_statusbar_item_s girara_statusbar_item_t;
typedef struct girara_argument_s girara_argument_t;
typedef struct girara_shortcut_mapping_s girara_shortcut_mapping_t;
typedef struct girara_argument_mapping_s girara_argument_mapping_t;
typedef struct girara_completion_element_s girara_completion_element_t;
typedef struct girara_completion_s girara_completion_t;
typedef struct girara_completion_group_s girara_completion_group_t;
typedef struct girara_shortcut_s girara_shortcut_t;
typedef struct girara_inputbar_shortcut_s girara_inputbar_shortcut_t;
typedef struct girara_special_command_s girara_special_command_t;
30
typedef struct girara_event_s girara_event_t;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

/**
 * This structure defines the possible argument identifiers
 */
enum
{
  GIRARA_HIDE = 1, /**< Hide the completion list */
  GIRARA_NEXT, /**< Next entry */
  GIRARA_PREVIOUS, /**< Previous entry */
  GIRARA_NEXT_GROUP, /**< Next group in the completion list */
  GIRARA_PREVIOUS_GROUP, /**< Previous group in the completion list */
  GIRARA_HIGHLIGHT, /**< Highlight the entry */
  GIRARA_NORMAL, /**< Set to the normal state */
  GIRARA_DELETE_LAST_WORD, /**< Delete the last word */
  GIRARA_DELETE_LAST_CHAR, /**< Delete the last character */
  GIRARA_NEXT_CHAR, /**< Go to the next character */
  GIRARA_PREVIOUS_CHAR, /**< Go to the previous character */
48 49
  GIRARA_DELETE_TO_LINE_START, /**< Delete the line to the start */
  GIRARA_DELETE_TO_LINE_END, /**< Delete the line to the end */
Moritz Lipp's avatar
Moritz Lipp committed
50
  GIRARA_DELETE_CURR_CHAR, /**< Delete current char */
51 52
  GIRARA_GOTO_START, /**< Go to start of the line */
  GIRARA_GOTO_END /**< Go to end of the line */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66
};

/**
 * Mode identifier
 */
typedef int girara_mode_t;

/**
 * Function declaration of a function that generates a completion group
 *
 * @param session The current girara session
 * @param input The current input
 * @return The completion group
 */
Moritz Lipp's avatar
Moritz Lipp committed
67 68
typedef girara_completion_t* (*girara_completion_function_t)(
    girara_session_t* session, const char* input);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
69 70 71 72 73 74 75

/**
 * Function declaration of a inputbar special function
 *
 * @param session The current girara session
 * @param input The current input
 * @param argument The given argument
76 77
 * @return TRUE No error occurred
 * @return FALSE Error occurred
Sebastian Ramacher's avatar
Sebastian Ramacher committed
78
 */
Moritz Lipp's avatar
Moritz Lipp committed
79 80
typedef bool (*girara_inputbar_special_function_t)(girara_session_t* session,
    const char* input, girara_argument_t* argument);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
81 82 83 84 85 86 87 88

/**
 * Function declaration of a command function
 *
 * @param session The current girara session
 * @param argc Number of arguments
 * @param argv Arguments
 */
Moritz Lipp's avatar
Moritz Lipp committed
89 90
typedef bool (*girara_command_function_t)(girara_session_t* session,
    girara_list_t* argument_list);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
91 92 93 94 95 96 97 98

/**
 * Function declaration of a shortcut function
 *
 * If a numeric value has been written into the buffer, this function gets as
 * often executed as the value defines or until the function returns false the
 * first time.
 */
Moritz Lipp's avatar
Moritz Lipp committed
99 100
typedef bool (*girara_shortcut_function_t)(girara_session_t*,
    girara_argument_t*, girara_event_t*, unsigned int);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132

/**
 * Function declaration of a function that frees something.
 *
 * @param data the data to be freed.
 */
typedef void (*girara_free_function_t)(void* data);

/** Function declaration of a function called as callback from girara_list_*
 * functions.
 *
 * @param data a list element.
 * @param userdata data passed as userdata to the calling function.
 */
typedef void (*girara_list_callback_t)(void* data, void* userdata);

/** Function declaration of a function which compares two elements.
 *
 * @param data1 the first element.
 * @param data2 the second element.
 * @return -1 if data1 < data2, 0 if data1 == data2 and 1 if data1 > data2
 */
typedef int (*girara_compare_function_t)(const void* data1, const void* data2);

/**
 * This structure defines the possible types that a setting value can have
 */
typedef enum girara_setting_type_e
{
  BOOLEAN, /**< Boolean type */
  FLOAT, /**< Floating number */
  INT, /**< Integer */
133 134
  STRING, /**< String */
  UNKNOWN = 0xFFFF /**< Unknown type */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
135
} girara_setting_type_t;
136

Sebastian Ramacher's avatar
Sebastian Ramacher committed
137 138 139 140
/**
 * Function declaration for a settings callback
 *
 * @param session The current girara session
141
 * @param name The name of the affected setting
Sebastian Ramacher's avatar
Sebastian Ramacher committed
142 143 144
 * @param type The type of the affected setting
 * @param value Pointer to the new value
 * @param data User data
Sebastian Ramacher's avatar
Sebastian Ramacher committed
145
 */
Moritz Lipp's avatar
Moritz Lipp committed
146
typedef void (*girara_setting_callback_t)(girara_session_t* session,
Sebastian Ramacher's avatar
Sebastian Ramacher committed
147
    const char* name, girara_setting_type_t type, const void* value, void* data);
148

Sebastian Ramacher's avatar
Sebastian Ramacher committed
149 150 151 152 153 154 155 156 157
/**
 * Definition of an argument of a shortcut or buffered command
 */
struct girara_argument_s
{
  int   n; /**< Identifier */
  void *data; /**< Data */
};

Moritz Lipp's avatar
Moritz Lipp committed
158 159 160 161 162 163 164 165 166
/**
 * Define mouse buttons
 */
typedef enum girara_mouse_button_e
{
  GIRARA_MOUSE_BUTTON1 = 1, /**< Button 1 */
  GIRARA_MOUSE_BUTTON2 = 2, /**< Button 2 */
  GIRARA_MOUSE_BUTTON3 = 3, /**< Button 3 */
  GIRARA_MOUSE_BUTTON4 = 4, /**< Button 4 */
167 168 169 170 171
  GIRARA_MOUSE_BUTTON5 = 5, /**< Button 5 */
  GIRARA_MOUSE_BUTTON6 = 6, /**< Button 6 */
  GIRARA_MOUSE_BUTTON7 = 7, /**< Button 7 */
  GIRARA_MOUSE_BUTTON8 = 8, /**< Button 8 */
  GIRARA_MOUSE_BUTTON9 = 9  /**< Button 9 */
Moritz Lipp's avatar
Moritz Lipp committed
172 173 174 175 176
} girara_mouse_button_t;

/**
 * Describes the types of a girara
 */
177 178 179
typedef enum girara_event_type_e
{
  GIRARA_EVENT_BUTTON_PRESS, /**< Single click */
Moritz Lipp's avatar
Moritz Lipp committed
180 181
  GIRARA_EVENT_2BUTTON_PRESS, /**< Double click */
  GIRARA_EVENT_3BUTTON_PRESS, /**< Triple click */
182
  GIRARA_EVENT_BUTTON_RELEASE, /**< Button released */
Moritz Lipp's avatar
Moritz Lipp committed
183
  GIRARA_EVENT_MOTION_NOTIFY, /**< Cursor moved */
Moritz Lipp's avatar
Moritz Lipp committed
184 185 186 187
  GIRARA_EVENT_SCROLL_UP, /**< Scroll event */
  GIRARA_EVENT_SCROLL_DOWN, /**< Scroll event */
  GIRARA_EVENT_SCROLL_LEFT, /**< Scroll event */
  GIRARA_EVENT_SCROLL_RIGHT, /**< Scroll event */
188 189 190 191 192 193 194
  GIRARA_EVENT_OTHER, /**< Unknown event */
  GIRARA_EVENT_SCROLL_BIDIRECTIONAL /**< Scroll event that carries extra data
                                     *   in girara_argument_t with motion
                                     *   information as double[2].
                                     *   First component is horizontal shift,
                                     *   second - vertical.
                                     */
195 196
} girara_event_type_t;

Moritz Lipp's avatar
Moritz Lipp committed
197 198 199
/**
 * Describes a girara event
 */
200 201 202
struct girara_event_s
{
  girara_event_type_t type; /**< The event type */
Moritz Lipp's avatar
Moritz Lipp committed
203

204 205
  double x; /**< X coordinates where the event occurred */
  double y; /**< Y coordinates where the event occurred */
206 207
};

208 209
typedef struct girara_input_history_io_s GiraraInputHistoryIO;
typedef struct girara_input_history_io_interface_s GiraraInputHistoryIOInterface;
210 211 212
typedef struct girara_input_history_s GiraraInputHistory;
typedef struct girara_input_history_class_s GiraraInputHistoryClass;

213 214 215
typedef struct girara_template_s GiraraTemplate;
typedef struct girara_template_class_s GiraraTemplateClass;

216
#endif