[gtksourceview/wip/chergert/vim: 204/293] add helper to get/set/take value for current register
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 204/293] add helper to get/set/take value for current register
- Date: Fri, 5 Nov 2021 04:23:05 +0000 (UTC)
commit 0ef3f3d3478f97a41ae04630fc820771f085dae7
Author: Christian Hergert <chergert redhat com>
Date: Tue Nov 2 11:20:15 2021 -0700
add helper to get/set/take value for current register
gtksourceview/vim/gtk-source-vim-state.c | 79 ++++++++++++++++++++++
gtksourceview/vim/gtk-source-vim-state.h | 112 +++++++++++++++++--------------
2 files changed, 139 insertions(+), 52 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-state.c b/gtksourceview/vim/gtk-source-vim-state.c
index bb4b1a7e..93eff621 100644
--- a/gtksourceview/vim/gtk-source-vim-state.c
+++ b/gtksourceview/vim/gtk-source-vim-state.c
@@ -34,6 +34,7 @@ typedef struct
GtkSourceVimState *parent;
GtkSourceVimState *child;
GtkSourceView *view;
+ const char *current_register;
int count;
@@ -946,3 +947,81 @@ gtk_source_vim_state_capture (GtkSourceVimState *self,
return FALSE;
}
+
+const char *
+gtk_source_vim_state_get_current_register (GtkSourceVimState *self)
+{
+ GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+
+ g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), NULL);
+
+ if (priv->current_register != NULL)
+ {
+ return priv->current_register;
+ }
+
+ if (priv->parent != NULL)
+ {
+ return gtk_source_vim_state_get_current_register (priv->parent);
+ }
+
+ return NULL;
+}
+
+void
+gtk_source_vim_state_set_current_register (GtkSourceVimState *self,
+ const char *current_register)
+{
+ GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+
+ if (g_strcmp0 (priv->current_register, current_register) != 0)
+ {
+ priv->current_register = g_intern_string (current_register);
+ }
+}
+
+const char *
+gtk_source_vim_state_get_current_register_value (GtkSourceVimState *self)
+{
+ GtkSourceVimState *registers;
+ const char *current_register;
+
+ g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), NULL);
+
+ current_register = gtk_source_vim_state_get_current_register (self);
+ registers = gtk_source_vim_state_get_registers (self);
+
+ return gtk_source_vim_registers_get (GTK_SOURCE_VIM_REGISTERS (registers), current_register);
+}
+
+void
+gtk_source_vim_state_set_current_register_value (GtkSourceVimState *self,
+ const char *value)
+{
+ GtkSourceVimState *registers;
+ const char *current_register;
+
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+
+ current_register = gtk_source_vim_state_get_current_register (self);
+ registers = gtk_source_vim_state_get_registers (self);
+
+ gtk_source_vim_registers_set (GTK_SOURCE_VIM_REGISTERS (registers), current_register, value);
+}
+
+void
+gtk_source_vim_state_take_current_register_value (GtkSourceVimState *self,
+ char *value)
+{
+ GtkSourceVimState *registers;
+ const char *current_register;
+
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+
+ current_register = gtk_source_vim_state_get_current_register (self);
+ registers = gtk_source_vim_state_get_registers (self);
+
+ gtk_source_vim_registers_take (GTK_SOURCE_VIM_REGISTERS (registers), current_register, value);
+}
diff --git a/gtksourceview/vim/gtk-source-vim-state.h b/gtksourceview/vim/gtk-source-vim-state.h
index 71297d4c..0a751512 100644
--- a/gtksourceview/vim/gtk-source-vim-state.h
+++ b/gtksourceview/vim/gtk-source-vim-state.h
@@ -59,58 +59,66 @@ struct _GtkSourceVimStateClass
GString *string);
};
-void gtk_source_vim_state_set_parent (GtkSourceVimState *self,
- GtkSourceVimState *parent);
-void gtk_source_vim_state_push (GtkSourceVimState *self,
- GtkSourceVimState *new_state);
-void gtk_source_vim_state_pop (GtkSourceVimState *self);
-void gtk_source_vim_state_append_command (GtkSourceVimState *self,
- GString *string);
-void gtk_source_vim_state_beep (GtkSourceVimState *self);
-GtkSourceVimState *gtk_source_vim_state_get_child (GtkSourceVimState *self);
-GtkSourceVimState *gtk_source_vim_state_get_current (GtkSourceVimState *self);
-GtkSourceView *gtk_source_vim_state_get_view (GtkSourceVimState *self);
-GtkSourceBuffer *gtk_source_vim_state_get_buffer (GtkSourceVimState *self,
- GtkTextIter *insert,
- GtkTextIter *selection_bound);
-GtkSourceVimState *gtk_source_vim_state_get_root (GtkSourceVimState *self);
-GtkSourceVimState *gtk_source_vim_state_get_parent (GtkSourceVimState *self);
-GtkSourceVimState *gtk_source_vim_state_get_registers (GtkSourceVimState *self);
-int gtk_source_vim_state_get_count (GtkSourceVimState *self);
-gboolean gtk_source_vim_state_get_count_set (GtkSourceVimState *self);
-void gtk_source_vim_state_set_count (GtkSourceVimState *self,
- int count);
-gboolean gtk_source_vim_state_get_can_repeat (GtkSourceVimState *self);
-void gtk_source_vim_state_set_can_repeat (GtkSourceVimState *self,
- gboolean can_repeat);
-void gtk_source_vim_state_begin_user_action (GtkSourceVimState *self);
-void gtk_source_vim_state_end_user_action (GtkSourceVimState *self);
-gboolean gtk_source_vim_state_capture (GtkSourceVimState *self,
- GdkEvent *event);
-gboolean gtk_source_vim_state_handle_event (GtkSourceVimState *self,
- GdkEvent *event);
-void gtk_source_vim_state_set_overwrite (GtkSourceVimState *self,
- gboolean overwrite);
-gboolean gtk_source_vim_state_synthesize (GtkSourceVimState *self,
- guint keyval,
- GdkModifierType mods);
-void gtk_source_vim_state_repeat (GtkSourceVimState *self);
-int gtk_source_vim_state_get_visible_lines (GtkSourceVimState *self);
-void gtk_source_vim_state_scroll_page (GtkSourceVimState *self,
- int count);
-void gtk_source_vim_state_scroll_half_page (GtkSourceVimState *self,
- int count);
-void gtk_source_vim_state_scroll_line (GtkSourceVimState *self,
- int count);
-void gtk_source_vim_state_z_scroll (GtkSourceVimState *self,
- double yalign);
-void gtk_source_vim_state_select (GtkSourceVimState *self,
- const GtkTextIter *insert,
- const GtkTextIter *selection);
-void gtk_source_vim_state_place_cursor_onscreen (GtkSourceVimState *self);
-void gtk_source_vim_state_keyval_to_string (guint keyval,
- GdkModifierType mods,
- char str[16]);
+void gtk_source_vim_state_set_parent (GtkSourceVimState *self,
+ GtkSourceVimState *parent);
+void gtk_source_vim_state_push (GtkSourceVimState *self,
+ GtkSourceVimState *new_state);
+void gtk_source_vim_state_pop (GtkSourceVimState *self);
+void gtk_source_vim_state_append_command (GtkSourceVimState *self,
+ GString *string);
+void gtk_source_vim_state_beep (GtkSourceVimState *self);
+GtkSourceVimState *gtk_source_vim_state_get_child (GtkSourceVimState *self);
+GtkSourceVimState *gtk_source_vim_state_get_current (GtkSourceVimState *self);
+GtkSourceView *gtk_source_vim_state_get_view (GtkSourceVimState *self);
+GtkSourceBuffer *gtk_source_vim_state_get_buffer (GtkSourceVimState *self,
+ GtkTextIter *insert,
+ GtkTextIter *selection_bound);
+GtkSourceVimState *gtk_source_vim_state_get_root (GtkSourceVimState *self);
+GtkSourceVimState *gtk_source_vim_state_get_parent (GtkSourceVimState *self);
+GtkSourceVimState *gtk_source_vim_state_get_registers (GtkSourceVimState *self);
+int gtk_source_vim_state_get_count (GtkSourceVimState *self);
+gboolean gtk_source_vim_state_get_count_set (GtkSourceVimState *self);
+void gtk_source_vim_state_set_count (GtkSourceVimState *self,
+ int count);
+gboolean gtk_source_vim_state_get_can_repeat (GtkSourceVimState *self);
+void gtk_source_vim_state_set_can_repeat (GtkSourceVimState *self,
+ gboolean can_repeat);
+void gtk_source_vim_state_begin_user_action (GtkSourceVimState *self);
+void gtk_source_vim_state_end_user_action (GtkSourceVimState *self);
+gboolean gtk_source_vim_state_capture (GtkSourceVimState *self,
+ GdkEvent *event);
+gboolean gtk_source_vim_state_handle_event (GtkSourceVimState *self,
+ GdkEvent *event);
+void gtk_source_vim_state_set_overwrite (GtkSourceVimState *self,
+ gboolean overwrite);
+gboolean gtk_source_vim_state_synthesize (GtkSourceVimState *self,
+ guint keyval,
+ GdkModifierType mods);
+void gtk_source_vim_state_repeat (GtkSourceVimState *self);
+int gtk_source_vim_state_get_visible_lines (GtkSourceVimState *self);
+void gtk_source_vim_state_scroll_page (GtkSourceVimState *self,
+ int count);
+void gtk_source_vim_state_scroll_half_page (GtkSourceVimState *self,
+ int count);
+void gtk_source_vim_state_scroll_line (GtkSourceVimState *self,
+ int count);
+void gtk_source_vim_state_z_scroll (GtkSourceVimState *self,
+ double yalign);
+void gtk_source_vim_state_select (GtkSourceVimState *self,
+ const GtkTextIter *insert,
+ const GtkTextIter *selection);
+const char *gtk_source_vim_state_get_current_register (GtkSourceVimState *self);
+void gtk_source_vim_state_set_current_register (GtkSourceVimState *self,
+ const char *current_register);
+const char *gtk_source_vim_state_get_current_register_value (GtkSourceVimState *self);
+void gtk_source_vim_state_set_current_register_value (GtkSourceVimState *self,
+ const char *value);
+void gtk_source_vim_state_take_current_register_value (GtkSourceVimState *self,
+ char *value);
+void gtk_source_vim_state_place_cursor_onscreen (GtkSourceVimState *self);
+void gtk_source_vim_state_keyval_to_string (guint keyval,
+ GdkModifierType mods,
+ char str[16]);
static inline gboolean
gtk_source_vim_state_is_escape (guint keyval,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]