public ListPromptState <T> Show(ListPromptTree <T> tree, int requestedPageSize = 15)
        {
            if (tree is null)
            {
                throw new ArgumentNullException(nameof(tree));
            }

            if (!_console.Profile.Capabilities.Interactive)
            {
                throw new NotSupportedException(
                          "Cannot show selection prompt since the current " +
                          "terminal isn't interactive.");
            }

            if (!_console.Profile.Capabilities.Ansi)
            {
                throw new NotSupportedException(
                          "Cannot show selection prompt since the current " +
                          "terminal does not support ANSI escape sequences.");
            }

            var nodes = tree.Traverse().ToList();
            var state = new ListPromptState <T>(nodes, _strategy.CalculatePageSize(_console, nodes.Count, requestedPageSize));
            var hook  = new ListPromptRenderHook <T>(_console, () => BuildRenderable(state));

            using (new RenderHookScope(_console, hook))
            {
                _console.Cursor.Hide();
                hook.Refresh();

                while (true)
                {
                    var key = _console.Input.ReadKey(true);

                    var result = _strategy.HandleInput(key, state);
                    if (result == ListPromptInputResult.Submit)
                    {
                        break;
                    }

                    if (state.Update(key.Key) || result == ListPromptInputResult.Refresh)
                    {
                        hook.Refresh();
                    }
                }
            }

            hook.Clear();
            _console.Cursor.Show();

            return(state);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectionPrompt{T}"/> class.
 /// </summary>
 public SelectionPrompt()
 {
     _tree = new ListPromptTree <T>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiSelectionPrompt{T}"/> class.
 /// </summary>
 /// <param name="comparer">
 /// The <see cref="IEqualityComparer{T}"/> implementation to use when comparing items,
 /// or <c>null</c> to use the default <see cref="IEqualityComparer{T}"/> for the type of the item.
 /// </param>
 public MultiSelectionPrompt(IEqualityComparer <T>?comparer = null)
 {
     Tree = new ListPromptTree <T>(comparer ?? EqualityComparer <T> .Default);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectionPrompt{T}"/> class.
 /// </summary>
 public SelectionPrompt()
 {
     _tree = new ListPromptTree <T>(EqualityComparer <T> .Default);
 }