+ def home(self):
+ self.allmarked = False
+ if self.type == self.TEXT:
+ self.timeout()
+ self.currPos = 0
+ self.update()
+
+ def end(self):
+ self.allmarked = False
+ if self.type == self.TEXT:
+ self.timeout()
+ if self.maxSize:
+ self.currPos = len(self.Text) - 1
+ else:
+ self.currPos = len(self.Text)
+ self.update()
+
+ def insertChar(self, ch, pos, owr, ins):
+ if ins and not self.maxSize:
+ self.Text = self.Text[0:pos] + ch + self.Text[pos:]
+ elif owr or self.overwrite:
+ self.Text = self.Text[0:pos] + ch + self.Text[pos + 1:]
+ elif self.maxSize:
+ self.Text = self.Text[0:pos] + ch + self.Text[pos:-1]
+ else:
+ self.Text = self.Text[0:pos] + ch + self.Text[pos:]
+
+ def deleteChar(self, pos):
+ if not self.maxSize:
+ self.Text = self.Text[0:pos] + self.Text[pos + 1:]
+ elif self.overwrite:
+ self.Text = self.Text[0:pos] + " " + self.Text[pos + 1:]
+ else:
+ self.Text = self.Text[0:pos] + self.Text[pos + 1:] + " "
+
+ def deleteAllChars(self):
+ if self.maxSize:
+ self.Text = " " * len(self.Text)
+ else:
+ self.Text = ""
+ self.currPos = 0
+
+ def tab(self):
+ if self.type == self.TEXT:
+ self.timeout()
+ if self.allmarked:
+ self.deleteAllChars()
+ self.allmarked = False
+ else:
+ self.insertChar(" ", self.currPos, False, True);
+ self.innerright()
+ self.update()
+
+ def delete(self):
+ if self.type == self.TEXT:
+ self.timeout()
+ if self.allmarked:
+ self.deleteAllChars()
+ self.allmarked = False
+ else:
+ self.deleteChar(self.currPos);
+ if self.maxSize and self.overwrite:
+ self.innerright()
+ self.update()
+
+ def deleteBackward(self):
+ if self.type == self.TEXT:
+ self.timeout()
+ if self.allmarked:
+ self.deleteAllChars()
+ self.allmarked = False
+ else:
+ if self.currPos > 0:
+ self.deleteChar(self.currPos-1);
+ if not self.maxSize and self.offset > 0:
+ self.offset -= 1
+ self.currPos -= 1
+ self.update()
+
+ def toggleOverwrite(self):
+ if self.type == self.TEXT:
+ self.timeout()
+ self.overwrite = not self.overwrite
+ self.update()
+
+ def handleAscii(self, code):
+ if self.type == self.TEXT:
+ self.timeout()
+ if self.allmarked:
+ self.deleteAllChars()
+ self.allmarked = False
+ self.insertChar(unichr(code), self.currPos, False, False);
+ self.innerright()
+ self.update()
+