[anjuta] bgo#559925 - Send special keys to the terminal



commit c4459990052829a1d7d3f8dbcbd45988f124d65a
Author: Filipe <filinep gmail com>
Date:   Mon Nov 23 22:52:17 2009 +0100

    bgo#559925  - Send special keys to the terminal

 plugins/terminal/anjuta-terminal-plugin.xml |    4 ++
 plugins/terminal/terminal.c                 |   44 ++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/plugins/terminal/anjuta-terminal-plugin.xml b/plugins/terminal/anjuta-terminal-plugin.xml
index 5842d04..fd4e46d 100644
--- a/plugins/terminal/anjuta-terminal-plugin.xml
+++ b/plugins/terminal/anjuta-terminal-plugin.xml
@@ -3,5 +3,9 @@
 	<popup name="PopupTerminal">
 		<menuitem name="Copy" action="ActionCopyFromTerminal" />
 		<menuitem name="Paste" action="ActionPasteInTerminal" />
+		<separator />
+		<menuitem name="Ctrl-C" action="ActionCommandToTerminal-CTRLC"/>
+		<menuitem name="Ctrl-X" action="ActionCommandToTerminal-CTRLX"/>
+		<menuitem name="Ctrl-Z" action="ActionCommandToTerminal-CTRLZ"/>
 	</popup>
 </ui>
diff --git a/plugins/terminal/terminal.c b/plugins/terminal/terminal.c
index 13050f0..7e3b006 100644
--- a/plugins/terminal/terminal.c
+++ b/plugins/terminal/terminal.c
@@ -585,6 +585,23 @@ on_terminal_paste_cb (GtkAction * action, TerminalPlugin *term_plugin)
 	vte_terminal_paste_clipboard(term);
 }
 
+static void
+on_terminal_command_cb (GtkAction * action, TerminalPlugin *term_plugin)
+{
+	VteTerminal *term;
+	gchar c;
+	
+	if (term_plugin->child_pid)
+		term = VTE_TERMINAL (term_plugin->term);
+	else
+		term = VTE_TERMINAL (term_plugin->shell);
+	
+	/* this only works for control + letter */
+	c = gtk_action_get_name (action) [strlen (gtk_action_get_name (action)) - 1] - 64;
+	
+	vte_terminal_feed_child (term, &c, 1);
+}
+
 static GtkActionEntry actions_terminal[] = {
 	{
 		"ActionCopyFromTerminal", 	              /* Action name */
@@ -601,7 +618,32 @@ static GtkActionEntry actions_terminal[] = {
 		NULL,
 		NULL,
 		G_CALLBACK (on_terminal_paste_cb)
-	}
+	},
+	/* Add other control + letter commands here ending in -CTRL and then letter e.g. -CTRLT */
+	{
+		"ActionCommandToTerminal-CTRLC",
+		NULL,
+		N_("Ctrl-C"),
+		NULL,
+		NULL,
+		G_CALLBACK (on_terminal_command_cb)
+	},
+	{
+		"ActionCommandToTerminal-CTRLX",
+		NULL,
+		N_("Ctrl-X"),
+		NULL,
+		NULL,
+		G_CALLBACK (on_terminal_command_cb)
+	},
+	{
+		"ActionCommandToTerminal-CTRLZ",
+		NULL,
+		N_("Ctrl-Z"),
+		NULL,
+		NULL,
+		G_CALLBACK (on_terminal_command_cb)
+	},
 };
 
 static void



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