當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Window.Move方法代碼示例

本文整理匯總了Golang中github.com/rthornton128/goncurses.Window.Move方法的典型用法代碼示例。如果您正苦於以下問題:Golang Window.Move方法的具體用法?Golang Window.Move怎麽用?Golang Window.Move使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/rthornton128/goncurses.Window的用法示例。


在下文中一共展示了Window.Move方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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)
//.........這裏部分代碼省略.........
開發者ID:AyaTech,項目名稱:textsecure-client,代碼行數:101,代碼來源:input.go


注:本文中的github.com/rthornton128/goncurses.Window.Move方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。