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

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: Add a comment. 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);
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 bool Cut(); 176 bool Cut();
171 177
172 // Copies the currently selected text and puts it to clipboard. Returns true 178 // Copies the currently selected text and puts it to clipboard. Returns true
173 // if something was copied to the clipboard. 179 // if something was copied to the clipboard.
174 bool Copy(); 180 bool Copy();
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
186 // Pastes text from the kill buffer at the current cursor position or
187 // selection.
188 bool Yank();
189
180 // Tells if any text is selected, even if the selection is in composition 190 // Tells if any text is selected, even if the selection is in composition
181 // text. 191 // text.
182 bool HasSelection() const; 192 bool HasSelection() const;
183 193
184 // Deletes the selected text. This method shouldn't be called with 194 // Deletes the selected text. This method shouldn't be called with
185 // composition text. 195 // composition text.
186 void DeleteSelection(); 196 void DeleteSelection();
187 197
188 // Deletes the selected text (if any) and insert text at given position. 198 // Deletes the selected text (if any) and insert text at given position.
189 void DeleteSelectionAndInsertTextAt(const base::string16& new_text, 199 void DeleteSelectionAndInsertTextAt(const base::string16& new_text,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // 2) new edit is added. (redo history is cleared) 299 // 2) new edit is added. (redo history is cleared)
290 // 3) redone all undone edits. 300 // 3) redone all undone edits.
291 EditHistory::iterator current_edit_; 301 EditHistory::iterator current_edit_;
292 302
293 DISALLOW_COPY_AND_ASSIGN(TextfieldModel); 303 DISALLOW_COPY_AND_ASSIGN(TextfieldModel);
294 }; 304 };
295 305
296 } // namespace views 306 } // namespace views
297 307
298 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_MODEL_H_ 308 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698