| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_CPP_DEV_IME_INPUT_EVENT_DEV_H_ | 5 #ifndef PPAPI_CPP_DEV_IME_INPUT_EVENT_DEV_H_ |
| 6 #define PPAPI_CPP_DEV_IME_INPUT_EVENT_DEV_H_ | 6 #define PPAPI_CPP_DEV_IME_INPUT_EVENT_DEV_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ppapi/c/dev/ppb_ime_input_event_dev.h" | 10 #include "ppapi/c/dev/ppb_ime_input_event_dev.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 /// @return A string var representing the composition text. For non-IME | 34 /// @return A string var representing the composition text. For non-IME |
| 35 /// input events the return value will be an undefined var. | 35 /// input events the return value will be an undefined var. |
| 36 Var GetText() const; | 36 Var GetText() const; |
| 37 | 37 |
| 38 /// Returns the number of segments in the composition text. | 38 /// Returns the number of segments in the composition text. |
| 39 /// | 39 /// |
| 40 /// @return The number of segments. For events other than COMPOSITION_UPDATE, | 40 /// @return The number of segments. For events other than COMPOSITION_UPDATE, |
| 41 /// returns 0. | 41 /// returns 0. |
| 42 uint32_t GetSegmentNumber() const; | 42 uint32_t GetSegmentNumber() const; |
| 43 | 43 |
| 44 /// Returns the start and the end position of the index-th segment in the | 44 /// Returns the position of the index-th segmentation point in the composition |
| 45 /// composition text. The positions are given by byte-indices of the string | 45 /// text. The position is given by a byte-offset (not a character-offset) of |
| 46 /// GetText(). They always satisfy 0 <= .first < .second <= (Length of | 46 /// the string returned by GetText(). It always satisfies |
| 47 /// GetText()) and GetSegmentAt(index).first < GetSegmentAt(index+1).first. | 47 /// 0=GetSegmentOffset(0) < ... < GetSegmentOffset(i) < GetSegmentOffset(i+1) |
| 48 /// When the event is not COMPOSITION_UPDATE or index >= GetSegmentNumber(), | 48 /// < ... < GetSegmentOffset(GetSegmentNumber())=(byte-length of GetText()). |
| 49 /// returns (0, 0). | 49 /// Note that [GetSegmentOffset(i), GetSegmentOffset(i+1)) represents the |
| 50 /// range of the i-th segment, and hence GetSegmentNumber() can be a valid |
| 51 /// argument to this function instead of an off-by-1 error. |
| 52 /// |
| 53 /// @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME |
| 54 /// event. |
| 50 /// | 55 /// |
| 51 /// @param[in] index An integer indicating a segment. | 56 /// @param[in] index An integer indicating a segment. |
| 52 /// | 57 /// |
| 53 /// @return A pair of integers representing the index-th segment. | 58 /// @return The byte-offset of the segmentation point. If the event is not |
| 54 std::pair<uint32_t, uint32_t> GetSegmentAt(uint32_t index) const; | 59 /// COMPOSITION_UPDATE or index is out of range, returns 0. |
| 60 uint32_t GetSegmentOffset(uint32_t index) const; |
| 55 | 61 |
| 56 /// Returns the index of the current target segment of composition. | 62 /// Returns the index of the current target segment of composition. |
| 57 /// | 63 /// |
| 58 /// @return An integer indicating the index of the target segment. When there | 64 /// @return An integer indicating the index of the target segment. When there |
| 59 /// is no active target segment, or the event is not COMPOSITION_UPDATE, | 65 /// is no active target segment, or the event is not COMPOSITION_UPDATE, |
| 60 /// returns -1. | 66 /// returns -1. |
| 61 int32_t GetTargetSegment() const; | 67 int32_t GetTargetSegment() const; |
| 62 | 68 |
| 63 /// Returns the range selected by caret in the composition text. | 69 /// Returns the range selected by caret in the composition text. |
| 64 /// | 70 /// |
| 65 /// @return A pair of integers indicating the selection range. | 71 /// @return A pair of integers indicating the selection range. |
| 66 std::pair<uint32_t, uint32_t> GetSelection() const; | 72 std::pair<uint32_t, uint32_t> GetSelection() const; |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 } // namespace pp | 75 } // namespace pp |
| 70 | 76 |
| 71 #endif // PPAPI_CPP_DEV_IME_INPUT_EVENT_DEV_H_ | 77 #endif // PPAPI_CPP_DEV_IME_INPUT_EVENT_DEV_H_ |
| OLD | NEW |