class_docstr: Toolbar for a system prompt.
  
  :param prompt: Prompt to be displayed to the user.
class_docstr_tok: ["Toolbar","for","a","system","prompt",".",":","param","prompt",":","Prompt","to","be","displayed","to","the","user","."]
code: def _build_key_bindings(self) -> KeyBindingsBase:
      focused = has_focus(self.system_buffer)
  
      # Emacs
      emacs_bindings = KeyBindings()
      handle = emacs_bindings.add
  
      @handle("escape", filter=focused)
      @handle("c-g", filter=focused)
      @handle("c-c", filter=focused)
      def _cancel(event: E) -> None:
          "Hide system prompt."
          self.system_buffer.reset()
          event.app.layout.focus_last()
  
      @handle("enter", filter=focused)
      async def _accept(event: E) -> None:
          "Run system command."
          await event.app.run_system_command(
              self.system_buffer.text,
              display_before_text=self._get_display_before_text(),
          )
          self.system_buffer.reset(append_to_history=True)
          event.app.layout.focus_last()
  
      # Vi.
      vi_bindings = KeyBindings()
      handle = vi_bindings.add
  
      @handle("escape", filter=focused)
      @handle("c-c", filter=focused)
      def _cancel_vi(event: E) -> None:
          "Hide system prompt."
          event.app.vi_state.input_mode = InputMode.NAVIGATION
          self.system_buffer.reset()
          event.app.layout.focus_last()
  
      @handle("enter", filter=focused)
      async def _accept_vi(event: E) -> None:
          "Run system command."
          event.app.vi_state.input_mode = InputMode.NAVIGATION
          await event.app.run_system_command(
              self.system_buffer.text,
              display_before_text=self._get_display_before_text(),
          )
          self.system_buffer.reset(append_to_history=True)
          event.app.layout.focus_last()
  
      # Global bindings. (Listen to these bindings, even when this widget is
      # not focussed.)
      global_bindings = KeyBindings()
      handle = global_bindings.add
  
      @handle(
          Keys.Escape, "!", filter=~focused & emacs_mode, is_global=True
      )
      def _focus_me(event: E) -> None:
          "M-'!' will focus this user control."
          event.app.layout.focus(self.window)
  
      @handle(
          "!",
          filter=~focused & vi_mode & vi_navigation_mode,
          is_global=True,
      )
      def _focus_me_vi(event: E) -> None:
          "Focus."
          event.app.vi_state.input_mode = InputMode.INSERT
          event.app.layout.focus(self.window)
  
      return merge_key_bindings(
          [
              ConditionalKeyBindings(emacs_bindings, emacs_mode),
              ConditionalKeyBindings(vi_bindings, vi_mode),
              ConditionalKeyBindings(
                  global_bindings, self.enable_global_bindings
              ),
          ]
      )
  
imports: from __future__ import annotations
  from typing import Any
  from prompt_toolkit.application.current import get_app
  from prompt_toolkit.buffer import Buffer
  from prompt_toolkit.enums import SYSTEM_BUFFER
  from prompt_toolkit.filters import Condition, FilterOrBool, emacs_mode, has_arg, has_completions, has_focus, has_validation_error, to_filter, vi_mode, vi_navigation_mode
  from prompt_toolkit.formatted_text import AnyFormattedText, StyleAndTextTuples, fragment_list_len, to_formatted_text
  from prompt_toolkit.key_binding.key_bindings import ConditionalKeyBindings, KeyBindings, KeyBindingsBase, merge_key_bindings
  from prompt_toolkit.key_binding.key_processor import KeyPressEvent
  from prompt_toolkit.key_binding.vi_state import InputMode
  from prompt_toolkit.keys import Keys
  from prompt_toolkit.layout.containers import ConditionalContainer, Container, Window
  from prompt_toolkit.layout.controls import BufferControl, FormattedTextControl, SearchBufferControl, UIContent, UIControl
  from prompt_toolkit.layout.dimension import Dimension
  from prompt_toolkit.layout.processors import BeforeInput
  from prompt_toolkit.lexers import SimpleLexer
  from prompt_toolkit.search import SearchDirection
label_desc: Use image node_id 3 for calling the SystemToolbar obj's underlying member method code with example usage: obj._build_key_bindings() and returns: merge_key_bindings