Janky line delete

This commit is contained in:
Jeremy Penner 2020-08-01 22:57:26 -04:00
parent 31ab88ab6c
commit 0d83da70ae
2 changed files with 27 additions and 13 deletions

View file

@ -353,11 +353,17 @@ class SyntBlock(Synt):
syntStmt.syntParent = self
return syntStmt
def RemoveLine(self, synt):
self.rgsynt.remove(synt)
def HandleKey(self, pwKey, pov, psel, key):
if ansi.FEnter(key):
self.InsertLineAfter(pwKey.pwChild.Value(), None)
psel.Inc(pwKey.PwParent())
return True
elif key == ansi.K_DEL and pwKey.pwChild.RgpwChild()[0] == psel.PwSelected(pwKey):
psel.Inc(pwKey.PwParent())
self.RemoveLine(pwKey.pwChild.Value())
return False
def Eval(self, env):
@ -738,8 +744,6 @@ class PwBlock(PwContainer):
return psel.Dec(self)
elif key == ansi.K_DOWN:
return psel.Inc(self)
elif key == ansi.K_DEL:
pass
return False
class PwDropdown(PwBlock):
@ -866,13 +870,27 @@ class Psel(TPrs):
return True
return False
def CLevelChild_PwRoot(self, pw):
clevelChild = 1
while pw.PwParent() != None:
clevelChild = clevelChild + 1
pw = pw.PwParent()
return (clevelChild, pw)
def PwRoot(self, pw):
return self.CLevelChild_PwRoot(pw)[1]
def Value(self, pwRoot):
pwRoot = self.PwRoot(pwRoot)
self.Validate(pwRoot)
if len(self.rgo_ipw) > 0:
return self.rgo_ipw[-1][0]
return None
def PwSelected(self, pwRoot, clevel = None):
def PwSelected(self, pw, clevel = None):
clevelChild, pwRoot = self.CLevelChild_PwRoot(pw)
if clevel is not None:
clevel = clevel + clevelChild - 1
self.Validate(pwRoot)
return self.PwSelectedI(pwRoot, self.rgo_ipw[:clevel])
@ -887,11 +905,7 @@ class Psel(TPrs):
return self.ChangeI(pwContainer, IoDec)
def ChangeI(self, pwContainer, fnChange):
clevelChild = 1
pwRoot = pwContainer
while pwRoot.PwParent() != None:
clevelChild = clevelChild + 1
pwRoot = pwRoot.PwParent()
clevelChild, pwRoot = self.CLevelChild_PwRoot(pwContainer)
self.Validate(pwRoot)
assert self.PwSelected(pwRoot, clevelChild).PwParent() == pwContainer

View file

@ -213,7 +213,7 @@ class Joiner(LeaveJoinToken):
self.game.Chat().Add(ChlSys(client, "has left"))
## TODO:
## - fix numbering
## - fix lobby numbering (clients either editing or playing a game)
class Player(TokenClient):
def InitPersistent(self, owner, client):