本文整理汇总了Golang中github.com/rthornton128/goncurses.End函数的典型用法代码示例。如果您正苦于以下问题:Golang End函数的具体用法?Golang End怎么用?Golang End使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了End函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
defineFlags()
if SHOW_VERSION {
fmt.Println("kvmtop version " + VERSION)
return
}
if !OUT_BATCH {
screenx, err := goncurses.Init()
if err != nil {
log.Fatal("init", err)
}
screen = screenx
defer goncurses.End()
}
initialize()
for n := -1; RUNCOUNT == -1 || n < RUNCOUNT; n++ {
start := time.Now()
measureVirtualMachines(n)
nextRun := start.Add(time.Duration(FREQUENCY) * time.Second)
updateVirtualMachineLists()
time.Sleep(nextRun.Sub(time.Now()))
}
}
开发者ID:cha87de,项目名称:kvmtop,代码行数:25,代码来源:kvmtop.go
示例2: main
func main() {
stdscr, err := goncurses.Init()
if err != nil {
log.Fatal("init", err)
}
defer goncurses.End()
goncurses.Raw(true) // turn on raw "uncooked" input
goncurses.Echo(false) // turn echoing of typed characters off
goncurses.Cursor(0) // hide cursor
stdscr.Keypad(true) // allow keypad input
stdscr.Print("Press a key...")
stdscr.Refresh()
if ch := stdscr.GetChar(); ch == goncurses.KEY_F2 {
stdscr.Print("The F2 key was pressed.")
} else {
stdscr.Print("The key pressed is: ")
stdscr.AttrOn(goncurses.A_BOLD)
stdscr.AddChar(goncurses.Char(ch))
stdscr.AttrOff(goncurses.A_BOLD)
}
stdscr.Refresh()
stdscr.GetChar()
}
开发者ID:trotha01,项目名称:goncurses,代码行数:26,代码来源:init.go
示例3: main
func main() {
stdscr, err := gc.Init()
if err != nil {
log.Fatal("init:", err)
}
defer gc.End()
msg := "Enter a string: "
row, col := stdscr.MaxYX()
row, col = (row/2)-1, (col-len(msg))/2
stdscr.MovePrint(row, col, msg)
/* GetString will only retieve the specified number of characters. Any
attempts by the user to enter more characters will elicit an audiable
beep */
var str string
str, err = stdscr.GetString(10)
if err != nil {
stdscr.MovePrint(row+1, col, "GetString Error:", err)
} else {
stdscr.MovePrintf(row+1, col, "You entered: %s", str)
}
stdscr.Refresh()
stdscr.GetChar()
}
开发者ID:trotha01,项目名称:goncurses,代码行数:26,代码来源:getstr.go
示例4: main
func main() {
_, err := gc.Init()
if err != nil {
log.Fatal(err)
}
defer gc.End()
// create a new pad of 50 rows and 200 columns...
var pad *gc.Pad
pad, err = gc.NewPad(50, 200)
if err != nil {
log.Fatal(err)
}
// ...and fill it with some characters
for x := 0; x < 50; x++ {
pad.MovePrint(x, x, "This is a pad.")
}
// Refresh the pad to show only a portion of the pad. Understanding
// what these coordinates mean can be a bit tricky. The first two
// coordinates are the position in the pad, in this case 0,5 (remember
// the coordinates in ncurses are y,x). The second set of numbers are the
// coordinates on the screen on which to display the content, so row 5,
// column 10. The last set of numbers tell how high and how wide the
// rectangle to displayed should be, in this case 15 rows long and 25
// columns wide.
pad.Refresh(0, 5, 5, 10, 15, 25)
pad.GetChar()
}
开发者ID:trotha01,项目名称:goncurses,代码行数:28,代码来源:pad.go
示例5: main
func main() {
// Initialize goncurses. It's essential End() is called to ensure the
// terminal isn't altered after the program ends
stdscr, err := goncurses.Init()
if err != nil {
log.Fatal("init", err)
}
defer goncurses.End()
// (Go)ncurses draws by cursor position and uses reverse cartisian
// coordinate system (y,x). Initially, the cursor is positioned at the
// coordinates 0,0 so the first call to Print will output the text at the
// top, left position of the screen since stdscr is a window which
// represents the terminal's screen size.
stdscr.Print("Hello, World!")
stdscr.MovePrint(3, 0, "Press any key to continue")
// Refresh() flushes output to the screen. Internally, it is the same as
// calling NoutRefresh() on the window followed by a call to Update()
stdscr.Refresh()
// GetChar will block execution until an input event, like typing a
// character on your keyboard, is received
stdscr.GetChar()
}
开发者ID:trotha01,项目名称:goncurses,代码行数:25,代码来源:hello.go
示例6: sendMsg
// In addition to sending a message using janimo's library, also clears screen and resets buffer
func sendMsg(inputWin *gc.Window, msgWin *gc.Window) {
if len(inputBuffer) != 0 {
msg := string(inputBuffer)
to := currentContact
err := ts.SendMessage(to, msg)
if err != nil {
gc.End()
log.Fatal("SendMessage failed yo: ", err)
}
var b bytes.Buffer
t := time.Now()
if t.Hour() < 10 {
b.WriteString("0")
}
b.WriteString(strconv.Itoa(t.Hour()))
b.WriteString(":")
if t.Minute() < 10 {
b.WriteString("0")
}
b.WriteString(strconv.Itoa(t.Minute()))
b.WriteString(": ")
b.WriteString(msg)
printToMsgWindow(b.String(), msgWin, true)
b.Reset()
insertMessage("You", currentContact, []byte(msg), nil)
inputBuffer = []byte{}
inputWin.Erase()
}
}
开发者ID:AyaTech,项目名称:textsecure-client,代码行数:32,代码来源:main.go
示例7: main
func main() {
stdscr, err := gc.Init()
if err != nil {
log.Fatal(err)
}
defer gc.End()
gc.Echo(false)
gc.CBreak(true)
gc.Cursor(0)
var panels [2]fp.FilePanel
rows, cols := stdscr.MaxYX()
height, width := rows, cols/2
y, x := 0, 0
activePanel := 0
panels[0] = fp.FilePanel{Height: height, Width: width, Y: y, X: x, Directory: "./", Selected: 0, IsActive: true}
panels[1] = fp.FilePanel{Height: height, Width: width, Y: y, X: x + width, Directory: "/home/kuzzmi/", Selected: 2, IsActive: false}
panels[0].Draw()
panels[1].Draw()
gc.UpdatePanels()
gc.Update()
stdscr.Keypad(true)
// stdscr.GetChar()
main:
for {
switch panels[activePanel].Panel.Window().GetChar() {
case 'q':
break main
case gc.KEY_RETURN:
panels[activePanel].Execute()
case gc.KEY_TAB:
panels[0].ToggleActivity()
panels[1].ToggleActivity()
gc.UpdatePanels()
gc.Update()
if activePanel == 0 {
activePanel = 1
} else {
activePanel = 0
}
case 'u':
panels[activePanel].GoUp()
case 'k':
panels[activePanel].Select(panels[activePanel].Selected - 1)
case 'j':
panels[activePanel].Select(panels[activePanel].Selected + 1)
case 'i':
panels[activePanel].HideHidden()
}
}
stdscr.Delete()
}
开发者ID:kuzzmi,项目名称:monk,代码行数:58,代码来源:files.go
示例8: ExitNC
func ExitNC() {
winMutex.Lock()
if win != nil {
win = nil
nc.End()
ncquit <- true
}
winMutex.Unlock()
}
开发者ID:Tondorf,项目名称:gosl,代码行数:9,代码来源:screen.go
示例9: main
// creates a curses based TUI for the textsecure library
func main() {
stdscr, err := gc.Init()
if err != nil {
log.Fatal("Error initializing curses:", err)
}
defer gc.End()
configCurses(stdscr)
client := &ts.Client{
GetConfig: getConfig,
GetLocalContacts: getLocalContacts,
GetVerificationCode: getVerificationCode,
GetStoragePassword: passphraseUnlock,
MessageHandler: recieveMessage,
RegistrationDone: registrationDone,
}
err = ts.Setup(client)
if err != nil {
log.Fatal("Could not initialize textsecure library", err)
}
db = setupDatabase()
contacts, err := ts.GetRegisteredContacts()
if err != nil {
log.Fatal("Could not get contacts: %s\n", err)
}
telToName = make(map[string]string)
for _, c := range contacts {
telToName[c.Tel] = c.Name
}
nameToTel = make(map[string]string)
for _, c := range contacts {
nameToTel[c.Name] = c.Tel
}
contactsWin, messageWinBorder, msgWin, inputBorderWin, inputWin := createMainWindows(stdscr)
menu_items, contactMenu, contactsMenuWin := makeContactsMenu(contacts, contactsWin)
globalInputWin = inputWin
globalMsgWin = msgWin
contactsMenuWin.Touch()
contactMenu.Post()
contactsWin.Refresh()
messageWinBorder.Refresh()
inputBorderWin.Refresh()
msgWin.Refresh()
msgWinSize_y, msgWinSize_x = msgWin.MaxYX()
currentContact = getTel(contactMenu.Current(nil).Name())
changeContact(contactsMenuWin, contactMenu)
inputWin.Move(0, 0)
go ts.StartListening()
inputHandler(inputWin, stdscr, contactsMenuWin, contactMenu, msgWin)
cleanup(menu_items, contactMenu)
}
开发者ID:AyaTech,项目名称:textsecure-client,代码行数:58,代码来源:main.go
示例10: main
func main() {
stdscr, err := gc.Init()
if err != nil {
return
}
defer gc.End()
stdscr.Border(gc.ACS_VLINE, gc.ACS_VLINE, gc.ACS_HLINE, gc.ACS_HLINE,
gc.ACS_ULCORNER, gc.ACS_URCORNER, gc.ACS_LLCORNER, gc.ACS_LRCORNER)
stdscr.GetChar()
}
开发者ID:trotha01,项目名称:goncurses,代码行数:11,代码来源:border.go
示例11: display
func (c *Circuit) display() {
stdscr, err := gc.Init()
if err != nil {
log.Println(err)
}
defer gc.End()
rows, cols := stdscr.MaxYX()
height, width := len(c.circuit)+1, len(c.circuit[0])+1
y, x := (rows-height)/2, (cols-width)/2
var win *gc.Window
win, err = gc.NewWindow(height, width, y, x)
if err != nil {
log.Println(err)
}
defer win.Delete()
win.Timeout(500)
for i := 0; i != height-1; i++ {
for j := 0; j != width-1; j++ {
if c.circuit[i][j] == "" {
continue
}
char := gc.Char([]rune(c.circuit[i][j])[0])
win.MoveAddChar(i, j, char)
}
}
main:
for {
for _, com := range c.Components {
com.Update()
}
for _, com := range c.Components {
cx, cy, _, _ := com.Space()
for coord, out := range com.Visual() {
char := gc.Char([]rune(*out)[0])
win.MoveAddChar(cx+coord.X, cy+coord.Y, char)
}
}
win.NoutRefresh()
gc.Update()
switch win.GetChar() {
case 'q':
break main
}
}
}
开发者ID:furryfaust,项目名称:textelectronics,代码行数:53,代码来源:circuit.go
示例12: dialog
func (cw *chatWin) dialog(messages chan message) {
stdscr, err := goncurses.Init()
if err != nil {
log.Fatal("init:", err)
}
defer goncurses.End()
goncurses.Raw(false)
stdscr.ScrollOk(true)
rows, cols := stdscr.MaxYX()
chats, err := goncurses.NewWindow(rows-MESSAGE_WIN_SIZE, cols, 0, 0)
if err != nil {
log.Fatal("Error setting up chat window")
}
chats.ScrollOk(true)
chats.Box(goncurses.ACS_VLINE, goncurses.ACS_HLINE)
chats.Refresh()
messageWin, err := goncurses.NewWindow(MESSAGE_WIN_SIZE, cols, rows-MESSAGE_WIN_SIZE, 0)
if err != nil {
log.Fatal("Error setting up chat window")
}
cw.msgRows, cw.msgCols = messageWin.MaxYX()
// allow special characters to come through (e.g. arrow keys)
messageWin.Keypad(true)
// sets terminal to non-blocking
// this also seems to print characters as they're typed, which causes some weird workarounds
goncurses.HalfDelay(1)
messageWin.Print(PROMPT)
for {
select {
case msg := <-messages:
y, _ := chats.CursorYX()
chats.MovePrint(y+1, 1, fmt.Sprintf("%s: %s", msg.From, msg.Message))
chats.Refresh()
messageWin.Refresh()
default:
line := cw.handleInput(messageWin)
if line != "" {
log.Println("Entered message:", line)
msg := message{From: cw.username, Message: line}
// TODO: uncomment once turnpike is fixed to not send events to the sender
// y, _ := chats.CursorYX()
// chats.MovePrint(y+1, 1, fmt.Sprintf("%s: %s", msg.From, msg.Message))
// chats.Refresh()
cw.msgs <- msg
}
}
}
}
开发者ID:apcera,项目名称:sample-apps,代码行数:53,代码来源:chatwin.go
示例13: main
func main() {
stdscr, _ := gc.Init()
defer gc.End()
gc.StartColor()
gc.CBreak(true)
gc.Echo(true)
stdscr.Keypad(true)
stdscr.Print("Hit 'tab' to cycle through windows, 'q' to quit")
gc.InitPair(1, gc.C_RED, gc.C_BLACK)
gc.InitPair(2, gc.C_GREEN, gc.C_BLACK)
gc.InitPair(3, gc.C_BLUE, gc.C_BLACK)
gc.InitPair(4, gc.C_CYAN, gc.C_BLACK)
var panels [3]*gc.Panel
y, x := 4, 10
for i := 0; i < 3; i++ {
h, w := 10, 40
title := "Window Number %d"
window, _ := gc.NewWindow(h, w, y+(i*4), x+(i*10))
window.Box(0, 0)
window.MoveAddChar(2, 0, gc.ACS_LTEE)
window.HLine(2, 1, gc.ACS_HLINE, w-2)
window.MoveAddChar(2, w-1, gc.ACS_RTEE)
window.ColorOn(int16(i + 1))
window.MovePrintf(1, (w/2)-(len(title)/2), title, i+1)
window.ColorOff(int16(i + 1))
panels[i] = gc.NewPanel(window)
}
active := 2
for {
gc.UpdatePanels()
gc.Update()
switch stdscr.GetChar() {
case 'q':
return
case gc.KEY_TAB:
active += 1
if active > 2 {
active = 0
}
panels[active].Top()
}
}
}
开发者ID:trotha01,项目名称:goncurses,代码行数:52,代码来源:panel2.go
示例14: ExampleInit
func ExampleInit() {
// You should always test to make sure ncurses has initialized properly.
// In order for your error messages to be visible on the terminal you will
// need to either log error messages or output them to to stderr.
stdscr, err := goncurses.Init()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer goncurses.End()
stdscr.Print("Press enter to continue...")
stdscr.Refresh()
}
开发者ID:kovetskiy,项目名称:goncurses,代码行数:13,代码来源:example_test.go
示例15: GetXY
func GetXY() (int, int) {
win, err := nc.Init()
if err != nil {
log.Fatal(err)
os.Exit(1)
}
win.Clear()
h, w := win.MaxYX()
nc.End()
fmt.Printf("screen: %d x %d\n", w, h)
return w, h
}
开发者ID:Tondorf,项目名称:gosl,代码行数:13,代码来源:screen.go
示例16: main
func main() {
stdscr, err := gc.Init()
if err != nil {
log.Fatal("init:", err)
}
defer gc.End()
// HasColors can be used to determine whether the current terminal
// has the capability of using colours. You could then chose whether or
// not to use some other mechanism, like using A_REVERSE, instead
if !gc.HasColors() {
log.Fatal("Example requires a colour capable terminal")
}
// Must be called after Init but before using any colour related functions
if err := gc.StartColor(); err != nil {
log.Fatal(err)
}
gc.Echo(false)
// Initialize a colour pair. Should only fail if an improper pair value
// is given
if err := gc.InitPair(1, gc.C_RED, gc.C_WHITE); err != nil {
log.Fatal("InitPair failed: ", err)
}
gc.InitPair(2, gc.C_BLACK, gc.C_CYAN)
stdscr.Println("Type any key to proceed and again to exit")
// An example of trying to set an invalid color pair
err = gc.InitPair(-1, gc.C_BLACK, gc.C_CYAN)
stdscr.Println("An intentional error:", err)
stdscr.Keypad(true)
stdscr.MovePrint(12, 30, "Hello, World!!!")
stdscr.Refresh()
stdscr.GetChar()
// Note that background doesn't just accept colours but will fill
// any blank positions with the supplied character too. Note that newly
// added text with spaces in it will have the blanks converted to the fill
// character, if given
stdscr.SetBackground(gc.Char('*') | gc.ColorPair(2))
// ColorOn/Off is a shortcut to calling AttrOn/Off(gc.ColorPair(pair))
stdscr.ColorOn(1)
stdscr.MovePrint(13, 30, "Hello, World in Color!!!")
stdscr.ColorOff(1)
stdscr.Refresh()
stdscr.GetChar()
}
开发者ID:trotha01,项目名称:goncurses,代码行数:50,代码来源:color.go
示例17: main
func main() {
stdscr, err := gc.Init()
if err != nil {
log.Fatal(err)
}
defer gc.End()
gc.Cursor(0)
gc.Echo(false)
stdscr.Print("A reversed plus-minus symbol: ")
stdscr.AddChar(gc.ACS_PLMINUS | gc.A_REVERSE)
stdscr.Refresh()
stdscr.GetChar()
}
开发者ID:trotha01,项目名称:goncurses,代码行数:15,代码来源:acs.go
示例18: main
func main() {
stdscr, err := gc.Init()
if err != nil {
log.Fatal(err)
}
defer gc.End()
gc.StartColor()
gc.Echo(false)
gc.Raw(true)
var colours = []int16{gc.C_BLACK, gc.C_BLUE, gc.C_CYAN, gc.C_GREEN,
gc.C_MAGENTA, gc.C_RED, gc.C_WHITE, gc.C_YELLOW}
var attributes = []struct {
attr gc.Char
text string
}{
{gc.A_NORMAL, "normal"},
{gc.A_STANDOUT, "standout"},
{gc.A_UNDERLINE | gc.A_BOLD, "underline"},
{gc.A_REVERSE, "reverse"},
{gc.A_BLINK, "blink"},
{gc.A_DIM, "dim"},
{gc.A_BOLD, "bold"},
}
stdscr.MovePrint(0, 0, "Normal terminal colors: ")
for i, c := range colours {
gc.InitPair(int16(i), c, c)
stdscr.ColorOn(int16(i))
stdscr.AddChar(' ')
stdscr.ColorOff(int16(i))
}
stdscr.MovePrint(1, 0, "Bold terminal colors: ")
stdscr.AttrOn(gc.A_BLINK)
for i, _ := range colours {
stdscr.ColorOn(int16(i))
stdscr.AddChar(' ')
stdscr.ColorOff(int16(i))
}
stdscr.AttrOff(gc.A_BLINK)
stdscr.Move(2, 0)
for _, a := range attributes {
stdscr.AttrOn(a.attr)
stdscr.Println(a.text)
stdscr.AttrOff(a.attr)
}
stdscr.GetChar()
}
开发者ID:trotha01,项目名称:goncurses,代码行数:48,代码来源:features.go
示例19: main
func main() {
stdscr, _ := gc.Init()
defer gc.End()
row, col := stdscr.MaxYX()
msg := "Just a string "
stdscr.MovePrint(row/2, (col-len(msg))/2, msg)
stdscr.MovePrintf(row-3, 0, "This screen has %d rows and %d columns. ",
row, col)
stdscr.Println()
stdscr.Print("Try resizing your terminal window and then " +
"run this program again.")
stdscr.Refresh()
stdscr.GetChar()
}
开发者ID:trotha01,项目名称:goncurses,代码行数:16,代码来源:print.go
示例20: main
func main() {
stdscr, err := goncurses.Init()
if err != nil {
log.Fatal("init:", err)
}
defer goncurses.End()
goncurses.Raw(true)
goncurses.Echo(false)
goncurses.Cursor(0)
stdscr.Clear()
stdscr.Keypad(true)
menu_items := []string{"Choice 1", "Choice 2", "Choice 3", "Choice 4",
"Exit"}
items := make([]*goncurses.MenuItem, len(menu_items))
for i, val := range menu_items {
items[i], _ = goncurses.NewItem(val, "")
defer items[i].Free()
}
menu, err := goncurses.NewMenu(items)
if err != nil {
stdscr.Print(err)
return
}
defer menu.Free()
menu.Post()
stdscr.MovePrint(20, 0, "'q' to exit")
stdscr.Refresh()
for {
goncurses.Update()
ch := stdscr.GetChar()
switch goncurses.KeyString(ch) {
case "q":
return
case "down":
menu.Driver(goncurses.REQ_DOWN)
case "up":
menu.Driver(goncurses.REQ_UP)
}
}
}
开发者ID:trotha01,项目名称:goncurses,代码行数:47,代码来源:menu.go
注:本文中的github.com/rthornton128/goncurses.End函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论