• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang clipboard.ReadAll函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/atotto/clipboard.ReadAll函数的典型用法代码示例。如果您正苦于以下问题:Golang ReadAll函数的具体用法?Golang ReadAll怎么用?Golang ReadAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ReadAll函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

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


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


示例3: clipboardInputNumber

func clipboardInputNumber(dev *at.Device, message string) {
	ticker := time.NewTicker(time.Millisecond * 100)
	go func() {
		previousPhoneNumber := ""
		for range ticker.C {
			if phoneNumber, err := clipboard.ReadAll(); err == nil {
				if phoneNumber, err = normalizePhoneNumber(phoneNumber); err == nil {
					if phoneNumber != previousPhoneNumber {
						sendSMS(dev, message, phoneNumber)
						previousPhoneNumber = phoneNumber
					}
				}
			}
		}
	}()

	scanner := bufio.NewScanner(os.Stdin)
	fmt.Print("Наберите \"выход\": ")
	for scanner.Scan() {
		text := scanner.Text()
		if isExitCommand(text) {
			break
		}
		fmt.Print("Наберите \"выход\" для прекращения работы.")
	}
	ticker.Stop()
}
开发者ID:yazver,项目名称:sendsms,代码行数:27,代码来源:sendsms.go


示例4: AddCommand

// AddCommand adds a Note
func AddCommand(c *cli.Context, i storage.Impl) (n storage.Note, err error) {
	nName, err := NoteName(c)
	if err != nil {
		return n, err
	}

	if exists := i.NoteExists(nName); exists == true {
		return n, fmt.Errorf("Note already exists")
	}

	n.Name = nName
	n.Temporary = c.Bool("t")

	// Only open editor if -p (read from clipboard) isnt set
	if c.IsSet("p") {
		nText, err := clipboard.ReadAll()
		if err != nil {
			return n, err
		}
		n.Text = nText
	} else {
		if err := writer.WriteNote(&n); err != nil {
			return n, err
		}
	}

	if err := i.SaveNote(&n); err != nil {
		return n, err
	}

	return n, nil
}
开发者ID:gummiboll,项目名称:forgetful,代码行数:33,代码来源:commands.go


示例5: main

func main() {
	usr, _ := user.Current()
	baseDir = fmt.Sprintf("%v/Pictures/webpic", usr.HomeDir)
	os.MkdirAll(baseDir, 0755)
	jsonFileAddr := fmt.Sprintf("%s/parser.json", baseDir)

	reloadParser(jsonFileAddr)

	var postUrl string
	var workerNum int
	var useDaemon bool

	rootCmd := &cobra.Command{
		Use:   "webpic",
		Short: "Download all the images in given post url",
		Run: func(cmd *cobra.Command, args []string) {
			if useDaemon {
				//Check clipboard
				var previousString string
				fmt.Println("Start watching clipboard.... (press ctrl+c to exit)")
				for {
					text, err := clipboard.ReadAll()
					if previousString != text {
						//Found something new in clipboard, check if it is URL.
						if err == nil && len(text) > 0 {
							urlInfo := urlRegex.FindStringSubmatch(text)
							if len(urlInfo) > 0 {
								go crawler(text, workerNum)
							}
						}
						previousString = text
					}

					time.Sleep(time.Second)
				}
			} else {
				if postUrl == "" {
					fmt.Println("Please use 'webpic -u URL'.")
					return
				}
				crawler(postUrl, workerNum)
			}
		},
	}
	rootCmd.Flags().StringVarP(&postUrl, "url", "u", "", "Url of post")
	rootCmd.Flags().IntVarP(&workerNum, "worker", "w", 25, "Number of workers")
	rootCmd.Flags().BoolVarP(&useDaemon, "daemon", "d", false, "Enable daemon mode to watch the clipboard.")

	updateCmd := &cobra.Command{
		Use:   "update",
		Short: "Download new parser from github and update local.",
		Run: func(cmd *cobra.Command, args []string) {
			updateParser(jsonFileAddr)
		},
	}

	rootCmd.AddCommand(updateCmd)
	rootCmd.Execute()
}
开发者ID:kkdai,项目名称:webpic,代码行数:59,代码来源:main.go


示例6: readClipboard

