Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: ui/views/controls/textfield/textfield_model.h

Issue 2119813002: views::Textfield: Implement yank editing command. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 = false);
101 102
102 // Deletes the first character before the current cursor position (as if, the 103 // 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 104 // the user has pressed backspace key in the textfield). Returns true if
104 // the removal is successful. 105 // the removal is successful. If |add_to_kill_buffer| is true, the deleted
106 // text is copied to the kill buffer.
105 // If there is composition text, it'll be deleted instead. 107 // If there is composition text, it'll be deleted instead.
106 bool Backspace(); 108 bool Backspace(bool add_to_kill_buffer = false);
107 109
108 // Cursor related methods. 110 // Cursor related methods.
109 111
110 // Returns the current cursor position. 112 // Returns the current cursor position.
111 size_t GetCursorPosition() const; 113 size_t GetCursorPosition() const;
112 114
113 // Moves the cursor, see RenderText for additional details. 115 // Moves the cursor, see RenderText for additional details.
114 // The current composition text will be confirmed. 116 // The current composition text will be confirmed.
115 void MoveCursor(gfx::BreakType break_type, 117 void MoveCursor(gfx::BreakType break_type,
116 gfx::VisualCursorDirection direction, 118 gfx::VisualCursorDirection direction,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 177
176 // Pastes text from the clipboard at current cursor position. Returns true 178 // Pastes text from the clipboard at current cursor position. Returns true
177 // if any text is pasted. 179 // if any text is pasted.
178 bool Paste(); 180 bool Paste();
179 181
180 // Transposes the characters to either side of the insertion point and 182 // 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 183 // advances the insertion point past both of them. Returns true if text is
182 // changed. 184 // changed.
183 bool Transpose(); 185 bool Transpose();
184 186
187 // Pastes text from the kill buffer at the current cursor position or
188 // selection.
189 bool Yank();
190
185 // Tells if any text is selected, even if the selection is in composition 191 // Tells if any text is selected, even if the selection is in composition
186 // text. 192 // text.
187 bool HasSelection() const; 193 bool HasSelection() const;
188 194
189 // Deletes the selected text. This method shouldn't be called with 195 // Deletes the selected text. This method shouldn't be called with
190 // composition text. 196 // composition text.
191 void DeleteSelection(); 197 void DeleteSelection();
192 198
193 // Deletes the selected text (if any) and insert text at given position. 199 // Deletes the selected text (if any) and insert text at given position.
194 void DeleteSelectionAndInsertTextAt(const base::string16& new_text, 200 void DeleteSelectionAndInsertTextAt(const base::string16& new_text,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // 2) new edit is added. (redo history is cleared) 300 // 2) new edit is added. (redo history is cleared)
295 // 3) redone all undone edits. 301 // 3) redone all undone edits.
296 EditHistory::iterator current_edit_; 302 EditHistory::iterator current_edit_;
297 303
298 DISALLOW_COPY_AND_ASSIGN(TextfieldModel); 304 DISALLOW_COPY_AND_ASSIGN(TextfieldModel);
299 }; 305 };
300 306
301 } // namespace views 307 } // namespace views
302 308
303 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_MODEL_H_ 309 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698