本文整理汇总了Golang中github.com/rthornton128/goncurses.Window.Scroll方法的典型用法代码示例。如果您正苦于以下问题:Golang Window.Scroll方法的具体用法?Golang Window.Scroll怎么用?Golang Window.Scroll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rthornton128/goncurses.Window
的用法示例。
在下文中一共展示了Window.Scroll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: printToMsgWindow
// Prints messages to the message window
func printToMsgWindow(msg string, msgWin *gc.Window, amSending bool) {
lines := int(len(msg)/(msgWinSize_x-1)) + 1
if amSending == true {
msgWin.Scroll(lines)
msgWin.ColorOn(2)
msgWin.MovePrint((msgWinSize_y - lines), 0, msg)
} else {
if strings.ContainsAny(msg, "\n") {
printByLineBreakdown := strings.Split(msg, "\n")
for i, val := range printByLineBreakdown {
if i != 0 {
msgWin.Scroll(1)
}
lines2 := int(len(val)/(msgWinSize_x-1)) + 1
if lines2 > 1 {
msgWin.Scroll(lines2)
msgWin.ColorOn(1)
msgWin.MovePrint((msgWinSize_y - lines2), int(msgWinSize_x*3/4), val)
} else {
msgWin.Scroll(lines2)
msgWin.ColorOn(1)
space_buf := (msgWinSize_x) - len(val)
msgWin.MovePrint((msgWinSize_y - lines), space_buf, val)
msgWin.Scroll(-1)
}
}
} else {
if lines > 1 {
msgWin.Scroll(lines)
msgWin.ColorOn(1)
msgWin.MovePrint((msgWinSize_y - lines), int(msgWinSize_x*3/4), msg)
} else {
msgWin.Scroll(lines)
msgWin.ColorOn(1)
space_buf := (msgWinSize_x) - len(msg)
msgWin.MovePrint((msgWinSize_y - lines), space_buf, msg)
msgWin.Scroll(-1)
}
}
}
msgWin.Refresh()
globalInputWin.Refresh()
}
示例2: inputHandler
// handles keyboard input
func inputHandler(inputWin *gc.Window, stdscr *gc.Window, contactsMenuWin *gc.Window, contactMenu *gc.Menu, msgWin *gc.Window) {
var NLlocate = map[int]newLine{}
var c gc.Char
var rawInput gc.Key
max_y, max_x := inputWin.MaxYX()
for {
rawInput = inputWin.GetChar()
c = gc.Char(rawInput)
// debugLog.Println(rawInput)
// debugLog.Println(c)
//Escape to Quit
if c == gc.Char(27) {
break
} else if rawInput == gc.KEY_BACKSPACE || c == gc.Char(127) {
//Delete Key
y, x := inputWin.CursorYX()
var del = byte('F')
if x != 0 {
inputWin.MoveDelChar(y, x-1)
del = inputBuffer[placer]
copy(inputBuffer[placer:len(inputBuffer)-1], inputBuffer[placer+1:])
inputBuffer = inputBuffer[0 : len(inputBuffer)-1]
placer--
if del != byte('\n') && NLlocate[y+scroll]._cursorX > x {
temp := newLine{NLlocate[y+scroll]._cursorX - 1, NLlocate[y+scroll]._placer - 1}
NLlocate[y+scroll] = temp
}
//debugLog.Println(inputBuffer)
} else if y != 0 { //when x==0 and y!=0
inputWin.Move(y-1, max_x-1)
inputWin.MoveDelChar(y-1, max_x-1)
del = inputBuffer[placer]
copy(inputBuffer[placer:len(inputBuffer)-1], inputBuffer[placer+1:])
inputBuffer = inputBuffer[0 : len(inputBuffer)-1]
//debugLog.Println(inputBuffer)
placer--
}
if del == byte('\n') {
inputWin.Erase()
inputWin.Print(string(inputBuffer))
inputWin.Move(y-1, NLlocate[y-1+scroll]._cursorX)
temp, check := NLlocate[y+scroll]
var temp_cursor = temp._cursorX
var temp_placer = temp._placer
if check && NLlocate[y-1+scroll]._cursorX+temp_cursor >= max_x {
_newLine := newLine{NLlocate[y-1+scroll]._cursorX + temp_cursor - max_x, NLlocate[y+scroll]._placer - 1}
NLlocate[y+scroll] = _newLine
delete(NLlocate, y-1)
} else if check { // check if there are any '\n' this line
var largest = -1 // if yes, select all '\n' and move
for i := range NLlocate { // placer by 1 and adjust cursor
if i >= y+scroll { // accordingly
if next_nl, ok := NLlocate[i+1]; ok {
new_nl := newLine{next_nl._cursorX, next_nl._placer - 1}
NLlocate[i] = new_nl
}
}
if i > largest {
largest = i
}
}
delete(NLlocate, largest) // delete last map entry
_newLine := newLine{NLlocate[y-1+scroll]._cursorX + temp_cursor, NLlocate[y-1+scroll]._placer + temp_placer - 1}
NLlocate[y-1+scroll] = _newLine
} else {
delete(NLlocate, y-1+scroll)
}
}
} else if c == gc.KEY_PAGEDOWN {
//debugLog.Println("HIT DOWN")
msgWin.Scroll(-10)
msgWin.Refresh()
inputWin.Refresh()
} else if c == gc.KEY_PAGEUP {
//debugLog.Println("HIT UP")
msgWin.Scroll(10)
msgWin.Refresh()
inputWin.Refresh()
} else if c == gc.KEY_LEFT {
y, x := inputWin.CursorYX()
if x != 0 {
inputWin.Move(y, x-1)
placer--
} else if y != 0 {
inputWin.Move(y-1, max_x-1)
placer--
}
if len(inputBuffer) > 0 && inputBuffer[placer+1] == byte('\n') {
inputWin.Move(y-1, NLlocate[y-1+scroll]._cursorX)
}
} else if c == gc.KEY_RIGHT {
y, x := inputWin.CursorYX()
placer++
if inputBuffer == nil || placer == len(inputBuffer) {
inputBuffer = append(inputBuffer, byte(' '))
}
if inputBuffer[placer] == byte('\n') || x >= max_x-1 {
inputWin.Move(y+1, 0)
//.........这里部分代码省略.........