diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-08 13:27:19 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-08 13:27:19 +0100 |
commit | 6820f9e14f2bcf542595b29e3d3e6ea28a8b7025 (patch) | |
tree | cfff36d4631401187c6018a49adeeae69f47d6da /Applications | |
parent | eda086699287dcd8f6f858a5d3c0a43009dd9e59 (diff) | |
download | serenity-6820f9e14f2bcf542595b29e3d3e6ea28a8b7025.zip |
WindowServer+LibGUI: Add a server-side clipboard.
On the client side, use GClipboard's data() and set_data(String) to access
the global clipboard. :^)
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/TextEditor/main.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Applications/TextEditor/main.cpp b/Applications/TextEditor/main.cpp index 84b474cf04..9200794c22 100644 --- a/Applications/TextEditor/main.cpp +++ b/Applications/TextEditor/main.cpp @@ -8,6 +8,7 @@ #include <LibGUI/GTextEditor.h> #include <LibGUI/GAction.h> #include <LibGUI/GFontDatabase.h> +#include <LibGUI/GClipboard.h> #include <AK/StringBuilder.h> #include <unistd.h> #include <stdio.h> @@ -83,11 +84,14 @@ int main(int argc, char** argv) }); auto copy_action = GAction::create("Copy", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/copyfile16.rgb", { 16, 16 }), [&] (const GAction&) { - printf("Copy: \"%s\"\n", text_editor->selected_text().characters()); + auto selected_text = text_editor->selected_text(); + printf("Copy: \"%s\"\n", selected_text.characters()); + GClipboard::the().set_data(selected_text); }); auto paste_action = GAction::create("Paste", { Mod_Ctrl, Key_V }, GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/paste16.rgb", { 16, 16 }), [&] (const GAction&) { - dbgprintf("FIXME: Implement Edit/Paste"); + auto paste_text = GClipboard::the().data(); + printf("Paste: \"%s\"\n", paste_text.characters()); }); auto menubar = make<GMenuBar>(); |