From e754c4d8175a3e5b381d27b8eb5a11a8d6085d7f Mon Sep 17 00:00:00 2001 From: Chip Black Date: Sat, 6 Jun 2009 04:15:57 -0500 Subject: [PATCH] Convert Vimish to use global config --- plugins/Vimish.cs | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) 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) { -- 2.25.1