1 /** 2 * Insert module. 3 * 4 * License: 5 * MIT. See LICENSE for full details. 6 */ 7 module tkd.widget.common.insert; 8 9 /** 10 * These are common commands that apply to all widgets that have them injected. 11 */ 12 mixin template Insert() 13 { 14 /** 15 * Insert text at an index. 16 * 17 * Params: 18 * text = The text to insert. 19 * charIndex = The index to insert the text. 20 * 21 * Returns: 22 * This widget to aid method chaining. 23 */ 24 public auto insertTextAt(this T)(string text, int charIndex) 25 { 26 this._tk.eval("%s insert %s %s", this.id, charIndex, text); 27 28 return cast(T) this; 29 } 30 31 /** 32 * Append text to the end. 33 * 34 * Params: 35 * text = The text to insert. 36 * 37 * Returns: 38 * This widget to aid method chaining. 39 */ 40 public auto appendText(this T)(string text) 41 { 42 this._tk.eval("%s insert end %s", this.id, text); 43 44 return cast(T) this; 45 } 46 47 /** 48 * Insert text at the cursor position. 49 * 50 * Params: 51 * text = The text to insert. 52 * 53 * Returns: 54 * This widget to aid method chaining. 55 * 56 * See_Also: 57 * $(LINK2 ./cursor.html, tkd.widget.common.cursor) $(BR) 58 * $(LINK2 ./index.html, tkd.widget.common.index) $(BR) 59 */ 60 public auto insertTextAtCursor(this T)(string text) 61 { 62 this._tk.eval("%s insert insert %s", this.id, text); 63 64 return cast(T) this; 65 } 66 }