SF.net SVN: geany: [1908] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Wed Sep 26 16:22:27 UTC 2007
Revision: 1908
http://geany.svn.sourceforge.net/geany/?rev=1908&view=rev
Author: ntrel
Date: 2007-09-26 09:22:20 -0700 (Wed, 26 Sep 2007)
Log Message:
-----------
Make common bash Ctrl-[a-z] keyboard shortcuts work in the VTE.
(Not sure why Ctrl-Shift-[cv] copy/paste shortcuts still don't work).
Modified Paths:
--------------
trunk/ChangeLog
trunk/NEWS
trunk/src/keybindings.c
trunk/src/vte.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-09-26 15:00:54 UTC (rev 1907)
+++ trunk/ChangeLog 2007-09-26 16:22:20 UTC (rev 1908)
@@ -2,6 +2,9 @@
* src/keybindings.c:
Fix selecting text with Shift-{PageUp,PageDown} (closes #1801315).
+ * src/keybindings.c, src/vte.c:
+ Make common bash Ctrl-[a-z] keyboard shortcuts work in the VTE.
+ (Not sure why Ctrl-Shift-[cv] copy/paste shortcuts still don't work).
2007-09-25 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2007-09-26 15:00:54 UTC (rev 1907)
+++ trunk/NEWS 2007-09-26 16:22:20 UTC (rev 1908)
@@ -3,6 +3,7 @@
Bugs fixed:
* Fixed opening the same file twice from the message window/command-line.
* Fixed Ctrl-Shift keybindings not working when caps lock is on.
+ * Fixed common bash Ctrl-[a-z] keyboard shortcuts not working in the VTE.
* Fixed saving the wrong document when using Save All with unnamed
documents.
* Fixed replacing with '^' or '$' regex chars.
Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c 2007-09-26 15:00:54 UTC (rev 1907)
+++ trunk/src/keybindings.c 2007-09-26 16:22:20 UTC (rev 1908)
@@ -43,6 +43,7 @@
#include "tools.h"
#include "navqueue.h"
#include "symbols.h"
+#include "vte.h"
const gboolean swap_alt_tab_order = FALSE;
@@ -654,6 +655,59 @@
}
+static gboolean set_sensitive(gpointer widget)
+{
+ gtk_widget_set_sensitive(GTK_WIDGET(widget), TRUE);
+ return FALSE;
+}
+
+
+static gboolean check_vte(GdkEventKey *event, guint keyval)
+{
+#ifndef HAVE_VTE
+ return FALSE;
+#else
+ GtkWidget *menubar;
+
+ if (! vte_info.have_vte)
+ return FALSE;
+ if (gtk_window_get_focus(GTK_WINDOW(app->window)) != vc->vte)
+ return FALSE;
+ if (event->state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) &&
+ (keyval == GDK_c || keyval == GDK_v)) // copy/paste
+ return TRUE;
+ if (event->state != GDK_CONTROL_MASK)
+ return FALSE;
+
+ // Check Ctrl-[a-z] terminal shortcuts
+ switch (keyval)
+ {
+ case GDK_a:
+ case GDK_c:
+ case GDK_d:
+ case GDK_e:
+ case GDK_k:
+ case GDK_q:
+ case GDK_r:
+ case GDK_s:
+ case GDK_u:
+ case GDK_w:
+ case GDK_z:
+ break;
+ default:
+ return FALSE;
+ }
+ /* Temporarily disable the menubar to prevent conflicting menu accelerators.
+ * Ideally we would just somehow disable the menubar without redrawing it,
+ * but maybe that's not possible. */
+ menubar = lookup_widget(app->window, "menubar1");
+ gtk_widget_set_sensitive(menubar, FALSE);
+ g_idle_add(&set_sensitive, (gpointer) menubar);
+ return TRUE;
+#endif
+}
+
+
/* central keypress event handler, almost all keypress events go to this function */
gboolean keybindings_got_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
@@ -673,7 +727,9 @@
if (event->state & GDK_MOD2_MASK)
event->state -= GDK_MOD2_MASK;
- // special case
+ // special cases
+ if (check_vte(event, keyval))
+ return FALSE;
if (check_construct_completion(event))
return TRUE;
Modified: trunk/src/vte.c
===================================================================
--- trunk/src/vte.c 2007-09-26 15:00:54 UTC (rev 1907)
+++ trunk/src/vte.c 2007-09-26 16:22:20 UTC (rev 1908)
@@ -60,6 +60,7 @@
#define VTE_TERMINAL(obj) (GTK_CHECK_CAST((obj), VTE_TYPE_TERMINAL, VteTerminal))
#define VTE_TYPE_TERMINAL (vf->vte_terminal_get_type())
+static void create_vte();
static void vte_start(GtkWidget *widget);
static gboolean vte_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
static gboolean vte_keypress(GtkWidget *widget, GdkEventKey *event, gpointer data);
@@ -76,6 +77,7 @@
POPUP_PREFERENCES
};
+
/* taken from anjuta, thanks */
static gchar **vte_get_child_environment(void)
{
@@ -133,9 +135,6 @@
void vte_init(void)
{
-
- GtkWidget *vte, *scrollbar, *hbox, *frame;
-
if (vte_info.have_vte == FALSE)
{ // app->have_vte can be false, even if VTE is compiled in, think of command line option
geany_debug("Disabling terminal support");
@@ -171,6 +170,17 @@
vte_register_symbols(module);
}
+ create_vte();
+
+ // setup the f10 menu override (so it works before the widget is first realized).
+ override_menu_key();
+}
+
+
+static void create_vte()
+{
+ GtkWidget *vte, *scrollbar, *hbox, *frame;
+
vte = vf->vte_terminal_new();
vc->vte = vte;
scrollbar = gtk_vscrollbar_new(GTK_ADJUSTMENT(VTE_TERMINAL(vte)->adjustment));
@@ -206,9 +216,6 @@
// the vte widget has to be realised before color changes take effect
g_signal_connect(G_OBJECT(vte), "realize", G_CALLBACK(vte_apply_user_settings), NULL);
-
- // setup the f10 menu override (so it works before the widget is first realized).
- override_menu_key();
}
@@ -240,7 +247,8 @@
event->keyval == GDK_d ||
event->keyval == GDK_C ||
event->keyval == GDK_D) &&
- event->state & GDK_CONTROL_MASK)
+ event->state & GDK_CONTROL_MASK &&
+ ! (event->state & GDK_SHIFT_MASK) && ! (event->state & GDK_MOD1_MASK))
{
vte_get_working_directory(); // try to keep the working directory when restarting the VTE
@@ -254,7 +262,6 @@
return TRUE;
}
-
return FALSE;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list