Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_MODEL_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_MODEL_H_ |
| 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_MODEL_H_ | 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_MODEL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 void ReplaceChar(base::char16 c) { | 88 void ReplaceChar(base::char16 c) { |
| 89 ReplaceTextInternal(base::string16(&c, 1), true); | 89 ReplaceTextInternal(base::string16(&c, 1), true); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Appends the text. | 92 // Appends the text. |
| 93 // The current composition text will be confirmed. | 93 // The current composition text will be confirmed. |
| 94 void Append(const base::string16& new_text); | 94 void Append(const base::string16& new_text); |
| 95 | 95 |
| 96 // Deletes the first character after the current cursor position (as if, the | 96 // Deletes the first character after the current cursor position (as if, the |
| 97 // the user has pressed delete key in the textfield). Returns true if | 97 // the user has pressed delete key in the textfield). Returns true if |
| 98 // the deletion is successful. | 98 // the deletion is successful. If |add_to_kill_buffer| is true, the deleted |
| 99 // text is copied to the kill buffer. | |
| 99 // If there is composition text, it'll be deleted instead. | 100 // If there is composition text, it'll be deleted instead. |
| 100 bool Delete(); | 101 bool Delete(bool add_to_kill_buffer); |
|
tapted
2016/07/06 01:46:37
default arguments are allowed by the style guide n
karandeepb
2016/07/19 07:04:40
Done.
| |
| 102 | |
| 103 bool Delete() { return Delete(false); } | |
| 101 | 104 |
| 102 // Deletes the first character before the current cursor position (as if, the | 105 // Deletes the first character before the current cursor position (as if, the |
| 103 // the user has pressed backspace key in the textfield). Returns true if | 106 // the user has pressed backspace key in the textfield). Returns true if |
| 104 // the removal is successful. | 107 // the removal is successful. If |add_to_kill_buffer| is true, the deleted |
| 108 // text is copied to the kill buffer. | |
| 105 // If there is composition text, it'll be deleted instead. | 109 // If there is composition text, it'll be deleted instead. |
| 106 bool Backspace(); | 110 bool Backspace(bool add_to_kill_buffer); |
| 111 | |
| 112 bool Backspace() { return Backspace(false); } | |
| 107 | 113 |
| 108 // Cursor related methods. | 114 // Cursor related methods. |
| 109 | 115 |
| 110 // Returns the current cursor position. | 116 // Returns the current cursor position. |
| 111 size_t GetCursorPosition() const; | 117 size_t GetCursorPosition() const; |
| 112 | 118 |
| 113 // Moves the cursor, see RenderText for additional details. | 119 // Moves the cursor, see RenderText for additional details. |
| 114 // The current composition text will be confirmed. | 120 // The current composition text will be confirmed. |
| 115 void MoveCursor(gfx::BreakType break_type, | 121 void MoveCursor(gfx::BreakType break_type, |
| 116 gfx::VisualCursorDirection direction, | 122 gfx::VisualCursorDirection direction, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 | 181 |
| 176 // Pastes text from the clipboard at current cursor position. Returns true | 182 // Pastes text from the clipboard at current cursor position. Returns true |
| 177 // if any text is pasted. | 183 // if any text is pasted. |
| 178 bool Paste(); | 184 bool Paste(); |
| 179 | 185 |
| 180 // Transposes the characters to either side of the insertion point and | 186 // Transposes the characters to either side of the insertion point and |
| 181 // advances the insertion point past both of them. Returns true if text is | 187 // advances the insertion point past both of them. Returns true if text is |
| 182 // changed. | 188 // changed. |
| 183 bool Transpose(); | 189 bool Transpose(); |
| 184 | 190 |
| 191 // Pastes text from the kill buffer at the current cursor position or | |
| 192 // selection. | |
| 193 bool Yank(); | |
| 194 | |
| 185 // Tells if any text is selected, even if the selection is in composition | 195 // Tells if any text is selected, even if the selection is in composition |
| 186 // text. | 196 // text. |
| 187 bool HasSelection() const; | 197 bool HasSelection() const; |
| 188 | 198 |
| 189 // Deletes the selected text. This method shouldn't be called with | 199 // Deletes the selected text. This method shouldn't be called with |
| 190 // composition text. | 200 // composition text. |
| 191 void DeleteSelection(); | 201 void DeleteSelection(); |
| 192 | 202 |
| 193 // Deletes the selected text (if any) and insert text at given position. | 203 // Deletes the selected text (if any) and insert text at given position. |
| 194 void DeleteSelectionAndInsertTextAt(const base::string16& new_text, | 204 void DeleteSelectionAndInsertTextAt(const base::string16& new_text, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 // 2) new edit is added. (redo history is cleared) | 304 // 2) new edit is added. (redo history is cleared) |
| 295 // 3) redone all undone edits. | 305 // 3) redone all undone edits. |
| 296 EditHistory::iterator current_edit_; | 306 EditHistory::iterator current_edit_; |
| 297 | 307 |
| 298 DISALLOW_COPY_AND_ASSIGN(TextfieldModel); | 308 DISALLOW_COPY_AND_ASSIGN(TextfieldModel); |
| 299 }; | 309 }; |
| 300 | 310 |
| 301 } // namespace views | 311 } // namespace views |
| 302 | 312 |
| 303 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_MODEL_H_ | 313 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_MODEL_H_ |
| OLD | NEW |