clean up broken word wrap, add , endOfScreen return value

This commit is contained in:
chrys 2016-10-20 21:10:39 +02:00
parent 5be38ed831
commit 763a1a26b5
2 changed files with 37 additions and 18 deletions

View File

@ -7,8 +7,9 @@
from core import debug
def getPrevChar(currX,currY, currText):
endOfScreen = False
if currText == '':
return -1, -1, ''
return -1, -1, '', endOfScreen
wrappedLines = currText.split('\n')
x = currX
y = currY
@ -16,51 +17,60 @@ def getPrevChar(currX,currY, currText):
if y - 1 > 0:
y -= 1
x = len(wrappedLines[y]) - 1
else:
endOfScreen = True
else:
x -= 1
currChar = wrappedLines[y][x]
return x, y, currChar
return x, y, currChar, endOfScreen
def getCurrentChar(currX,currY, currText):
endOfScreen = False
if currText == '':
return -1, -1, ''
wrappedLines = currText.split('\n')
currChar = wrappedLines[currY][currX]
return currX, currY, currChar
return currX, currY, currChar, endOfScreen
def getUpChar(currX,currY, currText):
endOfScreen = False
if currText == '':
return -1, -1, ''
return -1, -1, '', endOfScreen
wrappedLines = currText.split('\n')
currY -= 1
if currY < 0:
currY = 0
currChar = wrappedLines[currY][currX]
return currX, currY, currChar
return currX, currY, currChar, endOfScreen
def getDownChar(currX,currY, currText):
endOfScreen = False
if currText == '':
return -1, -1, ''
return -1, -1, '', endOfScreen
wrappedLines = currText.split('\n')
currY += 1
if currY >= len(wrappedLines):
currY = len(wrappedLines) -1
currY = len(wrappedLines) -1
else:
endOfScreen = True
currChar = wrappedLines[currY][currX]
return currX, currY, currChar
return currX, currY, currChar, endOfScreen
def getLastCharInLine(currY, currText):
endOfScreen = False
if currText == '':
return -1, -1, ''
return -1, -1, '', endOfScreen
wrappedLines = currText.split('\n')
currX = len(wrappedLines[currY].rstrip())-1
if currX < 0:
currX = 0
currChar = wrappedLines[currY][currX]
return currX, currY, currChar
return currX, currY, currChar, endOfScreen
def getNextChar(currX,currY, currText):
endOfScreen = False
if currText == '':
return -1, -1, ''
return -1, -1, '', endOfScreen
wrappedLines = currText.split('\n')
x = currX
y = currY
@ -68,10 +78,12 @@ def getNextChar(currX,currY, currText):
if y + 1 < len(wrappedLines) - 1:
y += 1
x = 0
else:
endOfScreen = True
else:
x += 1
currChar = wrappedLines[y][x]
return x, y, currChar
return x, y, currChar, endOfScreen
def getPhonetic(currChar):
if len(currChar) != 1:

View File

@ -7,35 +7,42 @@
from core import debug
def getPrevLine(currX,currY, currText):
endOfScreen = False
if currText == '':
return -1, -1, ''
return -1, -1, '', endOfScreen
wrappedLines = currText.split('\n')
x = currX
y = currY
if y - 1 >= 0:
y -= 1
else:
endOfScreen = True
x = 0
currLine = wrappedLines[y]
return x, y, currLine
return x, y, currLine, endOfScreen
def getCurrentLine(currX,currY, currText):
endOfScreen = False
if currText == '':
return -1, -1, ''
return -1, -1, '', endOfScreen
wrappedLines = currText.split('\n')
x = currX
y = currY
x = 0
currLine = wrappedLines[y]
return x, y, currLine
return x, y, currLine, endOfScreen
def getNextLine(currX,currY, currText):
endOfScreen = False
if currText == '':
return -1, -1, ''
return -1, -1, '', endOfScreen
wrappedLines = currText.split('\n')
x = currX
y = currY
if y + 1 < len(wrappedLines):
y += 1
else:
endOfScreen = True
x = 0
currLine = wrappedLines[y]
return x, y, currLine
return x, y, currLine, endOfScreen