6 G_DEFINE_TYPE(GiraraInputHistory, girara_input_history, G_TYPE_OBJECT)
11 typedef struct ih_private_s {
20 #define GIRARA_INPUT_HISTORY_GET_PRIVATE(obj) \
21 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIRARA_TYPE_INPUT_HISTORY, \
25 static void ih_finalize(GObject*
object);
26 static void ih_set_property(GObject*
object, guint prop_id,
27 const GValue*
value, GParamSpec* pspec);
28 static void ih_get_property(GObject*
object, guint prop_id, GValue*
value,
30 static void ih_append(GiraraInputHistory* history,
const char* input);
31 static girara_list_t* ih_list(GiraraInputHistory* history);
32 static const char* ih_next(GiraraInputHistory* history,
33 const char* current_input);
34 static const char* ih_previous(GiraraInputHistory* history,
35 const char* current_input);
36 static void ih_reset(GiraraInputHistory* history);
46 girara_input_history_class_init(GiraraInputHistoryClass*
class)
52 GObjectClass* object_class = G_OBJECT_CLASS(
class);
53 object_class->finalize = ih_finalize;
54 object_class->set_property = ih_set_property;
55 object_class->get_property = ih_get_property;
57 class->append = ih_append;
58 class->list = ih_list;
59 class->next = ih_next;
60 class->previous = ih_previous;
61 class->reset = ih_reset;
64 g_object_class_install_property(object_class,
PROP_IO,
65 g_param_spec_object(
"io",
"history reader/writer",
66 "GiraraInputHistoryIO object used to read and write history",
68 G_PARAM_WRITABLE | G_PARAM_READABLE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
73 girara_input_history_init(GiraraInputHistory* history)
83 ih_finalize(GObject*
object)
89 if (priv->
io != NULL) {
90 g_object_unref(priv->
io);
93 G_OBJECT_CLASS(girara_input_history_parent_class)->finalize(
object);
98 ih_set_property(GObject*
object, guint prop_id,
const GValue*
value,
105 if (priv->
io != NULL) {
106 g_object_unref(priv->
io);
109 gpointer* tmp = g_value_dup_object(value);
119 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
125 ih_get_property(GObject*
object, guint prop_id, GValue* value,
132 g_value_set_object(value, priv->
io);
135 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
150 ih_append(GiraraInputHistory* history,
const char* input)
169 if (priv->
io != NULL) {
177 static girara_list_t*
178 ih_list(GiraraInputHistory* history)
185 find_next(GiraraInputHistory* history,
const char* current_input,
bool next)
199 if (priv->
reset ==
true) {
211 const char* command = NULL;
213 if (priv->
reset ==
true || next ==
false) {
221 }
else if (next ==
true) {
222 if (priv->
current + 1 >= length) {
235 if (command == NULL) {
257 ih_next(GiraraInputHistory* history,
const char* current_input)
259 return find_next(history, current_input,
true);
263 ih_previous(GiraraInputHistory* history,
const char* current_input)
265 return find_next(history, current_input,
false);
269 ih_reset(GiraraInputHistory* history)
274 if (priv->
io != NULL) {
282 if (newlist != NULL) {
void girara_list_remove(girara_list_t *list, void *data)
void * girara_list_nth(girara_list_t *list, size_t n)
#define GIRARA_INPUT_HISTORY(obj)
void girara_list_append(girara_list_t *list, void *data)
GType girara_input_history_io_get_type(void)
void(* girara_free_function_t)(void *data)
size_t girara_list_size(girara_list_t *list)
girara_list_t * girara_list_new2(girara_free_function_t gfree)
#define GIRARA_INPUT_HISTORY_IO(obj)
#define GIRARA_INPUT_HISTORY_GET_PRIVATE(obj)
void girara_list_free(girara_list_t *list)
struct girara_input_history_io_s GiraraInputHistoryIO
void * girara_list_find(girara_list_t *list, girara_compare_function_t compare, const void *data)
int(* girara_compare_function_t)(const void *data1, const void *data2)
void girara_input_history_io_append(GiraraInputHistoryIO *io, const char *input)
GiraraInputHistoryIO * io
void girara_input_history_reset(GiraraInputHistory *history)
const char * girara_input_history_previous(GiraraInputHistory *history, const char *current_input)
girara_completion_group_t *group value
GIRARA_LIST_FOREACH_END(session->bindings.mouse_events, girara_mouse_event_t *, iter, mouse_event)
#define GIRARA_IS_INPUT_HISTORY(obj)
girara_list_t * girara_input_history_list(GiraraInputHistory *history)
const char * girara_input_history_next(GiraraInputHistory *history, const char *current_input)
g_return_val_if_fail(button!=NULL, false)
girara_list_t * girara_input_history_io_read(GiraraInputHistoryIO *io)
#define GIRARA_INPUT_HISTORY_GET_CLASS(obj)
GiraraInputHistory * girara_input_history_new(GiraraInputHistoryIO *io)
void girara_list_clear(girara_list_t *list)
#define GIRARA_TYPE_INPUT_HISTORY
void girara_input_history_append(GiraraInputHistory *history, const char *input)
#define GIRARA_LIST_FOREACH(list, type, iter, data)