RefreshConsole() public method

Rewrites the console using the latest values in the Buffer, preserving the cursor position with an optional adjustment.
public RefreshConsole ( int leftAdjust, int topAdjust ) : void
leftAdjust int Adjusts the left cursor position by the desired amound. If you want the cursor to stay where it was then use 0.
topAdjust int Adjusts the top cursor position by the desired amound. If you want the cursor to stay where it was then use 0.
return void
示例#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;
                }
            }

            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;
                }
                else
                {
                    PowerLogger.LogLine("Syntax highlighting threw exception: " + ex.ToString());
                }
            }

            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;
 }
示例#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;
 }
        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);
            }
        }
示例#6
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);
            }
        }
示例#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);
            }
        }