[gtksourceview/wip/chergert/vim: 203/363] add helper to check for readonly registers




commit 5d468e615a37121d21ebeb1c98b9c9797f9fa03b
Author: Christian Hergert <chergert redhat com>
Date:   Tue Nov 2 12:56:32 2021 -0700

    add helper to check for readonly registers

 gtksourceview/vim/gtk-source-vim-registers.c | 14 ++++++++++++++
 gtksourceview/vim/gtk-source-vim-registers.h |  1 +
 2 files changed, 15 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-registers.c b/gtksourceview/vim/gtk-source-vim-registers.c
index 81d15f09..af55ec4e 100644
--- a/gtksourceview/vim/gtk-source-vim-registers.c
+++ b/gtksourceview/vim/gtk-source-vim-registers.c
@@ -185,3 +185,17 @@ gtk_source_vim_registers_clear (GtkSourceVimRegisters *self,
 {
        gtk_source_vim_registers_set (self, name, NULL);
 }
+
+gboolean
+gtk_source_vim_register_is_read_only (const char *name)
+{
+       switch (name ? name[0] : 0)
+       {
+       case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
+       case '%': case '.': case '#': case ':':
+               return TRUE;
+
+       default:
+               return FALSE;
+       }
+}
diff --git a/gtksourceview/vim/gtk-source-vim-registers.h b/gtksourceview/vim/gtk-source-vim-registers.h
index 5b27b592..750f9bc7 100644
--- a/gtksourceview/vim/gtk-source-vim-registers.h
+++ b/gtksourceview/vim/gtk-source-vim-registers.h
@@ -39,5 +39,6 @@ void               gtk_source_vim_registers_set          (GtkSourceVimRegisters
                                                           const char            *string);
 void               gtk_source_vim_registers_clear        (GtkSourceVimRegisters *self,
                                                           const char            *name);
+gboolean           gtk_source_vim_register_is_read_only  (const char            *name);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]