X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=plugins%2FVimish.cs;h=3b4089d50068b905768e97a40c98ca28a55088ce;hb=1bff29702cf8ce8c1952d22243e4dc7a9df74105;hp=7ed071ff8b6a607ccb4557ff15a24ed0082c0135;hpb=83b79eb23390beda1fb04b00be48351fcf1b98af;p=WebThing.git diff --git a/plugins/Vimish.cs b/plugins/Vimish.cs index 7ed071f..3b4089d 100644 --- a/plugins/Vimish.cs +++ b/plugins/Vimish.cs @@ -4,87 +4,87 @@ using Gtk; using bytex64.WebThing; public class Plugin { - WebThing wt; - Gtk.Entry commandline; + WebThing wt; + Gtk.Entry commandline; - public Plugin(WebThing wt) { - this.wt = wt; - wt.WebView.KeyPressEvent += WebView_KeyPress; + public Plugin(WebThing wt) { + this.wt = wt; + wt.WebView.KeyPressEvent += WebView_KeyPress; - commandline = new Gtk.Entry(); - commandline.Activated += command_Activate; - commandline.KeyPressEvent += command_KeyPress; - wt.AttachWidget(commandline, CompassDirection.S, AttachOptions.Fill, AttachOptions.Shrink); + commandline = new Gtk.Entry(); + commandline.Activated += command_Activate; + commandline.KeyPressEvent += command_KeyPress; + wt.AttachWidget(commandline, CompassDirection.S, AttachOptions.Fill, AttachOptions.Shrink); - commandline.Hide(); - } + commandline.Hide(); + } - private void WebView_KeyPress(object o, KeyPressEventArgs e) { - Console.WriteLine(e.Event.Key); - switch(e.Event.Key) { - case Gdk.Key.j: - wt.ScrolledWindow.Vadjustment.Value += wt.ScrolledWindow.Vadjustment.StepIncrement; - break; - case Gdk.Key.k: - wt.ScrolledWindow.Vadjustment.Value -= wt.ScrolledWindow.Vadjustment.StepIncrement; - break; - case Gdk.Key.l: - wt.ScrolledWindow.Hadjustment.Value += wt.ScrolledWindow.Hadjustment.StepIncrement; - break; - case Gdk.Key.h: - wt.ScrolledWindow.Hadjustment.Value -= wt.ScrolledWindow.Hadjustment.StepIncrement; - break; - case Gdk.Key.o: - CommandStart("open "); - break; - case Gdk.Key.r: - wt.WebView.Reload(); - break; - case Gdk.Key.t: - CommandStart("tabopen "); - break; - case Gdk.Key.colon: - CommandlineShow(); - break; - case Gdk.Key.Escape: - wt.WebView.ExecuteScript("document.activeElement.blur()"); - break; - } - } + private void WebView_KeyPress(object o, KeyPressEventArgs e) { + Console.WriteLine(e.Event.Key); + switch(e.Event.Key) { + case Gdk.Key.j: + wt.ScrolledWindow.Vadjustment.Value += wt.ScrolledWindow.Vadjustment.StepIncrement; + break; + case Gdk.Key.k: + wt.ScrolledWindow.Vadjustment.Value -= wt.ScrolledWindow.Vadjustment.StepIncrement; + break; + case Gdk.Key.l: + wt.ScrolledWindow.Hadjustment.Value += wt.ScrolledWindow.Hadjustment.StepIncrement; + break; + case Gdk.Key.h: + wt.ScrolledWindow.Hadjustment.Value -= wt.ScrolledWindow.Hadjustment.StepIncrement; + break; + case Gdk.Key.o: + CommandStart("open "); + break; + case Gdk.Key.r: + wt.WebView.Reload(); + break; + case Gdk.Key.t: + CommandStart("tabopen "); + break; + case Gdk.Key.colon: + CommandlineShow(); + break; + case Gdk.Key.Escape: + wt.WebView.ExecuteScript("document.activeElement.blur()"); + break; + } + } - public void CommandStart(string text) { - commandline.Text = text; - commandline.GrabFocus(); - commandline.Position = text.Length; - commandline.Show(); - } + public void CommandStart(string text) { + commandline.Text = text; + commandline.GrabFocus(); + commandline.Position = text.Length; + commandline.Show(); + } - public void CommandlineShow() { - commandline.Show(); - commandline.GrabFocus(); - } + public void CommandlineShow() { + commandline.Show(); + commandline.GrabFocus(); + } - public void CommandlineHide() { - commandline.Hide(); - wt.WebView.GrabFocus(); - } + public void CommandlineHide() { + commandline.Hide(); + wt.WebView.GrabFocus(); + } - private void command_Activate(object o, EventArgs e) { - string[] args = Regex.Split(commandline.Text, @"\s+"); - switch(args[0]) { - case "open": - if (args.Length < 2) return; - wt.OpenUri(args[1]); - break; - case "q": - wt.Quit(); - break; - } - CommandlineHide(); - } + private void command_Activate(object o, EventArgs e) { + string[] args = Regex.Split(commandline.Text, @"\s+"); + switch(args[0]) { + case "open": + if (args.Length < 2) return; + wt.OpenUri(args[1]); + break; + case "q": + wt.Quit(); + break; + } + CommandlineHide(); + } - private void command_KeyPress(object o, KeyPressEventArgs e) { - if (e.Event.Key == Gdk.Key.Escape) - CommandlineHide(); - } + private void command_KeyPress(object o, KeyPressEventArgs e) { + if (e.Event.Key == Gdk.Key.Escape) + CommandlineHide(); + } }