/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package android.view.inputmethod;

option java_multiple_files = true;

/**
 * Represents a {@link android.view.inputmethod.InputConnection} object.
 */
message InputConnectionProto {
  reserved 1; // string editable_text
  reserved 2; // string selected_text
  optional int32 selected_text_start = 3;
  optional int32 selected_text_end = 4;
  optional int32 cursor_caps_mode = 5;
}

/**
 * Shows information about parameters and result for method calls to
 * {@link android.view.inputmethod.InputConnection}.
 */
message InputConnectionCallProto {
  oneof method_call {
    GetTextBeforeCursor get_text_before_cursor = 1;
    GetTextAfterCursor get_text_after_cursor = 2;
    GetSelectedText get_selected_text = 3;
    GetSurroundingText get_surrounding_text = 4;
    GetCursorCapsMode get_cursor_caps_mode = 5;
    GetExtractedText get_extracted_text = 6;
  }

  message GetTextBeforeCursor {
    optional int32 length = 1;
    optional int32 flags = 2;
    reserved 3; // string result
  }

  message GetTextAfterCursor {
    optional int32 length = 1;
    optional int32 flags = 2;
    reserved 3; // string result = 3
  }

  message GetSelectedText {
    optional int32 flags = 1;
    reserved 2; // string result = 2
  }

  message GetSurroundingText {
    optional int32 before_length = 1;
    optional int32 after_length = 2;
    optional int32 flags = 3;
    optional SurroundingText result = 4;

    message SurroundingText {
      reserved 1; // string text = 1
      optional int32 selection_start = 2;
      optional int32 selection_end = 3;
      optional int32 offset = 4;
    }
  }

  message GetCursorCapsMode {
    optional int32 req_modes = 1;
    optional int32 result = 2;
  }

  message GetExtractedText {
    optional ExtractedTextRequest request = 1;
    optional int32 flags = 2;
    reserved 3; // string result = 3

    message ExtractedTextRequest {
      optional int32 token = 1;
      optional int32 flags = 2;
      optional int32 hint_max_lines = 3;
      optional int32 hint_max_chars = 4;
    }
  }
}