Mercurial > projects > mde
comparison mde/content/Services.d @ 149:1125ba603af6
Some ideas for content service menus.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 14 Mar 2009 11:05:51 +0100 |
parents | 08651e8a8c51 |
children |
comparison
equal
deleted
inserted
replaced
148:17438f17bfb5 | 149:1125ba603af6 |
---|---|
18 | 18 |
19 /** Content services. | 19 /** Content services. |
20 * | 20 * |
21 * Services act on a content, potentially modifying it. They have the form: | 21 * Services act on a content, potentially modifying it. They have the form: |
22 * --- | 22 * --- |
23 * bool service (ref Content c); | 23 * bool service (Content c); |
24 * --- | 24 * --- |
25 * where c is the content acted on, and the return value is true if the content was changed (useful | 25 * where c is the content acted on, and the return value is true if the content was changed (useful |
26 * to know whether caches need updating or not). | 26 * to know whether caches need updating or not). |
27 */ | 27 */ |
28 module mde.content.Services; | 28 module mde.content.Services; |
29 | 29 |
30 bool copy (ref Content c) { | 30 import mde.content.AStringContent; |
31 // Put a duplicate on the clipboard, so later changes don't affect what's on the clipboard. | 31 |
32 clipboard = c.dup; | 32 union ContentUnion { |
33 return false; | 33 *Content ; |
34 } | 34 } |
35 | 35 |
36 bool paste (ref ContentText c) { | 36 bool copy (Content c) { |
37 if (clipboard is null) | 37 // store by type |
38 return false; // no item on clipboard, so don't do anything | 38 clipboard = c; |
39 c = clipboard.toText; | |
40 return true; | |
41 } | 39 } |
42 | 40 |
43 bool paste (ref ContentInt c) { | 41 bool paste (StringContent c) { |
44 if (clipboard is null) | 42 if (clipboard) |
45 return false; // no item on clipboard, so don't do anything | 43 c = clipboard.toString (0); |
46 c = clipboard.toInt; | 44 } |
47 return true; | 45 |
46 bool paste (IntContent c) { | |
47 | |
48 } | 48 } |
49 | 49 |
50 bool link (ref ContentText c) { | 50 bool link (ref ContentText c) { |
51 if (clipboard is null) | 51 if (clipboard is null) |
52 return false; // no item on clipboard, so don't do anything | 52 return false; // no item on clipboard, so don't do anything |
53 c = clipboard; | 53 c = clipboard; |
54 return true; | 54 return true; |
55 } | 55 } |
56 | 56 |
57 Content clipboard; | 57 ContentUnion clipboard; |