private static void demo_Env_OpenExternal() { InputBoxOptions opts = default; opts = new InputBoxOptions(); opts.IgnoreFocusOut = true; opts.Value = "http://github.com/metaleap/vscode-appz"; logLn(strFmt("uri@opts/{0}:\t{1}", "Prompt", "Enter any URI (of http: or mailto: or any other protocol scheme) to open in the applicable external app registered with your OS to handle that protocol.")); opts.Prompt = "Enter any URI (of http: or mailto: or any other protocol scheme) to open in the applicable external app registered with your OS to handle that protocol."; vsc.Window.ShowInputBox(opts, null)((string uri) => { if ((null == uri)) { vsc.Window.ShowWarningMessage(logLn("Don't be bashful.."), null); } else { logLn(strFmt("uri <- {0}", uri)); vsc.Env.OpenExternal(uri)((bool ok) => { string did = default; did = "Did"; if (!ok) { did = did + " not"; } vsc.Window.ShowInformationMessage(logLn(strFmt("{0} succeed in opening `{1}`, chapeau!", did, uri)), null); }); } }); }
private static void demo_clipboard() { vsc.Env.Clipboard().ReadText()((string text) => { if ((null == text)) { vsc.Window.ShowWarningMessage(logLn("No text in clipboard"), null); } else { InputBoxOptions opts = default; opts = new InputBoxOptions(); opts.IgnoreFocusOut = true; opts.Value = text; logLn(strFmt("input@opts/{0}:\t{1}", "Prompt", "Enter new contents to write to your clipboard.")); opts.Prompt = "Enter new contents to write to your clipboard."; vsc.Window.ShowInputBox(opts, null)((string input) => { if ((null == input)) { vsc.Window.ShowWarningMessage(logLn("Don't be bashful.."), null); } else { logLn(strFmt("input <- {0}", input)); vsc.Env.Clipboard().WriteText(input)(() => { vsc.Window.ShowInformationMessage(logLn("Okay. Now double-check by pasting somewhere."), null); }); } }); } }); }
private static void demo_Commands_RegisterCommand() { InputBoxOptions opts = default; opts = new InputBoxOptions(); opts.IgnoreFocusOut = true; opts.Value = "foo.bar.baz"; logLn(strFmt("cmdname@opts/{0}:\t{1}", "Prompt", "Enter your command name. The command will accept a single text input and return a result built from it.")); opts.Prompt = "Enter your command name. The command will accept a single text input and return a result built from it."; vsc.Window.ShowInputBox(opts, null)((string cmdname) => { if ((null == cmdname)) { vsc.Window.ShowWarningMessage(logLn("Don't be bashful.."), null); } else { logLn(strFmt("cmdname <- {0}", cmdname)); vsc.Commands.RegisterCommand(cmdname, (any[] cmdargs) => { vsc.Window.SetStatusBarMessage(logLn(strFmt("Command `{0}` invoked with: `{1}`", cmdname, cmdargs[0])), 4242); return(strFmt("Input to command `{0}` was: `{1}`", cmdname, cmdargs[0])); })((Disposable useToUnregister) => { InputBoxOptions opts2 = default; opts2 = new InputBoxOptions(); opts2.IgnoreFocusOut = true; logLn(strFmt("cmdarg@opts2/{0}:\t{1}", "Prompt", strFmt("Command `{0}` registered, try it now?", cmdname))); opts2.Prompt = strFmt("Command `{0}` registered, try it now?", cmdname); opts2.Value = strFmt("Enter input to command `{0}` here", cmdname); vsc.Window.ShowInputBox(opts2, null)((string cmdarg) => { if ((null == cmdarg)) { vsc.Window.ShowWarningMessage(logLn("Don't be bashful.."), null); } else { logLn(strFmt("cmdarg <- {0}", cmdarg)); any[] cmdargs2 = default; cmdargs2 = new any[1]; cmdargs2[0] = cmdarg; vsc.Commands.ExecuteCommand(cmdname, cmdargs2)((any ret) => { vsc.Window.ShowInformationMessage(logLn(strFmt("Command result: `{0}`, mad props!", ret)), null); }); } }); }); } }); }
private static void demo_Commands_GetCommands_and_ExecuteCommand() { vsc.Commands.GetCommands(false)((string[] items) => { QuickPickOptions opts = default; opts = new QuickPickOptions(); opts.IgnoreFocusOut = true; opts.PlaceHolder = strFmt("Retrieved {0} command ID(s), pick one to execute or escape now:", items.Length); vsc.Window.ShowQuickPick(quickPickItemsFrom(items), opts, null)((QuickPickItem[] item) => { if ((null == item)) { vsc.Window.ShowWarningMessage(logLn("Command selection cancelled, spooked?"), null); } else { InputBoxOptions opts2 = default; opts2 = new InputBoxOptions(); opts2.IgnoreFocusOut = true; logLn(strFmt("cmdarg@opts2/{0}:\t{1}", "PlaceHolder", strFmt("Any param for `{0}` command? Else leave blank.", item[0].Label))); opts2.PlaceHolder = strFmt("Any param for `{0}` command? Else leave blank.", item[0].Label); vsc.Window.ShowInputBox(opts2, null)((string cmdarg) => { if ((null == cmdarg)) { vsc.Window.ShowWarningMessage(logLn("Don't be bashful.."), null); } else { logLn(strFmt("cmdarg <- {0}", cmdarg)); any[] cmdargs = default; if ("" != cmdarg) { cmdargs = new any[1]; cmdargs[0] = cmdarg; } vsc.Commands.ExecuteCommand(item[0].Label, cmdargs)((any ret) => { vsc.Window.ShowInformationMessage(logLn(strFmt("Command result was: `{0}`, kudos!", ret)), null); }); } }); } }); }); }
private static void demo_Window_CreateTerminal() { InputBoxOptions optsname = default; optsname = new InputBoxOptions(); optsname.IgnoreFocusOut = true; logLn(strFmt("termname@optsname/{0}:\t{1}", "Prompt", "Name of your new terminal?")); optsname.Prompt = "Name of your new terminal?"; optsname.Value = appName; vsc.Window.ShowInputBox(optsname, null)((string termname) => { if ((null == termname)) { vsc.Window.ShowWarningMessage(logLn("Don't be bashful.."), null); } else { logLn(strFmt("termname <- {0}", termname)); InputBoxOptions optstext = default; optstext = new InputBoxOptions(); optstext.IgnoreFocusOut = true; logLn(strFmt("termtext@optstext/{0}:\t{1}", "Prompt", strFmt("Text to send to new terminal `{0}` initially upon creation?", termname))); optstext.Prompt = strFmt("Text to send to new terminal `{0}` initially upon creation?", termname); optstext.Value = appName; vsc.Window.ShowInputBox(optstext, null)((string termtext) => { if ((null == termtext)) { vsc.Window.ShowWarningMessage(logLn("Don't be bashful.."), null); } else { logLn(strFmt("termtext <- {0}", termtext)); InputBoxOptions optsvar = default; optsvar = new InputBoxOptions(); optsvar.IgnoreFocusOut = true; logLn(strFmt("termvar@optsvar/{0}:\t{1}", "Prompt", "Value for custom env var named `MY_ENV_VAR`?")); optsvar.Prompt = "Value for custom env var named `MY_ENV_VAR`?"; vsc.Window.ShowInputBox(optsvar, null)((string termvar) => { if ((null == termvar)) { vsc.Window.ShowWarningMessage(logLn("Don't be bashful.."), null); } else { logLn(strFmt("termvar <- {0}", termvar)); TerminalOptions cfg = default; cfg = new TerminalOptions(); cfg.Name = termname; cfg.Env = new Dictionary <string, string>(1); cfg.Env["MY_ENV_VAR"] = termvar; vsc.Window.CreateTerminal(cfg)((Terminal term) => { term.Show(false)(() => { term.SendText(termtext, false); }); }); } }); } }); } }); }