term-owo-cpp/clip-lib
2024-06-20 15:11:55 +01:00
..
clip_common.h fix 2024-06-20 15:11:55 +01:00
clip_lock_impl.h fix 2024-06-20 15:11:55 +01:00
clip_none.cpp fix 2024-06-20 15:11:55 +01:00
clip_osx.h fix 2024-06-20 15:11:55 +01:00
clip_osx.mm fix 2024-06-20 15:11:55 +01:00
clip_win_bmp.cpp fix 2024-06-20 15:11:55 +01:00
clip_win_bmp.h fix 2024-06-20 15:11:55 +01:00
clip_win_wic.cpp fix 2024-06-20 15:11:55 +01:00
clip_win_wic.h fix 2024-06-20 15:11:55 +01:00
clip_win.cpp fix 2024-06-20 15:11:55 +01:00
clip_win.h fix 2024-06-20 15:11:55 +01:00
clip_x11_png.h fix 2024-06-20 15:11:55 +01:00
clip_x11.cpp fix 2024-06-20 15:11:55 +01:00
clip.cpp fix 2024-06-20 15:11:55 +01:00
clip.h fix 2024-06-20 15:11:55 +01:00
CMakeLists.txt fix 2024-06-20 15:11:55 +01:00
CONTRIBUTING.md fix 2024-06-20 15:11:55 +01:00
image.cpp fix 2024-06-20 15:11:55 +01:00
README.md fix 2024-06-20 15:11:55 +01:00

Clip Library

Copyright (c) 2015-2024 David Capello

build MIT Licensed

Library to copy/retrieve content to/from the clipboard/pasteboard.

Features

Available features on Windows, macOS, and Linux (X11):

  • Copy/paste UTF-8 text.
  • Copy/paste user-defined data.
  • Copy/paste RGB/RGBA images. This library use non-premultiplied alpha RGB values.

Example

#include "clip.h"
#include <iostream>

int main() {
  clip::set_text("Hello World");

  std::string value;
  clip::get_text(value);
  std::cout << value << "\n";
}

User-defined clipboard formats

#include "clip.h"

int main() {
  clip::format my_format =
    clip::register_format("com.appname.FormatName");

  int value = 32;

  clip::lock l;
  l.clear();
  l.set_data(clip::text_format(), "Alternative text for value 32");
  l.set_data(my_format, &value, sizeof(int));
}

Platform specific details

  • If two versions of your application (32-bit and 64-bit) can run at at the same time, remember to avoid storing data types that could change depending on the platform (e.g. size_t) in your custom format data.
  • Windows:
  • Linux:
    • To be able to copy/paste on Linux you need libx11-dev/libX11-devel package.
    • To copy/paste images you will need libpng-dev/libpng-devel package.

Compilation Flags

  • CLIP_ENABLE_IMAGE: Enables the support to copy/paste images.
  • CLIP_ENABLE_LIST_FORMATS (only for Windows): Enables the clip::lock::list_formats() API function and the list_clip_formats example.
  • CLIP_EXAMPLES: Compile examples.
  • CLIP_TESTS: Compile tests.
  • CLIP_X11_WITH_PNG (only for Linux/X11): Enables support to copy/paste images using the libpng library on Linux.

Who is using this library?

Check the wiki to know what projects are using the clip library.