clipboard

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2018 License: BSD-3-Clause Imports: 4 Imported by: 1

README

Build Status

GoDoc

Clipboard for Go

Provide copying and pasting to the Clipboard for Go.

Build:

$ go get github.com/atotto/clipboard

Platforms:

  • OSX
  • Windows 7 (probably work on other Windows)
  • Linux, Unix (requires 'xclip' or 'xsel' command to be installed)

Document:

Notes:

  • Text string only
  • UTF-8 text encoding only (no conversion)

TODO:

  • Clipboard watcher(?)

Commands:

paste shell command:

$ go get github.com/atotto/clipboard/cmd/gopaste
$ # example:
$ gopaste > document.txt

copy shell command:

$ go get github.com/atotto/clipboard/cmd/gocopy
$ # example:
$ cat document.txt | gocopy

Documentation

Overview

Package clipboard read/write on clipboard

Example
package main

import (
	"fmt"

	"github.com/atotto/clipboard"
)

func main() {
	clipboard.WriteAll("日本語")
	text, _ := clipboard.ReadAll()
	fmt.Println(text)

}
Output:

日本語

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Primary bool
)
View Source
var Unsupported bool

Unsupported might be set true during clipboard init, to help callers decide whether or not to offer clipboard options.

Functions

func ReadAll

func ReadAll() (string, error)

ReadAll read string from clipboard

func Watch added in v0.1.3

func Watch(interval time.Duration) (<-chan string, context.CancelFunc)

Watch returns a channel for new clipboard content whenever it changes. It will return current clipboard content if not empty when initialized. Interval is the time between clipboard checks. Take into account that clickboard checks need a few milliseconds as well.

func WriteAll

func WriteAll(text string) error

WriteAll write string to clipboard

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL