Skip to content

Commit

Permalink
new readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian8j2 committed Aug 22, 2022
1 parent b078b37 commit c09cfc5
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
# ClipboardXX
Header only lightweight library to **copy** and **paste** text from clipboard
*Copyright (C) 2020 Arian Rezazadeh*
Header only lightweight library to **copy** and **paste** text from clipboard

## Example
```C++
#include "clipboard.hpp"
#include <clipboardxx.hpp>
#include <string>

int main() {
clipboardxx::clipboard clipboard;

// copy
clipboard << "text you wanna copy";
clipboard << "text you wanna copy"; // or clipboard.copy("text you wanna copy")


// paste
std::string paste_text;
clipboard >> paste_text;
clipboard >> paste_text; // or const std::string paste_text = clipboard.paste()
}
```

## Setup
## Compatibility
What supports:
- Copy pasting utf-8 text in mentioned operating systems
- Windows
- X11 in GNU/Linux based operating systems

### Windows
Nothing specially need to do, just copy `clipboard.hpp` under **include** folder to your include path.
What **not** supports:
- MacOS
- Wayland in GNU/Linux based operating systems (maybe soon ...)
- Copy pasting other formats such as images, documents ...

### Linux
in linux based operating systems, clipboardxx requires **xcb** and **pthread** to work, Link them manually or use CMake.
## Usage

### MacOS
There is currently **no support for MacOS**, Any contribute would be much appreciated.
#### Windows
Nothing specially need to do, You need all files under `include` directory and then include `clipboardxx.hpp` file and you are good to go

#### CMake
By using CMake, there is no need to manually change include path or link dependencies, Just put clipboardxx folder in your project subdirectoy and use `add_subdirectory` function to create `ClipboardXX` library and then link library to your target.
#### GNU/Linux
As mentioned before, Currently *ClipboardXX* only supports *X11* and needs *xcb* library and header files to communicate with it. So you need to install *xcb* with any way that you prefer. Then you need *cmake* to compile it without any hassle, just add *ClipboardXX* subdirectory in your cmake file:
```cmake
add_subdirectory(ClipboardXX)
target_link_libraries(your_target ClipboardXX)
```
## Error handling
In certain situations such as:
- cannot open clipboard in windows
- cannot empty clipboard in windows
- cannot allocate memory for copying data in windows

clipboardxx will throw an execption of type `clipboardxx::exception` you can handle it by your own way.
## Similar projects
[clip](https://github.com/dacap/clip) (+has so many formats for copy and paste, -it's not header only)

0 comments on commit c09cfc5

Please sign in to comment.