[gtksourceview/wip/chergert/vim] get view through helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] get view through helper
- Date: Fri, 5 Nov 2021 23:00:35 +0000 (UTC)
commit dbca0bab8ff1a9de7b535b5477d94338e0ffc9e4
Author: Christian Hergert <chergert redhat com>
Date: Fri Nov 5 15:58:55 2021 -0700
get view through helper
gtksourceview/vim/gtk-source-vim-state.c | 38 ++++++++++++++++++--------------
1 file changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-state.c b/gtksourceview/vim/gtk-source-vim-state.c
index bfa2222b..07ba0263 100644
--- a/gtksourceview/vim/gtk-source-vim-state.c
+++ b/gtksourceview/vim/gtk-source-vim-state.c
@@ -368,10 +368,10 @@ gtk_source_vim_state_get_view (GtkSourceVimState *self)
if (priv->view)
return priv->view;
- if (priv->parent)
- return gtk_source_vim_state_get_view (priv->parent);
+ if (priv->parent == NULL)
+ return NULL;
- return NULL;
+ return gtk_source_vim_state_get_view (priv->parent);
}
GtkSourceBuffer *
@@ -575,13 +575,15 @@ void
gtk_source_vim_state_set_overwrite (GtkSourceVimState *self,
gboolean overwrite)
{
- GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+ GtkSourceView *view;
g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
- if (priv->view != NULL)
+ view = gtk_source_vim_state_get_view (self);
+
+ if (view != NULL)
{
- gtk_text_view_set_overwrite (GTK_TEXT_VIEW (priv->view), overwrite);
+ gtk_text_view_set_overwrite (GTK_TEXT_VIEW (view), overwrite);
}
}
@@ -625,16 +627,18 @@ gtk_source_vim_state_select (GtkSourceVimState *self,
int
gtk_source_vim_state_get_visible_lines (GtkSourceVimState *self)
{
- GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+ GtkSourceView *view;
GtkTextIter begin, end;
GdkRectangle rect;
guint bline, eline;
g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), 2);
- gtk_text_view_get_visible_rect (GTK_TEXT_VIEW (priv->view), &rect);
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (priv->view), &begin, rect.x, rect.y);
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (priv->view), &end, rect.x, rect.y + rect.height);
+ view = gtk_source_vim_state_get_view (self);
+
+ gtk_text_view_get_visible_rect (GTK_TEXT_VIEW (view), &rect);
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), &begin, rect.x, rect.y);
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), &end, rect.x, rect.y + rect.height);
bline = gtk_text_iter_get_line (&begin);
eline = gtk_text_iter_get_line (&end);
@@ -796,29 +800,31 @@ gtk_source_vim_state_scroll_page (GtkSourceVimState *self,
void
gtk_source_vim_state_place_cursor_onscreen (GtkSourceVimState *self)
{
- GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+ GtkSourceView *view;
GtkTextIter iter;
GdkRectangle rect, loc;
gboolean move_insert = FALSE;
g_assert (GTK_SOURCE_IS_VIM_STATE (self));
+ view = gtk_source_vim_state_get_view (self);
+
gtk_source_vim_state_get_buffer (self, &iter, NULL);
- gtk_text_view_get_visible_rect (GTK_TEXT_VIEW (priv->view), &rect);
- gtk_text_view_get_iter_location (GTK_TEXT_VIEW (priv->view), &iter, &loc);
+ gtk_text_view_get_visible_rect (GTK_TEXT_VIEW (view), &rect);
+ gtk_text_view_get_iter_location (GTK_TEXT_VIEW (view), &iter, &loc);
if (loc.y < rect.y)
{
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (priv->view),
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view),
&iter, rect.x, rect.y);
move_insert = TRUE;
}
else if (loc.y + loc.height > rect.y + rect.height)
{
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (priv->view),
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view),
&iter, rect.x, rect.y + rect.height);
- gtk_text_view_get_iter_location (GTK_TEXT_VIEW (priv->view), &iter, &loc);
+ gtk_text_view_get_iter_location (GTK_TEXT_VIEW (view), &iter, &loc);
if (loc.y + loc.height > rect.y + rect.height)
gtk_text_iter_backward_line (&iter);
move_insert = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]