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

Golang curses.Endwin函数代码示例

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

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



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

示例1: executeCommand

func executeCommand(template string, current string) {
	command := strings.Replace(template, "{}", fmt.Sprintf("%q", current), -1)
	cmd := exec.Command("sh", "-c", command)
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	C.Endwin()
	cmd.Run()
	C.Refresh()
}
开发者ID:eshenhu,项目名称:fzf,代码行数:10,代码来源:terminal.go


示例2: executeCommand

func (t *Terminal) executeCommand(template string, items []*Item) {
	command := replacePlaceholder(template, t.ansi, t.delimiter, string(t.input), items)
	cmd := util.ExecCommand(command)
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	C.Endwin()
	cmd.Run()
	t.refresh()
}
开发者ID:infokiller,项目名称:fzf,代码行数:10,代码来源:terminal.go


示例3: executeCommand

func executeCommand(template string, replacement string) {
	command := strings.Replace(template, "{}", replacement, -1)
	cmd := util.ExecCommand(command)
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	C.Endwin()
	cmd.Run()
	C.Refresh()
}
开发者ID:wrideout,项目名称:dotzsh,代码行数:10,代码来源:terminal.go


示例4: executeCommand

func executeCommand(template string, replacement string) {
	command := strings.Replace(template, "{}", replacement, -1)
	shell := os.Getenv("SHELL")
	if len(shell) == 0 {
		shell = "sh"
	}
	cmd := exec.Command(shell, "-c", command)
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	C.Endwin()
	cmd.Run()
	C.Refresh()
}
开发者ID:imjerrybao,项目名称:fzf,代码行数:14,代码来源:terminal.go


示例5: Loop

