summaryrefslogtreecommitdiffstats
path: root/ui/platform_window/text_input_state.h
blob: 14d016bcede790835eb8df9a43d19c28909b15fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_PLATFORM_WINDOW_TEXT_INPUT_STATE_H_
#define UI_PLATFORM_WINDOW_TEXT_INPUT_STATE_H_

#include <string>

#include "ui/base/ime/text_input_flags.h"
#include "ui/base/ime/text_input_type.h"

namespace ui {

// Text input info which is based on blink::WebTextInputInfo.
struct TextInputState {
  TextInputState();
  TextInputState(TextInputType type,
                 int flags,
                 const std::string& text,
                 int selection_start,
                 int selection_end,
                 int composition_start,
                 int composition_end,
                 bool can_compose_inline);
  bool operator==(const TextInputState& other) const;

  // The type of input field.
  TextInputType type;

  // The flags of the input field (autocorrect, autocomplete, etc.).
  int flags;

  // The value of the input field.
  std::string text;

  // The cursor position of the current selection start, or the caret position
  // if nothing is selected.
  int selection_start;

  // The cursor position of the current selection end, or the caret position
  // if nothing is selected.
  int selection_end;

  // The start position of the current composition, or -1 if there is none.
  int composition_start;

  // The end position of the current composition, or -1 if there is none.
  int composition_end;

  // Whether or not inline composition can be performed for the current input.
  bool can_compose_inline;
};

}  // namespace ui

#endif  // UI_PLATFORM_WINDOW_TEXT_INPUT_STATE_H_