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

@ -352,12 +352,18 @@ class SyntBlock(Synt):
self.rgsynt.insert(self.rgsynt.index(syntAfter) + 1, syntStmt) self.rgsynt.insert(self.rgsynt.index(syntAfter) + 1, syntStmt)
syntStmt.syntParent = self syntStmt.syntParent = self
return syntStmt return syntStmt
def RemoveLine(self, synt):
self.rgsynt.remove(synt)
def HandleKey(self, pwKey, pov, psel, key): def HandleKey(self, pwKey, pov, psel, key):
if ansi.FEnter(key): if ansi.FEnter(key):
self.InsertLineAfter(pwKey.pwChild.Value(), None) self.InsertLineAfter(pwKey.pwChild.Value(), None)
psel.Inc(pwKey.PwParent()) psel.Inc(pwKey.PwParent())
return True 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 return False
def Eval(self, env): def Eval(self, env):
@ -738,8 +744,6 @@ class PwBlock(PwContainer):
return psel.Dec(self) return psel.Dec(self)
elif key == ansi.K_DOWN: elif key == ansi.K_DOWN:
return psel.Inc(self) return psel.Inc(self)
elif key == ansi.K_DEL:
pass
return False return False
class PwDropdown(PwBlock): class PwDropdown(PwBlock):
@ -865,14 +869,28 @@ class Psel(TPrs):
if self.FPwValid(pwChild): if self.FPwValid(pwChild):
return True return True
return False 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): def Value(self, pwRoot):
pwRoot = self.PwRoot(pwRoot)
self.Validate(pwRoot) self.Validate(pwRoot)
if len(self.rgo_ipw) > 0: if len(self.rgo_ipw) > 0:
return self.rgo_ipw[-1][0] return self.rgo_ipw[-1][0]
return None 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) self.Validate(pwRoot)
return self.PwSelectedI(pwRoot, self.rgo_ipw[:clevel]) return self.PwSelectedI(pwRoot, self.rgo_ipw[:clevel])
@ -887,11 +905,7 @@ class Psel(TPrs):
return self.ChangeI(pwContainer, IoDec) return self.ChangeI(pwContainer, IoDec)
def ChangeI(self, pwContainer, fnChange): def ChangeI(self, pwContainer, fnChange):
clevelChild = 1 clevelChild, pwRoot = self.CLevelChild_PwRoot(pwContainer)
pwRoot = pwContainer
while pwRoot.PwParent() != None:
clevelChild = clevelChild + 1
pwRoot = pwRoot.PwParent()
self.Validate(pwRoot) self.Validate(pwRoot)
assert self.PwSelected(pwRoot, clevelChild).PwParent() == pwContainer assert self.PwSelected(pwRoot, clevelChild).PwParent() == pwContainer
@ -915,7 +929,7 @@ class Pov(TokenClient):
def Back(self, val, pw): def Back(self, val, pw):
self.client.leaveGame() self.client.leaveGame()
def run(self): def run(self):
while True: while True:
key = self.EvKey().receive(self) key = self.EvKey().receive(self)

View file

@ -213,7 +213,7 @@ class Joiner(LeaveJoinToken):
self.game.Chat().Add(ChlSys(client, "has left")) self.game.Chat().Add(ChlSys(client, "has left"))
## TODO: ## TODO:
## - fix numbering ## - fix lobby numbering (clients either editing or playing a game)
class Player(TokenClient): class Player(TokenClient):
def InitPersistent(self, owner, client): def InitPersistent(self, owner, client):
@ -282,7 +282,7 @@ class GameWorld(Game):
def Chat(self): def Chat(self):
return self.chat return self.chat
def StName(self): def StName(self):
return self.dtStart.strftime("%b %d, %Y at %I:%M%p") + " [" + str(len(self.RgclientConnected())) + "]" return self.dtStart.strftime("%b %d, %Y at %I:%M%p") + " [" + str(len(self.RgclientConnected())) + "]"