code: def echo_via_pager(text_or_generator, color=None):
      """This function takes a text and shows it via an environment specific
      pager on stdout.
  
      .. versionchanged:: 3.0
         Added the `color` flag.
  
      :param text_or_generator: the text to page, or alternatively, a
                                generator emitting the text to page.
      :param color: controls if the pager supports ANSI colors or not.  The
                    default is autodetection.
      """
      color = resolve_color_default(color)
  
      if inspect.isgeneratorfunction(text_or_generator):
          i = text_or_generator()
      elif isinstance(text_or_generator, string_types):
          i = [text_or_generator]
      else:
          i = iter(text_or_generator)
  
      # convert every element of i to a text type if necessary
      text_generator = (
          el if isinstance(el, string_types) else text_type(el)
          for el in i
      )
  
      from ._termui_impl import pager
  
      return pager(itertools.chain(text_generator, "\n"), color)
  
imports: import inspect
  import io
  import itertools
  import os
  import struct
  import sys
  from ._compat import DEFAULT_COLUMNS
  from ._compat import get_winterm_size
  from ._compat import isatty
  from ._compat import raw_input
  from ._compat import string_types
  from ._compat import strip_ansi
  from ._compat import text_type
  from ._compat import WIN
  from .exceptions import Abort
  from .exceptions import UsageError
  from .globals import resolve_color_default
  from .types import Choice
  from .types import convert_type
  from .types import Path
  from .utils import echo
  from .utils import LazyFile
label_desc: Use image node_id 7 for calling a global function with example usage: echo_via_pager(text_or_generator, color) and returns: pager