func readClipboard() string {
	text, err := clipboard.ReadAll()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	return text
}
开发者ID:hotchemi,项目名称:surl,代码行数:8,代码来源:main.go


示例7: main

func main() {
	text, err := clipboard.ReadAll()
	if err != nil {
		panic(err)
	}

	fmt.Print(text)
}
开发者ID:tobischo,项目名称:kp2,代码行数:8,代码来源:gopaste.go


示例8: Example

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

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


示例9: KeyFuncPaste

func KeyFuncPaste(this *Buffer) Result {
	text, err := clipboard.ReadAll()
	if err == nil {
		this.InsertAndRepaint(
			strings.Replace(
				strings.Replace(
					strings.Replace(text, "\n", " ", -1),
					"\r", "", -1),
				"\t", " ", -1))
	}
	return CONTINUE
}
开发者ID:Matsuyanagi,项目名称:nyagos,代码行数:12,代码来源:readline_keyfunc.go


示例10: copyThenClear

func copyThenClear(text string, d time.Duration) error {
	signals := make(chan os.Signal, 1)
	signal.Notify(signals, os.Interrupt, os.Kill)
	defer signal.Stop(signals)
	original, err := clipboard.ReadAll()
	if err != nil {
		return err
	}
	err = clipboard.WriteAll(text)
	if err != nil {
		return err
	}
	select {
	case <-signals:
	case <-time.After(d):
	}
	current, _ := clipboard.ReadAll()
	if current == text {
		return clipboard.WriteAll(original)
	}
	return nil
}
开发者ID:zennro,项目名称:oyster,代码行数:22,代码来源:main.go


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


示例12: main

func main() {
	text, err := clipboard.ReadAll()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	re := regexp.MustCompile(`\r?\n`)
	line := re.ReplaceAllString(text, "")

	if err := clipboard.WriteAll(line); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	fmt.Print(line)
	os.Exit(0)
}
开发者ID:kuked,项目名称:straighten,代码行数:18,代码来源:main.go


示例13: getClipboard

func getClipboard() (string, error) {
	return clipboard.ReadAll()
}
开发者ID:gbbr,项目名称:textmate,代码行数:3,代码来源:editor.go


示例14: ProcessEvent

/*
ProcessEvent processes all events come from the control parent. If a control
processes an event it should return true. If the method returns false it means
that the control do not want or cannot process the event and the caller sends
the event to the control parent
*/
func (e *EditField) ProcessEvent(event Event) bool {
	if !e.Active() || !e.Enabled() {
		return false
	}

	if event.Type == EventActivate && event.X == 0 {
		term.HideCursor()
	}

	if event.Type == EventKey && event.Key != term.KeyTab {
		if e.onKeyPress != nil {
			res := e.onKeyPress(event.Key)
			if res {
				return true
			}
		}

		switch event.Key {
		case term.KeyEnter:
			return false
		case term.KeySpace:
			e.insertRune(' ')
			return true
		case term.KeyBackspace:
			e.backspace()
			return true
		case term.KeyDelete:
			e.del()
			return true
		case term.KeyArrowLeft:
			e.charLeft()
			return true
		case term.KeyHome:
			e.home()
			return true
		case term.KeyEnd:
			e.end()
			return true
		case term.KeyCtrlR:
			if !e.readonly {
				e.Clear()
			}
			return true
		case term.KeyArrowRight:
			e.charRight()
			return true
		case term.KeyCtrlC:
			clipboard.WriteAll(e.Title())
			return true
		case term.KeyCtrlV:
			if !e.readonly {
				s, _ := clipboard.ReadAll()
				e.SetTitle(s)
				e.end()
			}
			return true
		default:
			if event.Ch != 0 {
				e.insertRune(event.Ch)
				return true
			}
		}
		return false
	}

	return false
}
开发者ID:VladimirMarkelov,项目名称:clui,代码行数:73,代码来源:edit.go


示例15: readClipBoard

func readClipBoard() {
	clip, _ := clipboard.ReadAll()
	if isUrl(clip) && len(clip) > 50 {
		readerChan <- clip
	}
}
开发者ID:Rakin05,项目名称:ClipShorter,代码行数:6,代码来源:ClipShorter.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang clipboard.WriteAll函数代码示例发布时间:2022-05-24
下一篇:
Golang web.Context类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap