aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/zyedidia
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/zyedidia')
-rw-r--r--vendor/github.com/zyedidia/clipboard/.travis.yml18
-rw-r--r--vendor/github.com/zyedidia/clipboard/LICENSE27
-rw-r--r--vendor/github.com/zyedidia/clipboard/README.md50
-rw-r--r--vendor/github.com/zyedidia/clipboard/clipboard.go22
-rw-r--r--vendor/github.com/zyedidia/clipboard/clipboard_darwin.go58
-rw-r--r--vendor/github.com/zyedidia/clipboard/clipboard_unix.go105
-rw-r--r--vendor/github.com/zyedidia/clipboard/clipboard_windows.go107
-rw-r--r--vendor/github.com/zyedidia/glob/LICENSE22
-rw-r--r--vendor/github.com/zyedidia/glob/README.md28
-rw-r--r--vendor/github.com/zyedidia/glob/glob.go94
10 files changed, 531 insertions, 0 deletions
diff --git a/vendor/github.com/zyedidia/clipboard/.travis.yml b/vendor/github.com/zyedidia/clipboard/.travis.yml
new file mode 100644
index 0000000..f339196
--- /dev/null
+++ b/vendor/github.com/zyedidia/clipboard/.travis.yml
@@ -0,0 +1,18 @@
+language: go
+
+go:
+ - go1.2.2
+ - go1.3.3
+ - go1.4.3
+ - go1.5.3
+ - go1.6
+
+before_install:
+ - export DISPLAY=:99.0
+ - sh -e /etc/init.d/xvfb start
+
+script:
+ - sudo apt-get install xsel
+ - go test -v .
+ - sudo apt-get install xclip
+ - go test -v .
diff --git a/vendor/github.com/zyedidia/clipboard/LICENSE b/vendor/github.com/zyedidia/clipboard/LICENSE
new file mode 100644
index 0000000..dee3257
--- /dev/null
+++ b/vendor/github.com/zyedidia/clipboard/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2013 Ato Araki. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of @atotto. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/github.com/zyedidia/clipboard/README.md b/vendor/github.com/zyedidia/clipboard/README.md
new file mode 100644
index 0000000..6e2d15f
--- /dev/null
+++ b/vendor/github.com/zyedidia/clipboard/README.md
@@ -0,0 +1,50 @@
+[![Build Status](https://travis-ci.org/atotto/clipboard.svg?branch=master)](https://travis-ci.org/atotto/clipboard) [![Build Status](https://drone.io/github.com/atotto/clipboard/status.png)](https://drone.io/github.com/atotto/clipboard/latest)
+
+[![GoDoc](https://godoc.org/github.com/atotto/clipboard?status.svg)](http://godoc.org/github.com/atotto/clipboard)
+
+# Clipboard for Go
+
+Provide copying and pasting to the Clipboard for Go.
+
+Download shell commands at https://drone.io/github.com/atotto/clipboard/files
+
+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:
+
+* http://godoc.org/github.com/atotto/clipboard
+
+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
+
+
+
diff --git a/vendor/github.com/zyedidia/clipboard/clipboard.go b/vendor/github.com/zyedidia/clipboard/clipboard.go
new file mode 100644
index 0000000..49e590d
--- /dev/null
+++ b/vendor/github.com/zyedidia/clipboard/clipboard.go
@@ -0,0 +1,22 @@
+// Copyright 2013 @atotto. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package clipboard read/write on clipboard
+package clipboard
+
+import ()
+
+// ReadAll read string from clipboard
+func ReadAll(register string) (string, error) {
+ return readAll(register)
+}
+
+// WriteAll write string to clipboard
+func WriteAll(text string, register string) error {
+ return writeAll(text, register)
+}
+
+// Unsupported might be set true during clipboard init, to help callers decide
+// whether or not to offer clipboard options.
+var Unsupported bool
diff --git a/vendor/github.com/zyedidia/clipboard/clipboard_darwin.go b/vendor/github.com/zyedidia/clipboard/clipboard_darwin.go
new file mode 100644
index 0000000..66662cd
--- /dev/null
+++ b/vendor/github.com/zyedidia/clipboard/clipboard_darwin.go
@@ -0,0 +1,58 @@
+// Copyright 2013 @atotto. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin
+
+package clipboard
+
+import (
+ "os/exec"
+)
+
+var (
+ pasteCmdArgs = "pbpaste"
+ copyCmdArgs = "pbcopy"
+)
+
+func getPasteCommand() *exec.Cmd {
+ return exec.Command(pasteCmdArgs)
+}
+
+func getCopyCommand() *exec.Cmd {
+ return exec.Command(copyCmdArgs)
+}
+
+func readAll(register string) (string, error) {
+ if register != "clipboard" {
+ return "", nil
+ }
+ pasteCmd := getPasteCommand()
+ out, err := pasteCmd.Output()
+ if err != nil {
+ return "", err
+ }
+ return string(out), nil
+}
+
+func writeAll(text string, register string) error {
+ if register != "clipboard" {
+ return nil
+ }
+ copyCmd := getCopyCommand()
+ in, err := copyCmd.StdinPipe()
+ if err != nil {
+ return err
+ }
+
+ if err := copyCmd.Start(); err != nil {
+ return err
+ }
+ if _, err := in.Write([]byte(text)); err != nil {
+ return err
+ }
+ if err := in.Close(); err != nil {
+ return err
+ }
+ return copyCmd.Wait()
+}
diff --git a/vendor/github.com/zyedidia/clipboard/clipboard_unix.go b/vendor/github.com/zyedidia/clipboard/clipboard_unix.go
new file mode 100644
index 0000000..87d0251
--- /dev/null
+++ b/vendor/github.com/zyedidia/clipboard/clipboard_unix.go
@@ -0,0 +1,105 @@
+// Copyright 2013 @atotto. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build freebsd linux netbsd openbsd solaris
+
+package clipboard
+
+import "os/exec"
+
+const (
+ xsel = "xsel"
+ xclip = "xclip"
+)
+
+var (
+ internalClipboards map[string]string
+)
+
+func init() {
+ if _, err := exec.LookPath(xclip); err == nil {
+ if err := exec.Command("xclip", "-o").Run(); err == nil {
+ return
+ }
+ }
+ if _, err := exec.LookPath(xsel); err == nil {
+ if err := exec.Command("xsel").Run(); err == nil {
+ return
+ }
+ }
+
+ internalClipboards = make(map[string]string)
+ Unsupported = true
+}
+
+func copyCommand(register string) []string {
+ if _, err := exec.LookPath(xclip); err == nil {
+ return []string{xclip, "-in", "-selection", register}
+ }
+
+ if _, err := exec.LookPath(xsel); err == nil {
+ return []string{xsel, "--input", "--" + register}
+ }
+
+ return []string{}
+}
+func pasteCommand(register string) []string {
+ if _, err := exec.LookPath(xclip); err == nil {
+ return []string{xclip, "-out", "-selection", register}
+ }
+
+ if _, err := exec.LookPath(xsel); err == nil {
+ return []string{xsel, "--output", "--" + register}
+ }
+
+ return []string{}
+}
+
+func getPasteCommand(register string) *exec.Cmd {
+ pasteCmdArgs := pasteCommand(register)
+ return exec.Command(pasteCmdArgs[0], pasteCmdArgs[1:]...)
+}
+
+func getCopyCommand(register string) *exec.Cmd {
+ copyCmdArgs := copyCommand(register)
+ return exec.Command(copyCmdArgs[0], copyCmdArgs[1:]...)
+}
+
+func readAll(register string) (string, error) {
+ if Unsupported {
+ if text, ok := internalClipboards[register]; ok {
+ return text, nil
+ }
+ return "", nil
+ }
+ pasteCmd := getPasteCommand(register)
+ out, err := pasteCmd.Output()
+ if err != nil {
+ return "", err
+ }
+ return string(out), nil
+}
+
+func writeAll(text string, register string) error {
+ if Unsupported {
+ internalClipboards[register] = text
+ return nil
+ }
+ copyCmd := getCopyCommand(register)
+ in, err := copyCmd.StdinPipe()
+ if err != nil {
+ return err
+ }
+
+ if err := copyCmd.Start(); err != nil {
+ return err
+ }
+ if _, err := in.Write([]byte(text)); err != nil {
+ return err
+ }
+ if err := in.Close(); err != nil {
+ return err
+ }
+ return copyCmd.Wait()
+}
diff --git a/vendor/github.com/zyedidia/clipboard/clipboard_windows.go b/vendor/github.com/zyedidia/clipboard/clipboard_windows.go
new file mode 100644
index 0000000..2c1fecf
--- /dev/null
+++ b/vendor/github.com/zyedidia/clipboard/clipboard_windows.go
@@ -0,0 +1,107 @@
+// Copyright 2013 @atotto. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build windows
+
+package clipboard
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+const (
+ cfUnicodetext = 13
+ gmemFixed = 0x0000
+)
+
+var (
+ user32 = syscall.MustLoadDLL("user32")
+ openClipboard = user32.MustFindProc("OpenClipboard")
+ closeClipboard = user32.MustFindProc("CloseClipboard")
+ emptyClipboard = user32.MustFindProc("EmptyClipboard")
+ getClipboardData = user32.MustFindProc("GetClipboardData")
+ setClipboardData = user32.MustFindProc("SetClipboardData")
+
+ kernel32 = syscall.NewLazyDLL("kernel32")
+ globalAlloc = kernel32.NewProc("GlobalAlloc")
+ globalFree = kernel32.NewProc("GlobalFree")
+ globalLock = kernel32.NewProc("GlobalLock")
+ globalUnlock = kernel32.NewProc("GlobalUnlock")
+ lstrcpy = kernel32.NewProc("lstrcpyW")
+)
+
+func readAll(register string) (string, error) {
+ if register != "clipboard" {
+ return "", nil
+ }
+ r, _, err := openClipboard.Call(0)
+ if r == 0 {
+ return "", err
+ }
+ defer closeClipboard.Call()
+
+ h, _, err := getClipboardData.Call(cfUnicodetext)
+ if r == 0 {
+ return "", err
+ }
+
+ l, _, err := globalLock.Call(h)
+ if l == 0 {
+ return "", err
+ }
+
+ text := syscall.UTF16ToString((*[1 << 20]uint16)(unsafe.Pointer(l))[:])
+
+ r, _, err = globalUnlock.Call(h)
+ if r == 0 {
+ return "", err
+ }
+
+ return text, nil
+}
+
+func writeAll(text string, register string) error {
+ if register != "clipboard" {
+ return nil
+ }
+ r, _, err := openClipboard.Call(0)
+ if r == 0 {
+ return err
+ }
+ defer closeClipboard.Call()
+
+ r, _, err = emptyClipboard.Call(0)
+ if r == 0 {
+ return err
+ }
+
+ data := syscall.StringToUTF16(text)
+
+ h, _, err := globalAlloc.Call(gmemFixed, uintptr(len(data)*int(unsafe.Sizeof(data[0]))))
+ if h == 0 {
+ return err
+ }
+
+ l, _, err := globalLock.Call(h)
+ if l == 0 {
+ return err
+ }
+
+ r, _, err = lstrcpy.Call(l, uintptr(unsafe.Pointer(&data[0])))
+ if r == 0 {
+ return err
+ }
+
+ r, _, err = globalUnlock.Call(h)
+ if r == 0 {
+ return err
+ }
+
+ r, _, err = setClipboardData.Call(cfUnicodetext, h)
+ if r == 0 {
+ return err
+ }
+ return nil
+}
diff --git a/vendor/github.com/zyedidia/glob/LICENSE b/vendor/github.com/zyedidia/glob/LICENSE
new file mode 100644
index 0000000..cb00d95
--- /dev/null
+++ b/vendor/github.com/zyedidia/glob/LICENSE
@@ -0,0 +1,22 @@
+Glob is licensed under the MIT "Expat" License:
+
+Copyright (c) 2016: Zachary Yedidia.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/zyedidia/glob/README.md b/vendor/github.com/zyedidia/glob/README.md
new file mode 100644
index 0000000..e2e6c64
--- /dev/null
+++ b/vendor/github.com/zyedidia/glob/README.md
@@ -0,0 +1,28 @@
+# String globbing in Go
+
+[![GoDoc](https://godoc.org/github.com/zyedidia/glob?status.svg)](http://godoc.org/github.com/zyedidia/glob)
+
+This package adds support for globs in Go.
+
+It simply converts glob expressions to regexps. I try to follow the standard defined [here](http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_13).
+
+# Example
+
+```go
+package main
+
+import "github.com/zyedidia/glob"
+
+func main() {
+ glob, err := glob.Compile("{*.go,*.c}")
+ if err != nil {
+ // Error
+ }
+
+ glob.Match([]byte("test.c")) // true
+ glob.Match([]byte("hello.go")) // true
+ glob.Match([]byte("test.d")) // false
+}
+```
+
+You can call all the same functions on a glob that you can call on a regexp.
diff --git a/vendor/github.com/zyedidia/glob/glob.go b/vendor/github.com/zyedidia/glob/glob.go
new file mode 100644
index 0000000..10c9b5d
--- /dev/null
+++ b/vendor/github.com/zyedidia/glob/glob.go
@@ -0,0 +1,94 @@
+// Package glob provides objects for matching strings with globs
+package glob
+
+import "regexp"
+
+// Glob is a wrapper of *regexp.Regexp.
+// It should contain a glob expression compiled into a regular expression.
+type Glob struct {
+ *regexp.Regexp
+}
+
+// Compile a takes a glob expression as a string and transforms it
+// into a *Glob object (which is really just a regular expression)
+// Compile also returns a possible error.
+func Compile(pattern string) (*Glob, error) {
+ r, err := globToRegex(pattern)
+ return &Glob{r}, err
+}
+
+func globToRegex(glob string) (*regexp.Regexp, error) {
+ regex := ""
+ inGroup := 0
+ inClass := 0
+ firstIndexInClass := -1
+ arr := []byte(glob)
+
+ for i := 0; i < len(arr); i++ {
+ ch := arr[i]
+
+ switch ch {
+ case '\\':
+ i++
+ if i >= len(arr) {
+ regex += "\\"
+ } else {
+ next := arr[i]
+ switch next {
+ case ',':
+ // Nothing
+ case 'Q', 'E':
+ regex += "\\\\"
+ default:
+ regex += "\\"
+ }
+ regex += string(next)
+ }
+ case '*':
+ if inClass == 0 {
+ regex += ".*"
+ } else {
+ regex += "*"
+ }
+ case '?':
+ if inClass == 0 {
+ regex += "."
+ } else {
+ regex += "?"
+ }
+ case '[':
+ inClass++
+ firstIndexInClass = i + 1
+ regex += "["
+ case ']':
+ inClass--
+ regex += "]"
+ case '.', '(', ')', '+', '|', '^', '$', '@', '%':
+ if inClass == 0 || (firstIndexInClass == i && ch == '^') {
+ regex += "\\"
+ }
+ regex += string(ch)
+ case '!':
+ if firstIndexInClass == i {
+ regex += "^"
+ } else {
+ regex += "!"
+ }
+ case '{':
+ inGroup++
+ regex += "("
+ case '}':
+ inGroup--
+ regex += ")"
+ case ',':
+ if inGroup > 0 {
+ regex += "|"
+ } else {
+ regex += ","
+ }
+ default:
+ regex += string(ch)
+ }
+ }
+ return regexp.Compile("^" + regex + "$")
+}