예제 #1
0
        public ConsoleControl()
        {
            completer = new CommandAutocompleter(() => UO.CommandHandler.CommandNames);

            InitializeComponent();

            outputDocument             = new FlowDocument();
            _outputViewer.Document     = outputDocument;
            outputDocument.PagePadding = new Thickness(0);
            outputDocument.Background  = Brushes.Black;
            outputDocument.FontFamily  = _inputBlock.FontFamily;
            outputDocument.FontSize    = _inputBlock.FontSize;
            outputDocument.FontStretch = _inputBlock.FontStretch;
            outputDocument.FontStyle   = _inputBlock.FontStyle;


            ScriptEngine = new CSharpScriptEngine(new ScriptOutput(Dispatcher, consoleContent));

            var infusionConsoleLogger = new InfusionConsoleLogger(consoleContent, Dispatcher, Program.Configuration);

            fileLogger      = new FileLogger(Program.Configuration, new CircuitBreaker(HandleFileLoggingException));
            Program.Console = new AsyncLogger(new MultiplexLogger(infusionConsoleLogger, fileLogger));
            var commandHandler = new CommandHandler(Program.Console);

            Program.Initialize(commandHandler);
            DataContext = consoleContent;
            consoleContent.ConsoleOutput.CollectionChanged += ConsoleOutputOnCollectionChanged;

            _inputBlock.Focus();

            if (Application.Current.MainWindow != null)
            {
                Application.Current.MainWindow.Activated += (sender, args) => FocusInputLine();
            }
        }
예제 #2
0
        public void Can_return_just_one_name_for_exact_match()
        {
            var completer = new CommandAutocompleter(() => new[] { "info" });

            var result = completer.Autocomplete(",info");

            result.PotentialCommandNames.Should().ContainSingle("info");
        }
예제 #3
0
        public void Can_return_empty_list_when_command_on_command_line_contains_parameters()
        {
            var completer = new CommandAutocompleter(() => new[]
                                                     { "info", "reload", "refresh", "recallto", "recallhome", "help" });

            var result = completer.Autocomplete(",reload some parameter");

            result.PotentialCommandNames.Should().BeEmpty();
        }
예제 #4
0
        public void Can_return_empty_list_when_no_text_on_command_line()
        {
            var completer = new CommandAutocompleter(() => new[]
                                                     { "info", "reload", "refresh", "recallto", "recallhome", "help" });

            var result = completer.Autocomplete(string.Empty);

            result.PotentialCommandNames.Should().BeEmpty();
        }
예제 #5
0
        public void Can_return_empty_list_when_no_command_invocation_syntax_on_command_line()
        {
            var completer = new CommandAutocompleter(() => new[]
                                                     { "info", "reload", "refresh", "recallto", "recallhome", "help" });

            var result = completer.Autocomplete("something different");

            result.PotentialCommandNames.Should().BeEmpty();
        }
예제 #6
0
        public void Can_return_all_command_names_when_no_command_name_after_leading_comma()
        {
            var completer = new CommandAutocompleter(() => new[]
                                                     { "info", "reload", "refresh", "recallto", "recallhome", "help" });

            var result = completer.Autocomplete(",");

            result.PotentialCommandNames.Should().BeEquivalentTo("info", "reload", "refresh", "recallto", "recallhome", "help");
        }
예제 #7
0
        public void Can_return_command_names_when_no_command_starting_with_text_on_command_line()
        {
            var completer = new CommandAutocompleter(() => new[]
                                                     { "info", "reload", "refresh", "recallto", "recallhome", "help" });

            var result = completer.Autocomplete(",xxx");

            result.PotentialCommandNames.Should().BeEquivalentTo("info", "reload", "refresh", "recallto", "recallhome", "help");
        }
예제 #8
0
        public void Returns_autocompleted_command_line_when_single_potential_command_name()
        {
            var completer = new CommandAutocompleter(() => new[]
                                                     { "asdf1", });

            var result = completer.Autocomplete(",a");

            result.IsAutocompleted.Should().BeTrue();
            result.AutocompletedCommandLine.Should().Be(",asdf1 ");
        }
예제 #9
0
        public void Returns_no_autocompleted_command_when_no_potential_command_name()
        {
            var completer = new CommandAutocompleter(() => new[]
                                                     { "asdf1", });

            var result = completer.Autocomplete(",xx");

            result.IsAutocompleted.Should().BeFalse();
            result.AutocompletedCommandLine.Should().BeNull();
        }
예제 #10
0
        public void Returns_autocompleted_command_line_when_exact_match()
        {
            var completer = new CommandAutocompleter(() => new[]
                                                     { "asdf1", });

            var result = completer.Autocomplete(",asdf1");

            result.IsAutocompleted.Should().BeTrue();
            result.AutocompletedCommandLine.Should().Be(",asdf1 ");
        }
예제 #11
0
        public void Returns_no_autocompleted_command_for_one_space()
        {
            var completer = new CommandAutocompleter(() => new[]
                                                     { "asdf1", });

            var result = completer.Autocomplete(" ");

            result.IsAutocompleted.Should().BeFalse();
            result.AutocompletedCommandLine.Should().BeNull();
        }
예제 #12
0
        public void Returns_autocompleted_command_line_when_multiple_potential_command_names()
        {
            var completer = new CommandAutocompleter(() => new[]
                                                     { ",asdf1", ",asdf2", ",asdf3", ",asdf4" });

            var result = completer.Autocomplete(",as");

            result.IsAutocompleted.Should().BeTrue();
            result.AutocompletedCommandLine.Should().Be(",asdf");
        }
예제 #13
0
 public void Initialize(CommandHandler commandHandler)
 {
     this.commandHandler = commandHandler;
     completer           = new CommandAutocompleter(() => commandHandler.CommandNames);
 }