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 ");
41 CommandStart("tabopen ");
43 case Gdk.Key.BackSpace:
52 public void CommandStart(string text) {
53 commandline.Text = text;
54 commandline.GrabFocus();
55 commandline.Position = text.Length;
59 public void CommandlineShow() {
61 commandline.GrabFocus();
64 public void CommandlineHide() {
66 wt.WebView.GrabFocus();
69 private void command_Activate(object o, EventArgs e) {
70 string[] args = Regex.Split(commandline.Text, @"\s+");
73 if (args.Length < 2) return;
74 wt.WebView.Open(args[1]);
77 commandline.Text = "";
81 private void command_KeyPress(object o, KeyPressEventArgs e) {
82 if (e.Event.Key == Gdk.Key.Escape)