2 using System.Text.RegularExpressions;
4 using bytex64.WebThing;
10 public Plugin(WebThing wt) {
12 wt.WebView.KeyPressEvent += WebView_KeyPress;
14 commandline = new Gtk.Entry();
15 commandline.Activated += command_Activate;
16 commandline.KeyPressEvent += command_KeyPress;
17 wt.AttachWidget(commandline, CompassDirection.S, AttachOptions.Fill, AttachOptions.Shrink);
22 private void WebView_KeyPress(object o, KeyPressEventArgs e) {
23 Console.WriteLine(e.Event.Key);
26 wt.ScrolledWindow.Vadjustment.Value += wt.ScrolledWindow.Vadjustment.StepIncrement;
29 wt.ScrolledWindow.Vadjustment.Value -= wt.ScrolledWindow.Vadjustment.StepIncrement;
32 wt.ScrolledWindow.Hadjustment.Value += wt.ScrolledWindow.Hadjustment.StepIncrement;
35 wt.ScrolledWindow.Hadjustment.Value -= wt.ScrolledWindow.Hadjustment.StepIncrement;
38 CommandStart("open ");
44 CommandStart("tabopen ");
46 case Gdk.Key.BackSpace:
53 wt.WebView.ExecuteScript("document.activeElement.blur()");
58 public void CommandStart(string text) {
59 commandline.Text = text;
60 commandline.GrabFocus();
61 commandline.Position = text.Length;
65 public void CommandlineShow() {
67 commandline.GrabFocus();
70 public void CommandlineHide() {
72 wt.WebView.GrabFocus();
75 private void command_Activate(object o, EventArgs e) {
76 string[] args = Regex.Split(commandline.Text, @"\s+");
79 if (args.Length < 2) return;
89 private void command_KeyPress(object o, KeyPressEventArgs e) {
90 if (e.Event.Key == Gdk.Key.Escape)