Janky line delete
This commit is contained in:
parent
31ab88ab6c
commit
0d83da70ae
30
scripting.py
30
scripting.py
|
@ -353,11 +353,17 @@ class SyntBlock(Synt):
|
||||||
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):
|
||||||
|
@ -866,13 +870,27 @@ class Psel(TPrs):
|
||||||
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
|
||||||
|
|
||||||
|
|
2
world.py
2
world.py
|
@ -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):
|
||||||
|
|
Loading…
Reference in a new issue