[gtksourceview/wip/chergert/vim: 211/363] add upcase/downcase commands
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 211/363] add upcase/downcase commands
- Date: Mon, 8 Nov 2021 19:53:51 +0000 (UTC)
commit 0fc504e2e20450797e65c98681e96bdd250c3332
Author: Christian Hergert <chergert redhat com>
Date: Tue Nov 2 13:51:01 2021 -0700
add upcase/downcase commands
these are the name they have in vim (which is what?) so we don't use the
: prefix on them.
gtksourceview/vim/gtk-source-vim-command.c | 35 ++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-command.c b/gtksourceview/vim/gtk-source-vim-command.c
index 1abaa222..6b133445 100644
--- a/gtksourceview/vim/gtk-source-vim-command.c
+++ b/gtksourceview/vim/gtk-source-vim-command.c
@@ -280,6 +280,39 @@ gtk_source_vim_command_toggle_case (GtkSourceVimCommand *self)
self->ignore_mark = TRUE;
}
+static void
+gtk_source_vim_command_change_case (GtkSourceVimCommand *self,
+ GtkSourceChangeCaseType case_type)
+{
+ GtkSourceBuffer *buffer;
+ GtkTextIter iter;
+ GtkTextIter selection;
+
+ buffer = gtk_source_vim_state_get_buffer (GTK_SOURCE_VIM_STATE (self), &iter, &selection);
+
+ gtk_text_iter_order (&iter, &selection);
+
+ gtk_source_vim_state_begin_user_action (GTK_SOURCE_VIM_STATE (self));
+ gtk_source_buffer_change_case (buffer, case_type, &iter, &selection);
+ gtk_source_vim_state_end_user_action (GTK_SOURCE_VIM_STATE (self));
+
+ gtk_source_vim_state_select (GTK_SOURCE_VIM_STATE (self), &iter, &iter);
+
+ self->ignore_mark = TRUE;
+}
+
+static void
+gtk_source_vim_command_upcase (GtkSourceVimCommand *self)
+{
+ return gtk_source_vim_command_change_case (self, GTK_SOURCE_CHANGE_CASE_UPPER);
+}
+
+static void
+gtk_source_vim_command_downcase (GtkSourceVimCommand *self)
+{
+ return gtk_source_vim_command_change_case (self, GTK_SOURCE_CHANGE_CASE_LOWER);
+}
+
static void
gtk_source_vim_command_undo (GtkSourceVimCommand *self)
{
@@ -519,6 +552,8 @@ gtk_source_vim_command_class_init (GtkSourceVimCommandClass *klass)
ADD_COMMAND ("paste-after", gtk_source_vim_command_paste_after);
ADD_COMMAND ("paste-before", gtk_source_vim_command_paste_before);
ADD_COMMAND ("toggle-case", gtk_source_vim_command_toggle_case);
+ ADD_COMMAND ("upcase", gtk_source_vim_command_upcase);
+ ADD_COMMAND ("downcase", gtk_source_vim_command_downcase);
#undef ADD_COMMAND
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]