Commit b49b2da6 authored by Christian Hergert's avatar Christian Hergert
Browse files

simplify

parent bd42bc9c
......@@ -103,11 +103,13 @@ key_handler_repeat (GtkSourceVimNormal *self,
return TRUE;
}
static void
static GtkSourceVimState *
begin_insert (GtkSourceVimNormal *self,
GtkSourceVimState *motion,
gboolean after_char)
{
GtkSourceVimState *ret;
g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
g_assert (!motion || GTK_SOURCE_IS_VIM_MOTION (motion));
......@@ -126,7 +128,9 @@ begin_insert (GtkSourceVimNormal *self,
gtk_source_vim_state_select (GTK_SOURCE_VIM_STATE (self), &iter, &iter);
}
gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), gtk_source_vim_insert_new ());
ret = gtk_source_vim_insert_new ();
gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), ret);
return ret;
}
static gboolean
......@@ -175,8 +179,7 @@ key_handler_command (GtkSourceVimNormal *self,
switch (keyval)
{
case GDK_KEY_i:
new_state = gtk_source_vim_insert_new ();
gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), new_state);
begin_insert (self, gtk_source_vim_motion_new_none (), FALSE);
return TRUE;
case GDK_KEY_R:
......@@ -185,13 +188,15 @@ key_handler_command (GtkSourceVimNormal *self,
return TRUE;
case GDK_KEY_I:
new_state = gtk_source_vim_motion_new_first_char ();
begin_insert (self, new_state, FALSE);
begin_insert (self, gtk_source_vim_motion_new_first_char (), FALSE);
return TRUE;
case GDK_KEY_A:
new_state = gtk_source_vim_motion_new_line_end ();
begin_insert (self, new_state, TRUE);
begin_insert (self, gtk_source_vim_motion_new_line_end (), TRUE);
return TRUE;
case GDK_KEY_o:
new_state = begin_insert (self, gtk_source_vim_motion_new_line_end (), TRUE);
return TRUE;
case GDK_KEY_a:
......@@ -199,7 +204,6 @@ key_handler_command (GtkSourceVimNormal *self,
case GDK_KEY_C:
case GDK_KEY_D:
case GDK_KEY_J:
case GDK_KEY_o:
case GDK_KEY_O:
case GDK_KEY_p:
case GDK_KEY_P:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment