code: def display_completions_like_readline(event: E) -> None:
      """
      Key binding handler for readline-style tab completion.
      This is meant to be as similar as possible to the way how readline displays
      completions.
  
      Generate the completions immediately (blocking) and display them above the
      prompt in columns.
  
      Usage::
  
          # Call this handler when 'Tab' has been pressed.
          key_bindings.add(Keys.ControlI)(display_completions_like_readline)
      """
      # Request completions.
      b = event.current_buffer
      if b.completer is None:
          return
      complete_event = CompleteEvent(completion_requested=True)
      completions = list(
          b.completer.get_completions(b.document, complete_event)
      )
  
      # Calculate the common suffix.
      common_suffix = get_common_complete_suffix(
          b.document, completions
      )
  
      # One completion: insert it.
      if len(completions) == 1:
          b.delete_before_cursor(-completions[0].start_position)
          b.insert_text(completions[0].text)
      # Multiple completions with common part.
      elif common_suffix:
          b.insert_text(common_suffix)
      # Otherwise: display all completions.
      elif completions:
          _display_completions_like_readline(event.app, completions)
  
file_path: catboost/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/completion.py
imports: from __future__ import annotations
  import asyncio
  import math
  from typing import TYPE_CHECKING
  from prompt_toolkit.application.run_in_terminal import in_terminal
  from prompt_toolkit.completion import CompleteEvent, Completion, get_common_complete_suffix
  from prompt_toolkit.formatted_text import StyleAndTextTuples
  from prompt_toolkit.key_binding.key_bindings import KeyBindings
  from prompt_toolkit.key_binding.key_processor import KeyPressEvent
  from prompt_toolkit.keys import Keys
  from prompt_toolkit.utils import get_cwidth
label_desc: Use image node_id 2 for calling a global function with example usage: display_completions_like_readline(event) without return types