-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update README, update plugin build version range * add notifier * update plugin description * [WIP] add a cmd * added command a and A * [WIP] add paste cmd * [WIP] update README * 0.4.0 added command p
- Loading branch information
Showing
6 changed files
with
75 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package top.threep.plugin.txtic.cmd; | ||
|
||
import com.jgoodies.common.base.Strings; | ||
|
||
import java.awt.*; | ||
import java.awt.datatransfer.DataFlavor; | ||
import java.awt.datatransfer.UnsupportedFlavorException; | ||
import java.io.IOException; | ||
|
||
public class PasteCmd implements Cmd { | ||
private String separator = " "; | ||
private int idx = 0; | ||
private String[] contents; | ||
|
||
public PasteCmd(String options) { | ||
if (!Strings.isEmpty(options)) { | ||
this.separator = options; | ||
} | ||
this.initContents(); | ||
} | ||
|
||
private void initContents() { | ||
try { | ||
String data = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor); | ||
if (Strings.isEmpty(data)) { | ||
this.contents = new String[]{}; | ||
return; | ||
} | ||
this.contents = data.split(this.separator); | ||
} catch (UnsupportedFlavorException | IOException ignored) { | ||
} | ||
} | ||
|
||
@Override | ||
public String run(String text) { | ||
if (this.contents.length == 0 || (this.idx + 1) > this.contents.length) { | ||
return text; | ||
} | ||
String result = text + contents[idx]; | ||
this.idx += 1; | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters