comparison mde/content/AStringContent.d @ 167:620d4ea30228

Context menus: added a clipboard (functions accessible from main menu rather than context menu).
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 27 Jun 2009 11:57:26 +0200
parents bb2f1a76346d
children e45226d3deae
comparison
equal deleted inserted replaced
166:55667d048c31 167:620d4ea30228
79 if (c !is null) { 79 if (c !is null) {
80 sv = c.toString (0).dup; 80 sv = c.toString (0).dup;
81 return endEdit; 81 return endEdit;
82 } 82 }
83 return false; 83 return false;
84 }
85
86 /** Set value directly from a string. */
87 override void opAssign (char[] str) {
88 sv = str.dup;
89 return endEdit;
84 } 90 }
85 91
86 /** Acts on a keystroke to edit the value as a string. 92 /** Acts on a keystroke to edit the value as a string.
87 * 93 *
88 * After this has been used to edit the string, endEdit should be called 94 * After this has been used to edit the string, endEdit should be called
179 * 185 *
180 * Should never throw; should reset sv at least when returning false. */ 186 * Should never throw; should reset sv at least when returning false. */
181 bool endEdit (); 187 bool endEdit ();
182 188
183 protected: 189 protected:
190 //TODO: copy-on-assign, copy-on-edit, or what?
184 /* String version of value (for toString(0) and editing). 191 /* String version of value (for toString(0) and editing).
185 * WARNING: This must point to mutable memory (for endEdit), and 192 * WARNING: This must point to mutable memory (for endEdit), and
186 * when keyStroke can be called we must have svBuf[0..sv.length] == sv. */ 193 * when keyStroke can be called we must have svBuf[0..sv.length] == sv. */
187 char[] sv; 194 char[] sv;
188 char[] svBuf; // buffer to reduce reallocs 195 char[] svBuf; // buffer to reduce reallocs
254 v = *valp; 261 v = *valp;
255 super (symbol); 262 super (symbol);
256 } 263 }
257 264
258 void assignNoCng (char[] val) { 265 void assignNoCng (char[] val) {
259 v = val; 266 v = val.dup;
260 if (pos > sv.length) pos = sv.length; 267 if (pos > sv.length) pos = sv.length;
261 endEvent; 268 endEvent;
262 } 269 }
263 void opAssign (char[] val) { 270 void opAssign (char[] val) {
264 assignNoCng (val); 271 assignNoCng (val);