X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=plugins%2FVimish.cs;h=65490f8043ffcc8937777d83264ca8527fa59a8c;hb=2740ef26aaf53ac138efffe5f7761dce67e57414;hp=ebe088cbe654996490e18245bf9c3b5620e009a2;hpb=e754c4d8175a3e5b381d27b8eb5a11a8d6085d7f;p=WebThing.git diff --git a/plugins/Vimish.cs b/plugins/Vimish.cs index ebe088c..65490f8 100644 --- a/plugins/Vimish.cs +++ b/plugins/Vimish.cs @@ -17,7 +17,7 @@ public class Vimish : WebThingPlugin { commandline = new Gtk.Entry(); commandline.Activated += command_Activate; commandline.KeyPressEvent += command_KeyPress; - wt.AttachWidget(commandline, CompassDirection.S, AttachOptions.Fill, AttachOptions.Shrink); + wt.AttachWidget(commandline, AttachPoint.S, AttachOptions.Fill, AttachOptions.Shrink); commandline.Hide(); @@ -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: @@ -60,6 +39,31 @@ public class Vimish : WebThingPlugin { break; } } 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; @@ -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; } } @@ -131,6 +135,25 @@ public class Vimish : WebThingPlugin { Options[args[1]] = args[2]; ApplyOptions(); break; + case "save": + SaveConfig(); + break; + default: + bool found; + if (args.Length > 1) { + string[] callargs = new string[args.Length - 1]; + Array.Copy(args, 1, callargs, 0, args.Length - 1); + found = wt.Plugins.Call(args[0], callargs); + if (!found) + Error("No function {0}({1}) found", args[0], String.Join(", ", callargs)); + } else { + found = wt.Plugins.Call(args[0]); + if (!found) + Error("No function {0}() found", args[0]); + } + if (found) + Console.WriteLine("Plugin function {0} called successfully", args[0]); + break; } CommandlineHide(); } @@ -139,7 +162,7 @@ public class Vimish : WebThingPlugin { foreach (string key in Options.Keys) { switch(key) { case "ShowTabs": - bool v = ParseBool(Options[key]); + bool v = Config.ParseBool(Options[key]); wt.Tabs.ShowTabs = v; break; default: @@ -149,18 +172,6 @@ public class Vimish : WebThingPlugin { } } - private bool ParseBool(string v) { - switch(v.ToLower()) { - case "true": - case "t": - case "1": - case "on": - case "yes": - return true; - } - return false; - } - private void Error(string format, params object[] values) { Console.WriteLine(format, values); }