[gnome-builder] vim: add support for :q and :q!



commit 188c697d1ed8c9838dbd9832dbd7831f1f984cd5
Author: Christian Hergert <christian hergert me>
Date:   Mon Jan 12 19:58:08 2015 -0800

    vim: add support for :q and :q!

 src/editor/gb-editor-frame.c |   13 +++++++++++++
 src/vim/gb-source-vim.c      |    7 ++++---
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index 2c58720..eee712b 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -1058,6 +1058,19 @@ gb_editor_frame_on_execute_command (GbEditorFrame *self,
       gb_editor_frame_activate_action (self, "stack", "save");
       return TRUE;
     }
+  else if (g_strcmp0 (command_text, "q") == 0)
+    {
+      GtkWidget *toplevel;
+
+      toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+      gtk_window_close (GTK_WINDOW (toplevel));
+      return TRUE;
+    }
+  else if (g_strcmp0 (command_text, "q!") == 0)
+    {
+      g_application_quit (g_application_get_default ());
+      return TRUE;
+    }
 
   return FALSE;
 }
diff --git a/src/vim/gb-source-vim.c b/src/vim/gb-source-vim.c
index 17bf4f2..570dac9 100644
--- a/src/vim/gb-source-vim.c
+++ b/src/vim/gb-source-vim.c
@@ -4101,9 +4101,10 @@ gb_source_vim_is_command (const gchar *command_text)
    * Some other valid commands, that we don't know how to handle.
    * (But they may be handled by EXECUTE_COMMAND signal.
    */
-  if (g_strcmp0 (command_text, "w") == 0)
-    return TRUE;
-  else if (g_strcmp0 (command_text, "wq") == 0)
+  if (g_str_equal (command_text, "w") ||
+      g_str_equal (command_text, "wq") ||
+      g_str_equal (command_text, "q") ||
+      g_str_equal (command_text, "q!"))
     return TRUE;
 
   return FALSE;


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