From 33ceef3d2f3a900212e42e71af9edb1647fe8ac5 Mon Sep 17 00:00:00 2001 From: Hammy Date: Fri, 3 Sep 2021 00:02:08 +0100 Subject: [PATCH 1/3] Update README.md --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 38a7150..956c563 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,71 @@ The inspiration for this project came from my frustration of macOS not having cl built-in unlike Windows. This library will allow you to access the system clipboard and manipulate it. # Configuration -TODO + +Follow the steps below for a basic implementation: + +```java +public class Main { + public static void main(String[] args) { + // Retrieve an instance of MyClipboard + MyClipboard myClipboard = MyClipboard.getSystemClipboard(); + + // Start listening for clipboard notifications + myClipboard.startListening(); + + // Add event listeners for different types of events (Text, Image & File) + myClipboard.addEventListener((TextEvent) (oldContent, newContent) -> { + String oldText = oldContent.getText(); + BufferedImage oldImage = oldContent.getImage(); + List oldFiles = oldContent.getFiles(); + System.out.println("Old Text: " + oldText); + System.out.println("Old Image: " + oldImage); + System.out.println("Old File: " + oldFiles); + System.out.println("New String Content: " + newContent); + }); + + myClipboard.addEventListener((ImageEvent) (oldContent, newContent) -> { + String oldText = oldContent.getText(); + BufferedImage oldImage = oldContent.getImage(); + List oldFiles = oldContent.getFiles(); + System.out.println("Old Text: " + oldText); + System.out.println("Old Image: " + oldImage); + System.out.println("Old File: " + oldFiles); + System.out.println("New Image Content: " + newContent); + }); + + myClipboard.addEventListener((FileEvent) (oldContent, newContent) -> { + String oldText = oldContent.getText(); + BufferedImage oldImage = oldContent.getImage(); + List oldFiles = oldContent.getFiles(); + System.out.println("Old Text: " + oldText); + System.out.println("Old Image: " + oldImage); + System.out.println("Old File" + oldFiles); + System.out.println("New File Content: " + newContent); + }); + + // Insert into the clipboard + myClipboard.insert("exampleContent"); + + // Insert and notify MyClipboard of the new content + myClipboard.insertAndNotify("exampleContent"); + + // Set monitoring for clipboard types + myClipboard.setImageMonitored(true || false); + myClipboard.setTextMonitored(true || false); + myClipboard.setFileMonitored(true || false); + + // Toggle monitoring for clipboard types + myClipboard.toggleTextMonitored(); + myClipboard.toggleImagesMonitored(); + myClipboard.toggleFilesMonitored(); + + // Stop listening for clipboard notifications + myClipboard.stopListening(); + } +} +``` + # Windows / *Unix This approach differs from the macOS section below as Windows/*Unix properly notify the program with global clipboard events. @@ -34,9 +98,6 @@ Unlike the aforementioned event-driven approach, macOS unfortunately is not very system clipboard has changed. To query the system clipboard contents, we need to employ a polling schedule. I have chosen **200ms** to ensure that images and large files can be copied over as well as reducing the load on the CPU. -# Contributing -TODO - # Installation Latest Stable Version: ![maven-central] From 4ebf168a081511416e4132eaec5b08934e6f4b47 Mon Sep 17 00:00:00 2001 From: Hamothy <58985301+sgoudham@users.noreply.github.com> Date: Tue, 5 Apr 2022 21:23:28 -0700 Subject: [PATCH 2/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 956c563..46519ef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [license]: https://img.shields.io/github/license/sgoudham/MyClipboard [maven-central]: https://img.shields.io/maven-central/v/me.goudham/MyClipboard.svg?label=Maven%20Central -[build-status]: https://goudham.me/jenkins/job/MyClipboard/job/release/badge/icon +[build-status]: https://goudham.me/jenkins/job/sgoudham/job/MyClipboard/job/release/badge/icon [codecov]: https://codecov.io/gh/sgoudham/MyClipboard/branch/main/graph/badge.svg?token=F4LKql7rIq [issues]: https://img.shields.io/github/issues/sgoudham/MyClipboard?label=issues [pull-requests]: https://img.shields.io/github/issues-pr/sgoudham/MyClipboard @@ -126,4 +126,4 @@ dependencies { ``` # License -[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyClipboard.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyClipboard?ref=badge_large) \ No newline at end of file +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyClipboard.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyClipboard?ref=badge_large) From a5cf168fe91c0cb6b69a8b275c35ff48993671bf Mon Sep 17 00:00:00 2001 From: Hamothy <58985301+sgoudham@users.noreply.github.com> Date: Tue, 5 Apr 2022 21:32:19 -0700 Subject: [PATCH 3/3] Update version to 0.3.0 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 622e21c..15cbb87 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.goudham MyClipboard - 0.2.0 + 0.3.0 jar MyClipboard @@ -186,4 +186,4 @@ - \ No newline at end of file +