[gtksourceview/wip/chergert/vim] fix spacing
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] fix spacing
- Date: Wed, 20 Oct 2021 18:50:25 +0000 (UTC)
commit d0a665a35d346bd63827a8743c77192bef6f3c0a
Author: Christian Hergert <chergert redhat com>
Date: Wed Oct 20 11:46:33 2021 -0700
fix spacing
gtksourceview/gtksourcevimstate.c | 344 +++++++++++++++++++-------------------
gtksourceview/gtksourcevimstate.h | 30 ++--
2 files changed, 186 insertions(+), 188 deletions(-)
---
diff --git a/gtksourceview/gtksourcevimstate.c b/gtksourceview/gtksourcevimstate.c
index cb7a0f70..15a6aea5 100644
--- a/gtksourceview/gtksourcevimstate.c
+++ b/gtksourceview/gtksourcevimstate.c
@@ -26,19 +26,19 @@
typedef struct
{
- GtkSourceVimState *parent;
- GtkSourceView *view;
+ GtkSourceVimState *parent;
+ GtkSourceView *view;
} GtkSourceVimStatePrivate;
struct _GtkSourceVimNormal
{
- GtkSourceVimState parent_instance;
- GString *command;
+ GtkSourceVimState parent_instance;
+ GString *command;
};
struct _GtkSourceVimInsert
{
- GtkSourceVimState parent_instance;
+ GtkSourceVimState parent_instance;
};
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkSourceVimState, gtk_source_vim_state, G_TYPE_OBJECT)
@@ -46,10 +46,10 @@ G_DEFINE_TYPE (GtkSourceVimNormal, gtk_source_vim_normal, GTK_SOURCE_TYPE_VIM_ST
G_DEFINE_TYPE (GtkSourceVimInsert, gtk_source_vim_insert, GTK_SOURCE_TYPE_VIM_STATE)
enum {
- STATE_PROP_0,
- STATE_PROP_PARENT,
- STATE_PROP_VIEW,
- STATE_N_PROPS
+ STATE_PROP_0,
+ STATE_PROP_PARENT,
+ STATE_PROP_VIEW,
+ STATE_N_PROPS
};
static GParamSpec *state_properties [STATE_N_PROPS];
@@ -58,60 +58,60 @@ static inline char *
get_key_string (guint keyval,
char str[8])
{
- if (keyval == GDK_KEY_Escape)
- {
- str[0] = '^';
- str[1] = '[';
- str[2] = 0;
- }
- else if (keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter)
- {
- str[0] = '^';
- str[1] = 'M';
- str[2] = 0;
- }
- else
- {
- gunichar ch = gdk_keyval_to_unicode (keyval);
- int len = g_unichar_to_utf8 (ch, str);
- str[len] = 0;
- }
-
- return str;
+ if (keyval == GDK_KEY_Escape)
+ {
+ str[0] = '^';
+ str[1] = '[';
+ str[2] = 0;
+ }
+ else if (keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter)
+ {
+ str[0] = '^';
+ str[1] = 'M';
+ str[2] = 0;
+ }
+ else
+ {
+ gunichar ch = gdk_keyval_to_unicode (keyval);
+ int len = g_unichar_to_utf8 (ch, str);
+ str[len] = 0;
+ }
+
+ return str;
}
static gboolean
gtk_source_vim_state_real_handle (GtkSourceVimState *self,
GdkEvent *event)
{
- char string[8];
- GdkModifierType mods;
- guint keyval;
- guint keycode;
+ char string[8];
+ GdkModifierType mods;
+ guint keyval;
+ guint keycode;
- if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
- return FALSE;
+ if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
+ return FALSE;
- if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->handle_keypress == NULL)
- return FALSE;
+ if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->handle_keypress == NULL)
+ return FALSE;
- keyval = gdk_key_event_get_keyval (event);
- keycode = gdk_key_event_get_keycode (event);
- mods = gdk_key_event_get_consumed_modifiers (event);
- get_key_string (keyval, string);
+ keyval = gdk_key_event_get_keyval (event);
+ keycode = gdk_key_event_get_keycode (event);
+ mods = gdk_key_event_get_consumed_modifiers (event);
+ get_key_string (keyval, string);
- return GTK_SOURCE_VIM_STATE_GET_CLASS (self)->handle_keypress (self, keyval, keycode, mods, string);
+ return GTK_SOURCE_VIM_STATE_GET_CLASS (self)->handle_keypress (self, keyval, keycode, mods, string);
}
static void
gtk_source_vim_state_dispose (GObject *object)
{
- GtkSourceVimState *self = (GtkSourceVimState *)object;
- GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+ GtkSourceVimState *self = (GtkSourceVimState *)object;
+ GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
- g_clear_object (&priv->parent);
+ g_clear_object (&priv->parent);
- G_OBJECT_CLASS (gtk_source_vim_state_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gtk_source_vim_state_parent_class)->dispose (object);
}
static void
@@ -120,21 +120,20 @@ gtk_source_vim_state_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GtkSourceVimState *self = GTK_SOURCE_VIM_STATE (object);
+ GtkSourceVimState *self = GTK_SOURCE_VIM_STATE (object);
- switch (prop_id)
- {
- case STATE_PROP_PARENT:
- g_value_set_object (value, gtk_source_vim_state_get_parent (self));
- break;
+ switch (prop_id) {
+ case STATE_PROP_PARENT:
+ g_value_set_object (value, gtk_source_vim_state_get_parent (self));
+ break;
- case STATE_PROP_VIEW:
- g_value_set_object (value, gtk_source_vim_state_get_view (self));
- break;
+ case STATE_PROP_VIEW:
+ g_value_set_object (value, gtk_source_vim_state_get_view (self));
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
@@ -143,50 +142,49 @@ gtk_source_vim_state_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GtkSourceVimState *self = GTK_SOURCE_VIM_STATE (object);
- GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
-
- switch (prop_id)
- {
- case STATE_PROP_PARENT:
- priv->parent = g_value_dup_object (value);
- break;
-
- case STATE_PROP_VIEW:
- priv->view = g_value_dup_object (value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ GtkSourceVimState *self = GTK_SOURCE_VIM_STATE (object);
+ GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+
+ switch (prop_id) {
+ case STATE_PROP_PARENT:
+ priv->parent = g_value_dup_object (value);
+ break;
+
+ case STATE_PROP_VIEW:
+ priv->view = g_value_dup_object (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
gtk_source_vim_state_class_init (GtkSourceVimStateClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = gtk_source_vim_state_dispose;
- object_class->get_property = gtk_source_vim_state_get_property;
- object_class->set_property = gtk_source_vim_state_set_property;
+ object_class->dispose = gtk_source_vim_state_dispose;
+ object_class->get_property = gtk_source_vim_state_get_property;
+ object_class->set_property = gtk_source_vim_state_set_property;
- klass->handle = gtk_source_vim_state_real_handle;
+ klass->handle = gtk_source_vim_state_real_handle;
- state_properties [STATE_PROP_PARENT] =
- g_param_spec_object ("parent",
- "Parent",
- "The parent state",
- GTK_SOURCE_TYPE_VIM_STATE,
- (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ state_properties [STATE_PROP_PARENT] =
+ g_param_spec_object ("parent",
+ "Parent",
+ "The parent state",
+ GTK_SOURCE_TYPE_VIM_STATE,
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
- state_properties [STATE_PROP_VIEW] =
- g_param_spec_object ("view",
- "View",
- "The source view",
- GTK_SOURCE_TYPE_VIEW,
- (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ state_properties [STATE_PROP_VIEW] =
+ g_param_spec_object ("view",
+ "View",
+ "The source view",
+ GTK_SOURCE_TYPE_VIEW,
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
- g_object_class_install_properties (object_class, STATE_N_PROPS, state_properties);
+ g_object_class_install_properties (object_class, STATE_N_PROPS, state_properties);
}
static void
@@ -198,26 +196,26 @@ void
gtk_source_vim_state_get_iter (GtkSourceVimState *self,
GtkTextIter *iter)
{
- GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
- GtkTextBuffer *buffer;
- GtkTextMark *mark;
+ GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+ GtkTextBuffer *buffer;
+ GtkTextMark *mark;
- g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
- g_return_if_fail (iter != NULL);
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+ g_return_if_fail (iter != NULL);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->view));
- mark = gtk_text_buffer_get_insert (buffer);
- gtk_text_buffer_get_iter_at_mark (buffer, iter, mark);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->view));
+ mark = gtk_text_buffer_get_insert (buffer);
+ gtk_text_buffer_get_iter_at_mark (buffer, iter, mark);
}
void
gtk_source_vim_state_move_to (GtkSourceVimState *self,
const GtkTextIter *iter)
{
- g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
- g_return_if_fail (iter != NULL);
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+ g_return_if_fail (iter != NULL);
- gtk_text_buffer_select_range (gtk_text_iter_get_buffer (iter), iter, iter);
+ gtk_text_buffer_select_range (gtk_text_iter_get_buffer (iter), iter, iter);
}
/**
@@ -228,11 +226,11 @@ gtk_source_vim_state_move_to (GtkSourceVimState *self,
GtkSourceVimState *
gtk_source_vim_state_get_parent (GtkSourceVimState *self)
{
- GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+ GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
- g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), NULL);
+ g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), NULL);
- return priv->parent;
+ return priv->parent;
}
/**
@@ -243,11 +241,11 @@ gtk_source_vim_state_get_parent (GtkSourceVimState *self)
GtkSourceView *
gtk_source_vim_state_get_view (GtkSourceVimState *self)
{
- GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+ GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
- g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), NULL);
+ g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), NULL);
- return priv->view;
+ return priv->view;
}
/**
@@ -259,10 +257,10 @@ gtk_source_vim_state_get_view (GtkSourceVimState *self)
void
gtk_source_vim_state_enter (GtkSourceVimState *self)
{
- g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
- if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->enter)
- GTK_SOURCE_VIM_STATE_GET_CLASS (self)->enter (self);
+ if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->enter)
+ GTK_SOURCE_VIM_STATE_GET_CLASS (self)->enter (self);
}
/**
@@ -274,10 +272,10 @@ gtk_source_vim_state_enter (GtkSourceVimState *self)
void
gtk_source_vim_state_leave (GtkSourceVimState *self)
{
- g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
- if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->leave)
- GTK_SOURCE_VIM_STATE_GET_CLASS (self)->leave (self);
+ if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->leave)
+ GTK_SOURCE_VIM_STATE_GET_CLASS (self)->leave (self);
}
/**
@@ -290,11 +288,11 @@ void
gtk_source_vim_state_suspend (GtkSourceVimState *self,
GtkSourceVimState *to)
{
- g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
- g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (to));
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (to));
- if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->suspend)
- GTK_SOURCE_VIM_STATE_GET_CLASS (self)->suspend (self, to);
+ if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->suspend)
+ GTK_SOURCE_VIM_STATE_GET_CLASS (self)->suspend (self, to);
}
/**
@@ -308,11 +306,11 @@ void
gtk_source_vim_state_restore (GtkSourceVimState *self,
GtkSourceVimState *from)
{
- g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
- g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (from));
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+ g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (from));
- if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->restore)
- GTK_SOURCE_VIM_STATE_GET_CLASS (self)->restore (self, from);
+ if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->restore)
+ GTK_SOURCE_VIM_STATE_GET_CLASS (self)->restore (self, from);
}
/**
@@ -324,20 +322,20 @@ gboolean
gtk_source_vim_state_handle (GtkSourceVimState *self,
GdkEvent *event)
{
- g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
+ g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
- if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->handle)
- return GTK_SOURCE_VIM_STATE_GET_CLASS (self)->handle (self, event);
+ if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->handle)
+ return GTK_SOURCE_VIM_STATE_GET_CLASS (self)->handle (self, event);
- return FALSE;
+ return FALSE;
}
static gboolean
gtk_source_vim_normal_is_command (GtkSourceVimNormal *self,
const char *command)
{
- return FALSE;
+ return FALSE;
}
static gboolean
@@ -347,91 +345,91 @@ gtk_source_vim_normal_handle_keypress (GtkSourceVimState *state,
GdkModifierType mods,
const char *str)
{
- GtkSourceVimNormal *self = (GtkSourceVimNormal *)state;
+ GtkSourceVimNormal *self = (GtkSourceVimNormal *)state;
- g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
+ g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
- /* Fail, bail, etc? */
- if (str == NULL)
- return FALSE;
+ /* Fail, bail, etc? */
+ if (str == NULL)
+ return FALSE;
- /* TODO:
- *
- * if string is a number, then we can only have trailing
- * numbers in the command. we also need to check if the str
- * will terminate the command (cCaAiI etc).
- */
+ /* TODO:
+ *
+ * if string is a number, then we can only have trailing
+ * numbers in the command. we also need to check if the str
+ * will terminate the command (cCaAiI etc).
+ */
- g_string_append (self->command, str);
+ g_string_append (self->command, str);
- if (gtk_source_vim_normal_is_command (self, self->command->str))
- {
- }
+ if (gtk_source_vim_normal_is_command (self, self->command->str))
+ {
+ }
- return FALSE;
+ return FALSE;
}
static void
gtk_source_vim_normal_restore (GtkSourceVimState *state,
GtkSourceVimState *from)
{
- GtkSourceVimNormal *self = (GtkSourceVimNormal *)state;
+ GtkSourceVimNormal *self = (GtkSourceVimNormal *)state;
- g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
+ g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
- /* If we have a count to repeat, then we should perform that now. */
+ /* If we have a count to repeat, then we should perform that now. */
- /* If we are restoring from an insert, then we need to move
- * the cursor back one character so the block cursor appears
- * on the right character.
- */
- if (GTK_SOURCE_IS_VIM_INSERT (from))
- {
- GtkTextIter iter;
+ /* If we are restoring from an insert, then we need to move
+ * the cursor back one character so the block cursor appears
+ * on the right character.
+ */
+ if (GTK_SOURCE_IS_VIM_INSERT (from))
+ {
+ GtkTextIter iter;
- gtk_source_vim_state_get_iter (state, &iter);
+ gtk_source_vim_state_get_iter (state, &iter);
- if (!gtk_text_iter_starts_line (&iter))
- {
- gtk_text_iter_backward_char (&iter);
- gtk_source_vim_state_move_to (state, &iter);
- }
- }
+ if (!gtk_text_iter_starts_line (&iter))
+ {
+ gtk_text_iter_backward_char (&iter);
+ gtk_source_vim_state_move_to (state, &iter);
+ }
+ }
}
static void
gtk_source_vim_normal_finalize (GObject *object)
{
- GtkSourceVimNormal *self = (GtkSourceVimNormal *)object;
+ GtkSourceVimNormal *self = (GtkSourceVimNormal *)object;
- g_string_free (self->command, TRUE);
- self->command = NULL;
+ g_string_free (self->command, TRUE);
+ self->command = NULL;
- G_OBJECT_CLASS (gtk_source_vim_normal_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtk_source_vim_normal_parent_class)->finalize (object);
}
static void
gtk_source_vim_normal_class_init (GtkSourceVimNormalClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkSourceVimStateClass *state_class = GTK_SOURCE_VIM_STATE_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkSourceVimStateClass *state_class = GTK_SOURCE_VIM_STATE_CLASS (klass);
- object_class->finalize = gtk_source_vim_normal_finalize;
+ object_class->finalize = gtk_source_vim_normal_finalize;
- state_class->handle_keypress = gtk_source_vim_normal_handle_keypress;
- state_class->restore = gtk_source_vim_normal_restore;
+ state_class->handle_keypress = gtk_source_vim_normal_handle_keypress;
+ state_class->restore = gtk_source_vim_normal_restore;
}
static void
gtk_source_vim_normal_init (GtkSourceVimNormal *self)
{
- self->command = g_string_new (NULL);
+ self->command = g_string_new (NULL);
}
static void
gtk_source_vim_insert_class_init (GtkSourceVimInsertClass *klass)
{
- GtkSourceVimStateClass *state_class = GTK_SOURCE_VIM_STATE_CLASS (klass);
+ GtkSourceVimStateClass *state_class = GTK_SOURCE_VIM_STATE_CLASS (klass);
}
static void
diff --git a/gtksourceview/gtksourcevimstate.h b/gtksourceview/gtksourcevimstate.h
index abcd6917..1422f90c 100644
--- a/gtksourceview/gtksourcevimstate.h
+++ b/gtksourceview/gtksourcevimstate.h
@@ -21,7 +21,7 @@
#pragma once
-#include <gdk/gdk.h>
+#include <gtk/gtk.h>
#include "gtksourcetypes.h"
#include "gtksourcetypes-private.h"
@@ -34,21 +34,21 @@ G_DECLARE_DERIVABLE_TYPE (GtkSourceVimState, gtk_source_vim_state, GTK_SOURCE, V
struct _GtkSourceVimStateClass
{
- GObject parent_class;
+ GObject parent_class;
- void (*enter) (GtkSourceVimState *state);
- void (*leave) (GtkSourceVimState *state);
- void (*suspend) (GtkSourceVimState *state,
- GtkSourceVimState *to);
- void (*restore) (GtkSourceVimState *state,
- GtkSourceVimState *from);
- gboolean (*handle) (GtkSourceVimState *state,
- GdkEvent *event);
- gboolean (*handle_keypress) (GtkSourceVimState *state,
- guint keyval,
- guint keycode,
- GdkModifierType mods,
- const char *string);
+ void (*enter) (GtkSourceVimState *state);
+ void (*leave) (GtkSourceVimState *state);
+ void (*suspend) (GtkSourceVimState *state,
+ GtkSourceVimState *to);
+ void (*restore) (GtkSourceVimState *state,
+ GtkSourceVimState *from);
+ gboolean (*handle) (GtkSourceVimState *state,
+ GdkEvent *event);
+ gboolean (*handle_keypress) (GtkSourceVimState *state,
+ guint keyval,
+ guint keycode,
+ GdkModifierType mods,
+ const char *string);
};
GtkSourceVimState *gtk_source_vim_state_get_parent (GtkSourceVimState *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]