コード例 #1
0
        private void TestSetup(KeyMode keyMode, params KeyHandler[] keyHandlers)
        {
            _console = new TestConsole();

            PSConsoleReadLine.ClearHistory();
            PSConsoleReadLine.ClearKillRing();

            var options = new SetPSReadlineOption
            {
                AddToHistoryHandler               = null,
                BellStyle                         = PSConsoleReadlineOptions.DefaultBellStyle,
                CompletionQueryItems              = PSConsoleReadlineOptions.DefaultCompletionQueryItems,
                ContinuationPrompt                = PSConsoleReadlineOptions.DefaultContinuationPrompt,
                ContinuationPromptBackgroundColor = _console.BackgroundColor,
                ContinuationPromptForegroundColor = _console.ForegroundColor,
                DingDuration                      = 1,  // Make tests virtually silent when they ding
                DingTone                          = 37, // Make tests virtually silent when they ding
                EmphasisBackgroundColor           = _console.BackgroundColor,
                EmphasisForegroundColor           = PSConsoleReadlineOptions.DefaultEmphasisForegroundColor,
                ErrorBackgroundColor              = ConsoleColor.DarkRed,
                ErrorForegroundColor              = ConsoleColor.Red,
                ExtraPromptLineCount              = PSConsoleReadlineOptions.DefaultExtraPromptLineCount,
                HistoryNoDuplicates               = PSConsoleReadlineOptions.DefaultHistoryNoDuplicates,
                HistorySaveStyle                  = HistorySaveStyle.SaveNothing,
                HistorySearchCaseSensitive        = PSConsoleReadlineOptions.DefaultHistorySearchCaseSensitive,
                HistorySearchCursorMovesToEnd     = PSConsoleReadlineOptions.DefaultHistorySearchCursorMovesToEnd,
                MaximumHistoryCount               = PSConsoleReadlineOptions.DefaultMaximumHistoryCount,
                MaximumKillRingCount              = PSConsoleReadlineOptions.DefaultMaximumKillRingCount,
                ResetTokenColors                  = true,
                ShowToolTips                      = PSConsoleReadlineOptions.DefaultShowToolTips,
                WordDelimiters                    = PSConsoleReadlineOptions.DefaultWordDelimiters,
            };

            switch (keyMode)
            {
            case KeyMode.Cmd:
                options.EditMode = EditMode.Windows;
                break;
            case KeyMode.Emacs:
                options.EditMode = EditMode.Emacs;
                break;
            case KeyMode.Vi:
                options.EditMode = EditMode.Vi;
                break;
            }

            PSConsoleReadLine.SetOptions(options);

            foreach (var keyHandler in keyHandlers)
            {
                PSConsoleReadLine.SetKeyHandler(new [] {keyHandler.Chord}, keyHandler.Handler, "", "");
            }

            var colorOptions = new SetPSReadlineOption();
            foreach (var val in typeof(TokenClassification).GetEnumValues())
            {
                colorOptions.TokenKind = (TokenClassification)val;
                colorOptions.ForegroundColor = ForegroundColors[(int)val];
                colorOptions.BackgroundColor = BackgroundColors[(int)val];
                PSConsoleReadLine.SetOptions(colorOptions);
            }
        }
コード例 #2
0
        private void TestSetup(KeyMode keyMode, params KeyHandler[] keyHandlers)
        {
            _console = new TestConsole();

            PSConsoleReadLine.ClearHistory();
            PSConsoleReadLine.ClearKillRing();

            var options = new SetPSReadlineOption
            {
                AddToHistoryHandler  = null,
                BellStyle            = PSConsoleReadlineOptions.DefaultBellStyle,
                CompletionQueryItems = PSConsoleReadlineOptions.DefaultCompletionQueryItems,
                ContinuationPrompt   = PSConsoleReadlineOptions.DefaultContinuationPrompt,
                ContinuationPromptBackgroundColor = _console.BackgroundColor,
                ContinuationPromptForegroundColor = _console.ForegroundColor,
                DingDuration                  = 1,      // Make tests virtually silent when they ding
                DingTone                      = 37,     // Make tests virtually silent when they ding
                EmphasisBackgroundColor       = _console.BackgroundColor,
                EmphasisForegroundColor       = PSConsoleReadlineOptions.DefaultEmphasisForegroundColor,
                ErrorBackgroundColor          = ConsoleColor.DarkRed,
                ErrorForegroundColor          = ConsoleColor.Red,
                ExtraPromptLineCount          = PSConsoleReadlineOptions.DefaultExtraPromptLineCount,
                HistoryNoDuplicates           = PSConsoleReadlineOptions.DefaultHistoryNoDuplicates,
                HistorySaveStyle              = HistorySaveStyle.SaveNothing,
                HistorySearchCaseSensitive    = PSConsoleReadlineOptions.DefaultHistorySearchCaseSensitive,
                HistorySearchCursorMovesToEnd = PSConsoleReadlineOptions.DefaultHistorySearchCursorMovesToEnd,
                MaximumHistoryCount           = PSConsoleReadlineOptions.DefaultMaximumHistoryCount,
                MaximumKillRingCount          = PSConsoleReadlineOptions.DefaultMaximumKillRingCount,
                ResetTokenColors              = true,
                ShowToolTips                  = PSConsoleReadlineOptions.DefaultShowToolTips,
                WordDelimiters                = PSConsoleReadlineOptions.DefaultWordDelimiters,
            };

            switch (keyMode)
            {
            case KeyMode.Cmd:
                options.EditMode = EditMode.Windows;
                break;

            case KeyMode.Emacs:
                options.EditMode = EditMode.Emacs;
                break;

            case KeyMode.Vi:
                options.EditMode = EditMode.Vi;
                break;
            }

            PSConsoleReadLine.SetOptions(options);

            foreach (var keyHandler in keyHandlers)
            {
                PSConsoleReadLine.SetKeyHandler(new [] { keyHandler.Chord }, keyHandler.Handler, "", "");
            }

            var colorOptions = new SetPSReadlineOption();

            foreach (var val in typeof(TokenClassification).GetEnumValues())
            {
                colorOptions.TokenKind       = (TokenClassification)val;
                colorOptions.ForegroundColor = ForegroundColors[(int)val];
                colorOptions.BackgroundColor = BackgroundColors[(int)val];
                PSConsoleReadLine.SetOptions(colorOptions);
            }
        }