X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=plugins%2FVimish.cs;fp=plugins%2FVimish.cs;h=ebe088cbe654996490e18245bf9c3b5620e009a2;hb=e754c4d8175a3e5b381d27b8eb5a11a8d6085d7f;hp=0b699d8c66efa098870f4bd4c66dc8ca2a816630;hpb=fc785e55243b0a680c19ea6ccd77b759fe216766;p=WebThing.git diff --git a/plugins/Vimish.cs b/plugins/Vimish.cs index 0b699d8..ebe088c 100644 --- a/plugins/Vimish.cs +++ b/plugins/Vimish.cs @@ -20,6 +20,8 @@ public class Vimish : WebThingPlugin { wt.AttachWidget(commandline, CompassDirection.S, AttachOptions.Fill, AttachOptions.Shrink); commandline.Hide(); + + ApplyOptions(); } public override void InitWebView(WebView wv) { @@ -124,26 +126,39 @@ public class Vimish : WebThingPlugin { break; case "set": if (args.Length == 2) - SetVar(args[1], ""); + Options[args[1]] = null; else - SetVar(args[1], args[2]); + Options[args[1]] = args[2]; + ApplyOptions(); break; } CommandlineHide(); } - public void SetVar(string key, string val) { - switch(key) { - case "showtabs": - wt.Tabs.ShowTabs = true; - break; - case "hidetabs": - wt.Tabs.ShowTabs = false; - break; - default: - Error("No variable {0}", key); - break; + private void ApplyOptions() { + foreach (string key in Options.Keys) { + switch(key) { + case "ShowTabs": + bool v = ParseBool(Options[key]); + wt.Tabs.ShowTabs = v; + break; + default: + Error("No variable {0}", key); + break; + } + } + } + + 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) {