本文整理汇总了Golang中github.com/atotto/clipboard.WriteAll函数的典型用法代码示例。如果您正苦于以下问题:Golang WriteAll函数的具体用法?Golang WriteAll怎么用?Golang WriteAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WriteAll函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: returnPw
func returnPw(pwch chan string) {
var pwd string
select {
case pw := <-pwch:
pwd = pw
case <-time.After(750 * time.Millisecond):
say("Generating...")
pwd = <-pwch
}
if *noTerminal {
fmt.Print(pwd)
return
}
before, err := clipboard.ReadAll()
clipboard.WriteAll(pwd)
say("\nPassword copied to clipboard! ")
time.Sleep(5 * time.Second)
say("Cleaning clipboard in 5 seconds...")
time.Sleep(5 * time.Second)
if err != nil {
clipboard.WriteAll("")
} else {
clipboard.WriteAll(before)
}
say("\n...again? or CTRL+C\n")
}
示例2: writeToClipboard
func writeToClipboard(buffer *bytes.Buffer) {
clipboardOutput := buffer.String()
if clipboardOutput != "" {
clipboard.WriteAll(clipboardOutput)
fmt.Printf("nw: wrote \"%s\" to clipboard\n", clipboardOutput)
}
}
示例3: runAdd
func (app *App) runAdd(login, realm, note string, copyPassword bool) {
db := app.openStore()
defer db.Close()
if login == "" {
login = readInput("Login: ")
}
password := readPasswordConfirm("Password")
if realm == "" {
realm = readInput("Realm: ")
}
if note == "" {
note = readInput("Note: ")
}
db.AddCredential(&store.Credential{
Login: login,
Password: password,
Realm: realm,
Note: note,
})
printSuccess("Credential added. ")
if copyPassword {
clipboard.WriteAll(password)
fmt.Println("Password copied to the clipboard.")
} else {
fmt.Println()
}
}
示例4: generateOauthURLAndExit
func (yt *YouTube) generateOauthURLAndExit() {
// Redirect user to Google's consent page to ask for permission
// for the scopes specified above.
url := yt.config.AuthCodeURL("state", oauth2.AccessTypeOffline, oauth2.ApprovalForce)
clipboard.WriteAll(url)
log.Fatalln("Visit the following URL to generate an auth code, then rerun with -auth=<code> (It has also been copied to your clipboard):\n%s", url)
}
示例5: add
func add(name string, password []byte) error {
clipboard.WriteAll(string(password))
p := Password{}
p.Salt = randBytes(8)
key = pbkdf2.Key(key, p.Salt, 4096, 32, sha1.New)
session, err := aes.NewCipher(key)
if err != nil {
return err
}
password = pad(password)
pass_ciphered := make([]byte, aes.BlockSize+len(password))
iv := pass_ciphered[:aes.BlockSize]
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
return err
}
mode := cipher.NewCBCEncrypter(session, iv)
mode.CryptBlocks(pass_ciphered[aes.BlockSize:], password)
p.Pass = pass_ciphered
logins[name] = p
return nil
}
示例6: processClipboard
func processClipboard() {
val, _ := clipboard.ReadAll()
if lastClipboardValue != val {
lastClipboardValue = val
found := false
for _, urlPattern := range urls {
m, _ := regexp.MatchString(
"\\A"+strings.Replace(urlPattern, "*", "(.*)", -1)+"\\z",
val)
if m {
found = true
break
}
}
if found {
go func() {
min := minify(val)
if len(min) > 0 {
clipboard.WriteAll(min)
lastClipboardValue = min
}
}()
}
}
}
示例7: Example
func Example() {
clipboard.WriteAll("日本語")
text, _ := clipboard.ReadAll()
fmt.Println(text)
// Output:
// 日本語
}
示例8: writeClipBoard
func writeClipBoard() {
shortened := <-shortenChan
err := clipboard.WriteAll(shortened)
if err != nil {
log.Fatal(err)
}
writerChan <- "wrote " + shortened + " to the clipboard\n"
}
示例9: action
func action(context *cli.Context) {
text := readClipboard()
res := httpGet(text)
json := unmarshal(res)
if json.Errormessage != "" {
fmt.Fprintln(os.Stderr, json.Errormessage)
os.Exit(1)
}
clipboard.WriteAll(json.Shorturl)
fmt.Println("Write the value to clipboard: " + json.Shorturl)
}
示例10: main
func main() {
out, err := ioutil.ReadAll(os.Stdin)
if err != nil {
panic(err)
}
if err := clipboard.WriteAll(string(out)); err != nil {
panic(err)
}
}
示例11: CopyToClipboard
func (b *BrowserCode) CopyToClipboard() error {
encoded, err := b.Encode()
if err != nil {
return err
}
err = clipboard.WriteAll(encoded)
if err != nil {
return err
}
return nil
}
示例12: KeyFuncClearBefore
func KeyFuncClearBefore(this *Buffer) Result {
var killbuf bytes.Buffer
for i := 0; i < this.Cursor; i++ {
killbuf.WriteRune(this.Buffer[i])
}
clipboard.WriteAll(killbuf.String())
keta := this.Delete(0, this.Cursor)
Backspace(keta)
this.Cursor = 0
this.Repaint(0, keta)
return CONTINUE
}
示例13: copyPass
func copyPass(siteName string) {
decrypted, _ := getDecryptedData()
value, ok := decrypted[siteName]
if ok {
err := clipboard.WriteAll(value)
check(err)
fmt.Println("The password has been copied to the clipboard")
} else {
fmt.Println("Not found")
os.Exit(1)
}
}
示例14: runGen
func (app *App) runGen(login, realm, note string, copyPassword bool, generator *passgen.Generator) {
passwordChan := make(chan *passwordResult)
go func() {
password, err := generator.Generate()
passwordChan <- &passwordResult{password: password, err: err}
}()
db := app.openStore()
defer db.Close()
if login == "" {
login = readInput("Login: ")
}
if realm == "" {
realm = readInput("Realm: ")
}
if note == "" {
note = readInput("Note: ")
}
var result *passwordResult
select {
case result = <-passwordChan:
fmt.Println("Password: (generated)")
default:
fmt.Println("Password: (generating)")
result = <-passwordChan
}
if result.err != nil {
printError("%s\n", result.err)
return
}
db.AddCredential(&store.Credential{
Login: login,
Password: result.password,
Realm: realm,
Note: note,
})
printSuccess("Credential added. ")
if copyPassword {
clipboard.WriteAll(result.password)
fmt.Println("Generated password copied to the clipboard.")
} else {
fmt.Println()
}
}
示例15: main
func main() {
r := regexp.MustCompile(`^“([^“”]+)”[^“”]+Excerpt From:[^“”]+“[^“”]+” iBooks.`)
for true {
clipContent, _ := clipboard.ReadAll()
matchedGroups := r.FindStringSubmatch(clipContent)
if len(matchedGroups) > 0 {
stripped := matchedGroups[1]
clipboard.WriteAll(stripped)
fmt.Println("\n\n" + stripped)
}
time.Sleep(50)
}
}