1 /** 2 The clipboard library. 3 */ 4 module clipboard; 5 6 import std.stdio; 7 8 /** 9 Read a string from the clipboard. 10 */ 11 public wstring readClipboard() { 12 version(Windows) { 13 import clipboard_windows; 14 return clipboard_windows.readClipboard(); 15 } else version(OSX) { 16 import clipboard_darwin; 17 return clipboard_darwin.readClipboard(); 18 } else version(linux) { 19 import clipboard_linux; 20 return clipboard_linux.readClipboard(); 21 } else { 22 writeln("This plattform is not supported."); 23 } 24 } 25 26 /** 27 Write a string to the clipboard. 28 */ 29 public void writeClipboard(wstring text) { 30 version(Windows) { 31 import clipboard_windows; 32 clipboard_windows.writeClipboard(text); 33 } else version(OSX) { 34 import clipboard_darwin; 35 return clipboard_darwin.writeClipboard(text); 36 } else version(linux) { 37 import clipboard_linux; 38 return clipboard_linux.writeClipboard(text); 39 } else { 40 writeln("This plattform is not supported."); 41 } 42 } 43 44 /** 45 Clears the clipboard. 46 */ 47 public void clearClipboard() { 48 version(Windows) { 49 import clipboard_windows; 50 clipboard_windows.clearClipboard(); 51 } else version(OSX) { 52 import clipboard_darwin; 53 return clipboard_darwin.clearClipboard(); 54 } else version(linux) { 55 import clipboard_linux; 56 return clipboard_linux.clearClipboard(); 57 } else { 58 writeln("This plattform is not supported."); 59 } 60 } 61 62 /** 63 Prepare the console in order to read and write UTF8 strings. 64 */ 65 public void prepareConsole() { 66 version(Windows) { 67 import clipboard_windows; 68 clipboard_windows.prepareConsole(); 69 } else version(OSX) { 70 import clipboard_darwin; 71 return clipboard_darwin.prepareConsole(); 72 } else version(linux) { 73 import clipboard_linux; 74 return clipboard_linux.prepareConsole(); 75 } else { 76 writeln("This plattform is not supported."); 77 } 78 }