# File lib/rbreadline.rb, line 7150
  def rl_search_history(direction, invoking_key)
    rl_setstate(RL_STATE_ISEARCH)
    cxt = _rl_isearch_init(direction)

    rl_display_search(cxt.search_string, (cxt.sflags & SF_REVERSE)!=0, -1)

    # If we are using the callback interface, all we do is set up here and
    #    return.  The key is that we leave RL_STATE_ISEARCH set.
    if (rl_isstate(RL_STATE_CALLBACK))
      return (0)
    end

    r = -1
    while(true)
      _rl_search_getchar(cxt)
      # We might want to handle EOF here (c == 0)
      r = _rl_isearch_dispatch(cxt, cxt.lastc)
      break if (r <= 0)
    end

    # The searching is over.  The user may have found the string that she
    #   was looking for, or else she may have exited a failing search.  If
    #   LINE_INDEX is -1, then that shows that the string searched for was
    #   not found.  We use this to determine where to place rl_point.
    _rl_isearch_cleanup(cxt, r)
  end