[gtksourceview/wip/chergert/vim: 340/363] add :nohl to hide search highlight
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 340/363] add :nohl to hide search highlight
- Date: Mon, 8 Nov 2021 19:53:56 +0000 (UTC)
commit 91a50e1ba2b9fa3aaeea059aa243fb68fc3f757f
Author: Christian Hergert <chergert redhat com>
Date: Sat Nov 6 19:23:21 2021 -0700
add :nohl to hide search highlight
gtksourceview/vim/gtk-source-vim-command.c | 32 ++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-command.c b/gtksourceview/vim/gtk-source-vim-command.c
index c8b366fb..d657b6e8 100644
--- a/gtksourceview/vim/gtk-source-vim-command.c
+++ b/gtksourceview/vim/gtk-source-vim-command.c
@@ -23,10 +23,12 @@
#include <string.h>
-#include "gtksourcebuffer.h"
-#include "gtksourcestyleschememanager.h"
-#include "gtksourcestylescheme.h"
-#include "gtksourceview.h"
+#include <gtksourceview/gtksourcebuffer.h>
+#include <gtksourceview/gtksourcesearchcontext.h>
+#include <gtksourceview/gtksourcesearchsettings.h>
+#include <gtksourceview/gtksourcestyleschememanager.h>
+#include <gtksourceview/gtksourcestylescheme.h>
+#include <gtksourceview/gtksourceview.h>
#include "gtk-source-vim.h"
#include "gtk-source-vim-char-pending.h"
@@ -608,6 +610,17 @@ gtk_source_vim_command_colorscheme (GtkSourceVimCommand *self)
g_free (stripped);
}
+static void
+gtk_source_vim_command_nohl (GtkSourceVimCommand *self)
+{
+ GtkSourceSearchContext *context;
+
+ g_assert (GTK_SOURCE_IS_VIM_COMMAND (self));
+
+ gtk_source_vim_state_get_search (GTK_SOURCE_VIM_STATE (self), NULL, &context);
+ gtk_source_search_context_set_highlight (context, FALSE);
+}
+
static void
gtk_source_vim_command_append_command (GtkSourceVimState *state,
GString *string)
@@ -863,6 +876,7 @@ gtk_source_vim_command_class_init (GtkSourceVimCommandClass *klass)
ADD_COMMAND (":delete", gtk_source_vim_command_delete);
ADD_COMMAND (":join", gtk_source_vim_command_join);
ADD_COMMAND (":j", gtk_source_vim_command_join);
+ ADD_COMMAND (":nohl", gtk_source_vim_command_nohl);
ADD_COMMAND (":undo", gtk_source_vim_command_undo);
ADD_COMMAND (":u", gtk_source_vim_command_undo);
ADD_COMMAND (":redo", gtk_source_vim_command_redo);
@@ -941,9 +955,13 @@ GtkSourceVimState *
gtk_source_vim_command_new_parsed (const char *command_line)
{
GtkSourceVimCommand *ret = NULL;
+ GtkSourceVimCommandClass *klass;
g_return_val_if_fail (command_line != NULL, NULL);
+ /* ensure class_init called */
+ klass = g_type_class_ref (GTK_SOURCE_TYPE_VIM_COMMAND);
+
/* TODO: create a real parser for this stuff */
if (g_str_has_prefix (command_line, ":colorscheme "))
@@ -951,6 +969,12 @@ gtk_source_vim_command_new_parsed (const char *command_line)
ret = GTK_SOURCE_VIM_COMMAND (gtk_source_vim_command_new (":colorscheme"));
ret->options = g_strdup (command_line + strlen (":colorscheme"));
}
+ else if (g_hash_table_contains (commands, command_line))
+ {
+ ret = GTK_SOURCE_VIM_COMMAND (gtk_source_vim_command_new (command_line));
+ }
+
+ g_type_class_unref (klass);
return GTK_SOURCE_VIM_STATE (ret);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]