// Loop is called to start Terminal I/O
func (t *Terminal) Loop() {
	<-t.startChan
	{ // Late initialization
		intChan := make(chan os.Signal, 1)
		signal.Notify(intChan, os.Interrupt, os.Kill)
		go func() {
			<-intChan
			t.reqBox.Set(reqQuit, nil)
		}()

		resizeChan := make(chan os.Signal, 1)
		signal.Notify(resizeChan, syscall.SIGWINCH)
		go func() {
			for {
				<-resizeChan
				t.reqBox.Set(reqRedraw, nil)
			}
		}()

		t.mutex.Lock()
		t.initFunc()
		t.calculateMargins()
		t.printPrompt()
		t.placeCursor()
		C.Refresh()
		t.printInfo()
		t.printHeader()
		t.mutex.Unlock()
		go func() {
			timer := time.NewTimer(initialDelay)
			<-timer.C
			t.reqBox.Set(reqRefresh, nil)
		}()

		// Keep the spinner spinning
		go func() {
			for {
				t.mutex.Lock()
				reading := t.reading
				t.mutex.Unlock()
				if !reading {
					break
				}
				time.Sleep(spinnerDuration)
				t.reqBox.Set(reqInfo, nil)
			}
		}()
	}

	exit := func(code int) {
		if code <= exitNoMatch && t.history != nil {
			t.history.append(string(t.input))
		}
		os.Exit(code)
	}

	go func() {
		for {
			t.reqBox.Wait(func(events *util.Events) {
				defer events.Clear()
				t.mutex.Lock()
				for req := range *events {
					switch req {
					case reqPrompt:
						t.printPrompt()
						if t.inlineInfo {
							t.printInfo()
						}
					case reqInfo:
						t.printInfo()
					case reqList:
						t.printList()
					case reqHeader:
						t.printHeader()
					case reqRefresh:
						t.suppress = false
					case reqRedraw:
						C.Clear()
						C.Endwin()
						C.Refresh()
						t.printAll()
					case reqClose:
						C.Close()
						if t.output() {
							exit(exitOk)
						}
						exit(exitNoMatch)
					case reqQuit:
						C.Close()
						exit(exitInterrupt)
					}
				}
				t.placeCursor()
				t.mutex.Unlock()
			})
			t.refresh()
		}
	}()

//.........这里部分代码省略.........
开发者ID:eshenhu,项目名称:fzf,代码行数:101,代码来源:terminal.go


示例6: Loop

// Loop is called to start Terminal I/O
func (t *Terminal) Loop() {
	<-t.startChan
	{ // Late initialization
		t.mutex.Lock()
		t.initFunc()
		t.printPrompt()
		t.placeCursor()
		C.Refresh()
		t.printInfo()
		t.mutex.Unlock()
		go func() {
			timer := time.NewTimer(initialDelay)
			<-timer.C
			t.reqBox.Set(reqRefresh, nil)
		}()

		resizeChan := make(chan os.Signal, 1)
		signal.Notify(resizeChan, syscall.SIGWINCH)
		go func() {
			for {
				<-resizeChan
				t.reqBox.Set(reqRedraw, nil)
			}
		}()
	}

	go func() {
		for {
			t.reqBox.Wait(func(events *util.Events) {
				defer events.Clear()
				t.mutex.Lock()
				for req := range *events {
					switch req {
					case reqPrompt:
						t.printPrompt()
					case reqInfo:
						t.printInfo()
					case reqList:
						t.printList()
					case reqRefresh:
						t.suppress = false
					case reqRedraw:
						C.Clear()
						C.Endwin()
						C.Refresh()
						t.printAll()
					case reqClose:
						C.Close()
						t.output()
						os.Exit(0)
					case reqQuit:
						C.Close()
						os.Exit(1)
					}
				}
				t.placeCursor()
				t.mutex.Unlock()
			})
			t.refresh()
		}
	}()

	looping := true
	for looping {
		event := C.GetChar()

		t.mutex.Lock()
		previousInput := t.input
		events := []util.EventType{reqPrompt}
		req := func(evts ...util.EventType) {
			for _, event := range evts {
				events = append(events, event)
				if event == reqClose || event == reqQuit {
					looping = false
				}
			}
		}
		toggle := func() {
			if t.cy < t.merger.Length() {
				item := t.merger.Get(t.cy)
				if _, found := t.selected[item.text]; !found {
					var strptr *string
					if item.origText != nil {
						strptr = item.origText
					} else {
						strptr = item.text
					}
					t.selected[item.text] = selectedItem{time.Now(), strptr}
				} else {
					delete(t.selected, item.text)
				}
				req(reqInfo)
			}
		}
		switch event.Type {
		case C.Invalid:
			t.mutex.Unlock()
			continue
		case C.CtrlA:
//.........这里部分代码省略.........
开发者ID:zennro,项目名称:fzf,代码行数:101,代码来源:terminal.go


示例7: Loop


//.........这里部分代码省略.........
					case reqPrompt:
						t.printPrompt()
						if t.inlineInfo {
							t.printInfo()
						}
					case reqInfo:
						t.printInfo()
					case reqList:
						t.printList()
						cnt := t.merger.Length()
						var currentFocus *Item
						if cnt > 0 && cnt > t.cy {
							currentFocus = t.currentItem()
						} else {
							currentFocus = nil
						}
						if currentFocus != focused {
							focused = currentFocus
							if t.isPreviewEnabled() {
								t.previewBox.Set(reqPreviewEnqueue, focused)
							}
						}
					case reqJump:
						if t.merger.Length() == 0 {
							t.jumping = jumpDisabled
						}
						t.printList()
					case reqHeader:
						t.printHeader()
					case reqRefresh:
						t.suppress = false
					case reqRedraw:
						C.Clear()
						C.Endwin()
						C.Refresh()
						t.printAll()
					case reqClose:
						C.Close()
						if t.output() {
							exit(exitOk)
						}
						exit(exitNoMatch)
					case reqPreviewDisplay:
						t.previewer.text = value.(string)
						t.previewer.lines = strings.Count(t.previewer.text, "\n")
						t.previewer.offset = 0
						t.printPreview()
					case reqPreviewRefresh:
						t.printPreview()
					case reqPrintQuery:
						C.Close()
						t.printer(string(t.input))
						exit(exitOk)
					case reqQuit:
						C.Close()
						exit(exitInterrupt)
					}
				}
				t.placeCursor()
				t.mutex.Unlock()
			})
			t.refresh()
		}
	}()

	looping := true
开发者ID:infokiller,项目名称:fzf,代码行数:67,代码来源:terminal.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang curses.MaxX函数代码示例发布时间:2022-05-23
下一篇:
Golang curses.CPrint函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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