本文整理汇总了Golang中github.com/rthornton128/goncurses.Window.MoveWindow方法的典型用法代码示例。如果您正苦于以下问题:Golang Window.MoveWindow方法的具体用法?Golang Window.MoveWindow怎么用?Golang Window.MoveWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rthornton128/goncurses.Window
的用法示例。
在下文中一共展示了Window.MoveWindow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: windw
func windw() {
stdscr, err := gc.Init()
if err != nil {
log.Fatal(err)
}
defer gc.End()
// Turn off character echo, hide the cursor and disable input buffering
gc.Echo(false)
gc.CBreak(true)
gc.Cursor(0)
stdscr.Print("Use arrow keys to move the window. Press 'q' to exit")
stdscr.NoutRefresh()
// Determine the center of the screen and offset those coordinates by
// half of the window size we are about to create. These coordinates will
// be used to move our window around the screen
rows, cols := stdscr.MaxYX()
height, width := 20, 40
y, x := (rows-height)/2, (cols-width)/2
// Create a new window centered on the screen and enable the use of the
// keypad on it so the arrow keys are available
var win *gc.Window
win, err = gc.NewWindow(height, width, y, x)
if err != nil {
log.Fatal(err)
}
win.Keypad(true)
windw:
for {
// Clear the section of screen where the box is currently located so
// that it is blanked by calling Erase on the window and refreshing it
// so that the chances are sent to the virtual screen but not actually
// output to the terminal
win.Erase()
win.NoutRefresh()
// Move the window to it's new location (if any) and redraw it
win.MoveWindow(y, x)
win.Box(gc.ACS_VLINE, gc.ACS_HLINE)
win.NoutRefresh()
// Update will flush only the characters which have changed between the
// physical screen and the virtual screen, minimizing the number of
// characters which must be sent
gc.Update()
// In order for the window to display correctly, we must call GetChar()
// on it rather than stdscr
switch win.GetChar() {
case 'q':
break windw
case 'h':
if x > 0 {
x--
}
case 'l':
if x < cols-width {
x++
}
case 'k':
if y > 1 {
y--
}
case 'j':
if y < rows-height {
y++
}
}
}
win.Delete()
}