commit:84890340eccbe66e303780a992fe152356974394
author:Chip Black
committer:Chip Black
date:Sun Jun 7 23:09:08 2009 -0500
parents:638aa976c61aff23d6394609ee840222aadaa423
Rearrange key handling in FFNav and Vimish
diff --git a/plugins/FFNav.cs b/plugins/FFNav.cs
line changes: +16/-7
index 4869c2f..588f432
--- a/plugins/FFNav.cs
+++ b/plugins/FFNav.cs
@@ -8,12 +8,28 @@ public class FFNav : WebThingPlugin {
 
     public override void Init(WebThing wt) {
         this.wt = wt;
+
+        wt.Window.KeyPressEvent += Window_KeyPress;
     }
 
     public override void InitWebView(WebView wv) {
         wv.KeyPressEvent += WebView_KeyPress;
     }
 
+    private void Window_KeyPress(object o, KeyPressEventArgs e) {
+        if ((e.Event.State & Gdk.ModifierType.ControlMask) != 0) {
+            switch(e.Event.Key) {
+            case Gdk.Key.t:
+                wt.NewTab();
+                wt.Tabs.CurrentPage = wt.Tabs.NPages - 1;
+                break;
+            case Gdk.Key.w:
+                wt.CloseTab();
+                break;
+            }
+        }
+    }
+
     private void WebView_KeyPress(object o, KeyPressEventArgs e) {
         WebView wv = (WebView) o;
         if ((e.Event.State & Gdk.ModifierType.Mod1Mask) != 0) {
@@ -27,13 +43,6 @@ public class FFNav : WebThingPlugin {
             }
         } else if ((e.Event.State & Gdk.ModifierType.ControlMask) != 0) {
             switch(e.Event.Key) {
-            case Gdk.Key.t:
-                wt.NewTab();
-                wt.Tabs.CurrentPage = wt.Tabs.NPages - 1;
-                break;
-            case Gdk.Key.w:
-                wt.CloseTab();
-                break;
             case Gdk.Key.ISO_Left_Tab:
                 if (wt.Tabs.CurrentPage == 0)
                     wt.Tabs.CurrentPage = wt.Tabs.NPages - 1;

diff --git a/plugins/Vimish.cs b/plugins/Vimish.cs
line changes: +27/-23
index 3b4969f..968fae9
--- a/plugins/Vimish.cs
+++ b/plugins/Vimish.cs
@@ -29,27 +29,6 @@ public class Vimish : WebThingPlugin {
     }
 
     private void Window_KeyPress(object o, KeyPressEventArgs e) {
-        switch(e.Event.Key) {
-        case Gdk.Key.o:
-            CommandStart("open ");
-            break;
-        case Gdk.Key.O:
-            CommandStart("open " + wt.WebView.MainFrame.Uri);
-            break;
-        case Gdk.Key.t:
-            CommandStart("tabopen ");
-            break;
-        case Gdk.Key.T:
-            CommandStart("tabopen " + wt.WebView.MainFrame.Uri);
-            break;
-        case Gdk.Key.colon:
-            CommandlineShow();
-            break;
-        }
-    }
-
-    private void WebView_KeyPress(object o, KeyPressEventArgs e) {
-        Console.WriteLine(e.Event.Key);
         if ((Gdk.ModifierType.ControlMask & e.Event.State) != 0) {
             switch(e.Event.Key) {
             case Gdk.Key.n:
@@ -61,6 +40,31 @@ public class Vimish : WebThingPlugin {
             }
         } else {
             switch(e.Event.Key) {
+            case Gdk.Key.o:
+                CommandStart("open ");
+                break;
+            case Gdk.Key.O:
+                CommandStart("open " + wt.WebView.MainFrame.Uri);
+                break;
+            case Gdk.Key.t:
+                CommandStart("tabopen ");
+                break;
+            case Gdk.Key.T:
+                CommandStart("tabopen " + wt.WebView.MainFrame.Uri);
+                break;
+            case Gdk.Key.colon:
+                CommandlineShow();
+                break;
+            }
+        }
+    }
+
+    private void WebView_KeyPress(object o, KeyPressEventArgs e) {
+        WebView wv = (WebView)o;
+
+        Console.WriteLine(e.Event.Key);
+        if (e.Event.State == Gdk.ModifierType.None) {
+            switch(e.Event.Key) {
             case Gdk.Key.j:
                 wt.ScrolledWindow.Vadjustment.Value += wt.ScrolledWindow.Vadjustment.StepIncrement;
                 break;
@@ -74,10 +78,10 @@ public class Vimish : WebThingPlugin {
                 wt.ScrolledWindow.Hadjustment.Value -= wt.ScrolledWindow.Hadjustment.StepIncrement;
                 break;
             case Gdk.Key.r:
-                wt.WebView.Reload();
+                wv.Reload();
                 break;
             case Gdk.Key.Escape:
-                wt.WebView.ExecuteScript("document.activeElement.blur()");
+                wv.ExecuteScript("document.activeElement.blur()");
                 break;
             }
         }