Exemple #1
0
        /// <summary>Pre-process the important bits of input and store in private fields.</summary>
        /// <remarks>This allows the input to be available for validation and the main execute method.</remarks>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        private void PreprocessInput(ActionInput actionInput)
        {
            // Make sure there is a sender.
            this.sender  = actionInput.Controller;
            this.session = this.sender as Session;
            if (this.sender == null || this.sender.Thing == null)
            {
                return;
            }

            // Make sure the sender is an actual connected user.
            this.userControlledBehavior = this.sender.Thing.Behaviors.FindFirst <UserControlledBehavior>();
            if (this.userControlledBehavior == null)
            {
                return;
            }

            // Parse and store the desired buffer length, if one was provided.
            string lengthText = actionInput.Tail.ToLower().Trim();

            if (string.IsNullOrEmpty(lengthText))
            {
                this.parseSucceeded = true;
            }
            else if (lengthText == "auto")
            {
                this.parsedBufferLength = -1;
                this.parseSucceeded     = true;
            }
            else
            {
                this.parseSucceeded = this.TryParse(lengthText, out this.parsedBufferLength);
            }
        }
Exemple #2
0
 /// <summary>Displays the current buffer length to the user, handling the special case of "auto" instead of -1.</summary>
 private void ShowCurrentBuffer(UserControlledBehavior userControlledBehavior)
 {
     if (userControlledBehavior.PagingRowLimit == -1)
     {
         session.WriteLine($"Your screen buffer size is 'auto' (currently {session.TerminalOptions.Height} lines).");
     }
     else
     {
         session.WriteLine($"Your screen buffer is set to {userControlledBehavior.PagingRowLimit} lines.");
     }
 }