Hide tabs by default, add code to Vimish to show/hide tabs
[WebThing.git] / plugins / Vimish.cs
index 8de862a..0b699d8 100644 (file)
@@ -10,6 +10,7 @@ public class Vimish : WebThingPlugin {
 
     public override void Init(WebThing wt) {
         this.wt = wt;
+        wt.Tabs.ShowTabs = false;
 
         wt.Window.KeyPressEvent += Window_KeyPress;
 
@@ -30,9 +31,15 @@ public class Vimish : WebThingPlugin {
         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;
@@ -115,10 +122,34 @@ public class Vimish : WebThingPlugin {
         case "q":
             wt.Quit();
             break;
+        case "set":
+            if (args.Length == 2)
+                SetVar(args[1], "");
+            else
+                SetVar(args[1], args[2]);
+            break;
         }
         CommandlineHide();
     }
 
+    public void SetVar(string key, string val) {
+        switch(key) {
+        case "showtabs":
+            wt.Tabs.ShowTabs = true;
+            break;
+        case "hidetabs":
+            wt.Tabs.ShowTabs = false;
+            break;
+        default:
+            Error("No variable {0}", key);
+            break;
+        }
+    }
+
+    private void Error(string format, params object[] values) {
+        Console.WriteLine(format, values);
+    }
+
     private void command_KeyPress(object o, KeyPressEventArgs e) {
         if (e.Event.Key == Gdk.Key.Escape)
             CommandlineHide();