Example #1
0
        public static string ShowHistory(string id = "", int num = 10)
        {
            Shell s = Shell.GetShell(id);

            if (s != null)
            {
                if (s.MainControl.Dispatcher.CheckAccess())
                {
                    ShellTextControl c = s.MainControl as ShellTextControl;
                    if (c != null)
                    {
                        ShellTextBox b = c.GetContents;
                        if (b != null)
                        {
                            return(b.GetHistory(num));
                        }
                    }
                }
                else
                {
                    return((string)s.MainControl.Dispatcher.Invoke(new Func <string>(() => { return ShowHistory(s.ShellId, num); })));
                }
            }
            return("Error: no history available.");
        }
Example #2
0
        public static string SetCommandPrompt(string id = "", string prompt = null)
        {
            Shell s = Shell.GetShell(id);

            if (s != null)
            {
                if (s.MainControl.Dispatcher.CheckAccess())
                {
                    ShellTextControl c = s.MainControl as ShellTextControl;
                    if (c != null)
                    {
                        ShellTextBox b = c.GetContents;
                        if (b != null)
                        {
                            if (prompt == null)
                            {
                                return(b.GetPromptPrefix());
                            }
                            prompt = prompt.Trim();
                            b.SetPromptPrefix(prompt);
                            return("");
                        }
                    }
                }
                else
                {
                    return((string)s.MainControl.Dispatcher.Invoke(new Func <string>(() => { return SetCommandPrompt(s.ShellId, prompt); })));
                }
            }
            return("Error: could not access prompt.");
        }
Example #3
0
        // On entry, node is the shell node.
        public override void Serializer(XmlNode node, bool isSerialize)
        {
            base.Serializer(node, isSerialize);
            XmlNode t = Project.GetChildNode(node, "textcontrol");

            if (t == null)
            {
                return;
            }
            ShellTextBox b = GetContents;

            if (b != null)
            {
                if (isSerialize)
                {
                    Project.SetNodeAttributeValue(t, "prompt", b.GetPromptPrefix());
                }
                else
                {
                    b.SetPromptPrefix(Project.GetNodeAttributeValue(t, "prompt", ""));
                }
            }
        }
Example #4
0
        public void InitCommand()
        {
            if (SettingsService.idemode)
            {
                atb     = ServiceHost.File.Open <ShellTextBox>(Application.StartupPath + "/shell", DockState.DockBottom);
                atb.svc = this;
                atb.Clear();

                ServiceHost.File.Closing += delegate(object sender, FileEventArgs e)
                {
                    e.Cancel |= (StringComparer.InvariantCultureIgnoreCase.Compare(e.FileName, Application.StartupPath + "\\shell") == 0);
                };

                atb.LineInserted += new AdvancedTextBox.LineInsertNotify(atb_LineInserted);
                atb.AutoSave      = true;

                tbp             = atb.Parent as IDockContent;
                tbp.Text        = "Scheme Shell ";
                tbp.HideOnClose = true;
                tbp.Hide();

                InitializeShell();
            }
        }