code: def edit(
      text: t.Optional[t.AnyStr] = None,
      editor: t.Optional[str] = None,
      env: t.Optional[t.Mapping[str, str]] = None,
      require_save: bool = True,
      extension: str = ".txt",
      filename: t.Optional[str] = None,
  ) -> t.Optional[t.AnyStr]:
      r"""Edits the given text in the defined editor.  If an editor is given
      (should be the full path to the executable but the regular operating
      system search path is used for finding the executable) it overrides
      the detected editor.  Optionally, some environment variables can be
      used.  If the editor is closed without changes, `None` is returned.  In
      case a file is edited directly the return value is always `None` and
      `require_save` and `extension` are ignored.
  
      If the editor cannot be opened a :exc:`UsageError` is raised.
  
      Note for Windows: to simplify cross-platform usage, the newlines are
      automatically converted from POSIX to Windows and vice versa.  As such,
      the message here will have ``\n`` as newline markers.
  
      :param text: the text to edit.
      :param editor: optionally the editor to use.  Defaults to automatic
                     detection.
      :param env: environment variables to forward to the editor.
      :param require_save: if this is true, then not saving in the editor
                           will make the return value become `None`.
      :param extension: the extension to tell the editor about.  This defaults
                        to `.txt` but changing this might change syntax
                        highlighting.
      :param filename: if provided it will edit this file instead of the
                       provided text contents.  It will not use a temporary
                       file as an indirection in that case.
      """
      from ._termui_impl import Editor
  
      ed = Editor(
          editor=editor,
          env=env,
          require_save=require_save,
          extension=extension,
      )
  
      if filename is None:
          return ed.edit(text)
  
      ed.edit_file(filename)
      return None
  
imports: import inspect
  import io
  import itertools
  import sys
  import typing
  from gettext import gettext
  from ._compat import isatty
  from ._compat import strip_ansi
  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 ParamType
  from .utils import echo
  from .utils import LazyFile
label_desc: Use image node_id 13 for calling a global function with example usage: edit(text, editor, env, require_save, extension, filename) and returns: None, ed