[gtksourceview/wip/chergert/vim] add set text api for command bar
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] add set text api for command bar
- Date: Thu, 4 Nov 2021 16:44:03 +0000 (UTC)
commit a6471c28a296c25facde1524e5efb3967f4814a6
Author: Christian Hergert <chergert redhat com>
Date: Thu Nov 4 09:43:52 2021 -0700
add set text api for command bar
gtksourceview/vim/gtk-source-vim-command-bar.c | 20 +++++++++++++++++---
gtksourceview/vim/gtk-source-vim-command-bar.h | 4 +++-
2 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-command-bar.c b/gtksourceview/vim/gtk-source-vim-command-bar.c
index 762a78e7..f0c6bc99 100644
--- a/gtksourceview/vim/gtk-source-vim-command-bar.c
+++ b/gtksourceview/vim/gtk-source-vim-command-bar.c
@@ -148,9 +148,11 @@ gtk_source_vim_command_bar_enter (GtkSourceVimState *state)
g_assert (GTK_SOURCE_VIM_STATE (self));
- g_string_truncate (self->buffer, 0);
- g_string_append_c (self->buffer, ':');
- do_notify (self);
+ if (self->buffer->len == 0)
+ {
+ g_string_append_c (self->buffer, ':');
+ do_notify (self);
+ }
view = gtk_source_vim_state_get_view (GTK_SOURCE_VIM_STATE (self));
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
@@ -197,3 +199,15 @@ gtk_source_vim_command_bar_get_text (GtkSourceVimCommandBar *self)
return self->buffer->str;
}
+
+void
+gtk_source_vim_command_bar_set_text (GtkSourceVimCommandBar *self,
+ const char *text)
+{
+ g_return_if_fail (GTK_SOURCE_IS_VIM_COMMAND_BAR (self));
+
+ g_string_truncate (self->buffer, 0);
+ g_string_append (self->buffer, text);
+
+ do_notify (self);
+}
diff --git a/gtksourceview/vim/gtk-source-vim-command-bar.h b/gtksourceview/vim/gtk-source-vim-command-bar.h
index 2495fa8a..739cccbb 100644
--- a/gtksourceview/vim/gtk-source-vim-command-bar.h
+++ b/gtksourceview/vim/gtk-source-vim-command-bar.h
@@ -30,6 +30,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GtkSourceVimCommandBar, gtk_source_vim_command_bar, GTK_SOURCE, VIM_COMMAND_BAR,
GtkSourceVimState)
GtkSourceVimState *gtk_source_vim_command_bar_new (void);
-const char *gtk_source_vim_command_bar_get_text (GtkSourceVimCommandBar *self);
+const char *gtk_source_vim_command_bar_get_text (GtkSourceVimCommandBar *self);
+void gtk_source_vim_command_bar_set_text (GtkSourceVimCommandBar *self,
+ const char *text);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]