private void DoSyntaxHighlighting(RichCommandLineContext context)
        {
            if (Highlighter == null)
            {
                return;
            }

            bool highlightChanged = false;

            try
            {
                highlightChanged = Highlighter.TryHighlight(context);
            }
            catch (Exception ex)
            {
                if (ThrowOnSyntaxHighlightException)
                {
                    throw;
                }
                else
                {
                    PowerLogger.LogLine("Syntax highlighting threw exception: " + ex.ToString());
                }
            }

            if (highlightChanged)
            {
                context.RefreshConsole(0, 0);
            }
        }
        private void DoSyntaxHighlighting(RichCommandLineContext context)
        {
            if (Highlighter == null)
            {
                return;
            }

            bool highlightChanged = false;

            try
            {
                highlightChanged = Highlighter.TryHighlight(context);
            }
            catch (Exception ex)
            {
                if (ThrowOnSyntaxHighlightException)
                {
                    throw;
                }
            }

            if (highlightChanged)
            {
                context.RefreshConsole(0, 0);
            }
        }
 private void HandleDelete(RichCommandLineContext context)
 {
     if (context.BufferPosition < context.Buffer.Count)
     {
         context.Buffer.RemoveAt(context.BufferPosition);
         context.RefreshConsole(0, 0);
     }
     context.Intercept = true;
 }
Example #4
0
 private void HandleDelete(RichCommandLineContext context)
 {
     if (context.BufferPosition < context.Buffer.Count)
     {
         context.Buffer.RemoveAt(context.BufferPosition);
         context.RefreshConsole(0, 0);
     }
     context.Intercept = true;
 }
Example #5
0
        public void Handle(RichCommandLineContext context)
        {
            if (context.KeyPressed.Modifiers.HasFlag(ConsoleModifiers.Control) == false)
            {
                return;
            }

            context.Intercept = true;
            context.RefreshTokenInfo();

            if (ContextAssistProvider == null || ContextAssistProvider.CanAssist(context) == false)
            {
                return;
            }

            int left = context.Console.CursorLeft;
            int top  = context.Console.CursorTop;

            ContextAssistResult result = ContextAssistResult.NoOp;

            try
            {
                context.Console.WriteLine("\n");
                result = ContextAssistProvider.DrawMenu(context);

                while (result.IsTerminal == false)
                {
                    var key = context.Console.ReadKey(true);
                    result = ContextAssistProvider.OnKeyboardInput(context, key);
                }
            }
            finally
            {
                ContextAssistProvider.ClearMenu(context);
                context.Console.CursorLeft = left;
                context.Console.CursorTop  = top;
            }

            if (result.StatusCode == ContextAssistResultStatusCode.Success)
            {
                context.ClearConsole();
                context.Console.CursorLeft = left;
                context.Console.CursorTop  = top;
                context.Buffer.Clear();
                context.Buffer.AddRange(result.NewBuffer);
                context.RefreshConsole(result.ConsoleRefreshLeftOffset, 0);
            }
        }
        public void Handle(RichCommandLineContext context)
        {
            if (context.KeyPressed.Modifiers.HasFlag(ConsoleModifiers.Control) == false)
            {
                return;
            }

            context.Intercept = true;
            context.RefreshTokenInfo();

            if (ContextAssistProvider == null || ContextAssistProvider.CanAssist(context) == false)
            {
                return;
            }

            int left = context.Console.CursorLeft;
            int top = context.Console.CursorTop;

            ContextAssistResult result = ContextAssistResult.NoOp;

            try
            {
                context.Console.WriteLine("\n");
                result = ContextAssistProvider.DrawMenu(context);

                while (result.IsTerminal == false)
                {
                    var key = context.Console.ReadKey(true);
                    result = ContextAssistProvider.OnKeyboardInput(context, key);
                }
            }
            finally
            {
                ContextAssistProvider.ClearMenu(context);
                context.Console.CursorLeft = left;
                context.Console.CursorTop = top;
            }

            if (result.StatusCode == ContextAssistResultStatusCode.Success)
            {
                context.ClearConsole();
                context.Console.CursorLeft = left;
                context.Console.CursorTop = top;
                context.Buffer.Clear();
                context.Buffer.AddRange(result.NewBuffer);
                context.RefreshConsole(result.ConsoleRefreshLeftOffset, 0);
            }
        }
        private void HandleBackspace(RichCommandLineContext context)
        {
            context.Intercept = true;

            if(context.BufferPosition == 0)
            {
                return;
            }

            context.BufferPosition--;

            if (context.BufferPosition < context.Buffer.Count)
            {
                context.Buffer.RemoveAt(context.BufferPosition);
                context.RefreshConsole(-1, 0);
            }
        }
Example #8
0
        private void HandleBackspace(RichCommandLineContext context)
        {
            context.Intercept = true;

            if (context.BufferPosition == 0)
            {
                return;
            }

            context.BufferPosition--;

            if (context.BufferPosition < context.Buffer.Count)
            {
                context.Buffer.RemoveAt(context.BufferPosition);
                context.RefreshConsole(-1, 0);
            }
        }
        private void DoSyntaxHighlighting(RichCommandLineContext context)
        {
            if(Highlighter == null)
            {
                return;
            }

            bool highlightChanged = false;

            try
            {
                highlightChanged = Highlighter.TryHighlight(context);
            }
            catch(Exception ex)
            {
                if (ThrowOnSyntaxHighlightException)
                {
                    throw;
                }
                else
                {
                    PowerLogger.LogLine("Syntax highlighting threw exception: " + ex.ToString());
                }
            }

            if(highlightChanged)
            {
                context.RefreshConsole(0, 0);
            }
        }