当前位置: 首页>>代码示例>>Golang>>正文


Golang clipboard.WriteAll函数代码示例

本文整理汇总了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")
}
开发者ID:ionDynamics,项目名称:statelessPassword,代码行数:28,代码来源:frontend.go

示例2: writeToClipboard

func writeToClipboard(buffer *bytes.Buffer) {
	clipboardOutput := buffer.String()
	if clipboardOutput != "" {
		clipboard.WriteAll(clipboardOutput)
		fmt.Printf("nw: wrote \"%s\" to clipboard\n", clipboardOutput)
	}
}
开发者ID:kodybrown,项目名称:numberwang,代码行数:7,代码来源:nw.go

示例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()
	}
}
开发者ID:schmich,项目名称:ward,代码行数:34,代码来源:add.go

示例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)
}
开发者ID:iopred,项目名称:bruxism,代码行数:7,代码来源:youtube.go

示例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
}
开发者ID:jostillmanns,项目名称:passdb,代码行数:27,代码来源:passdb.go

示例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
				}
			}()
		}
	}
}
开发者ID:amazedevil,项目名称:AutoUrlMinifier,代码行数:25,代码来源:main.go

示例7: Example

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

	// Output:
	// 日本語
}
开发者ID:maiavb1980,项目名称:clipboard,代码行数:8,代码来源:example_test.go

示例8: writeClipBoard

func writeClipBoard() {
	shortened := <-shortenChan
	err := clipboard.WriteAll(shortened)
	if err != nil {
		log.Fatal(err)
	}
	writerChan <- "wrote " + shortened + " to the clipboard\n"
}
开发者ID:Rakin05,项目名称:ClipShorter,代码行数:8,代码来源:ClipShorter.go

示例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)
}
开发者ID:hotchemi,项目名称:surl,代码行数:11,代码来源:main.go

示例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)
	}
}
开发者ID:tobischo,项目名称:kp2,代码行数:11,代码来源:gocopy.go

示例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

}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:12,代码来源:browsercode.go

示例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
}
开发者ID:Matsuyanagi,项目名称:nyagos,代码行数:12,代码来源:readline_keyfunc.go

示例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)
	}
}
开发者ID:eugenijm,项目名称:pm,代码行数:12,代码来源:commands.go

示例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()
	}
}
开发者ID:schmich,项目名称:ward,代码行数:52,代码来源:add.go

示例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)
	}
}
开发者ID:kindlychung,项目名称:stripibook,代码行数:13,代码来源:main.go


注:本文中的github.com/atotto/clipboard.WriteAll函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。