2 using System.Text.RegularExpressions;
5 using bytex64.WebThing;
7 public class Vimish : WebThingPlugin {
11 public override void Init(WebThing wt) {
14 wt.Window.KeyPressEvent += Window_KeyPress;
16 commandline = new Gtk.Entry();
17 commandline.Activated += command_Activate;
18 commandline.KeyPressEvent += command_KeyPress;
19 wt.AttachWidget(commandline, CompassDirection.S, AttachOptions.Fill, AttachOptions.Shrink);
24 public override void InitWebView(WebView wv) {
25 wv.KeyPressEvent += WebView_KeyPress;
28 private void Window_KeyPress(object o, KeyPressEventArgs e) {
31 CommandStart("open ");
34 CommandStart("tabopen ");
42 private void WebView_KeyPress(object o, KeyPressEventArgs e) {
43 Console.WriteLine(e.Event.Key);
44 if ((Gdk.ModifierType.ControlMask & e.Event.State) != 0) {
56 wt.ScrolledWindow.Vadjustment.Value += wt.ScrolledWindow.Vadjustment.StepIncrement;
59 wt.ScrolledWindow.Vadjustment.Value -= wt.ScrolledWindow.Vadjustment.StepIncrement;
62 wt.ScrolledWindow.Hadjustment.Value += wt.ScrolledWindow.Hadjustment.StepIncrement;
65 wt.ScrolledWindow.Hadjustment.Value -= wt.ScrolledWindow.Hadjustment.StepIncrement;
71 wt.WebView.ExecuteScript("document.activeElement.blur()");
77 public void CommandStart(string text) {
78 commandline.Text = text;
79 commandline.GrabFocus();
80 commandline.Position = text.Length;
84 public void CommandlineShow() {
86 commandline.GrabFocus();
89 public void CommandlineHide() {
91 wt.WebView.GrabFocus();
94 private void command_Activate(object o, EventArgs e) {
95 string[] args = Regex.Split(commandline.Text, @"\s+");
101 if (args.Length < 2) return;
105 if (args.Length < 2) return;
106 wt.OpenUriTab(args[1]);
107 wt.Tabs.CurrentPage = wt.Tabs.NPages - 1;
122 private void command_KeyPress(object o, KeyPressEventArgs e) {
123 if (e.Event.Key == Gdk.Key.Escape)