Spelltinkle 0.1 documentation

spelltinkle.input

Contents

Source code for spelltinkle.input

[docs]class InputActions: def __init__(self, session): self.session = session self.c = 0 self.string = ''
[docs] def update(self, doc, string=None): if string is not None: self.string = string
[docs] def insert_character(self, doc, chr): s = self.string[:self.c] + chr + self.string[self.c:] self.c += 1 self.update(doc, s)
[docs] def bs(self, doc): s = self.string[:self.c - 1] + self.string[self.c:] self.c -= 1 self.update(doc, s)
[docs] def delete(self, doc): s = self.string[:self.c] + self.string[self.c + 1:] self.update(doc, s)
[docs] def left(self, doc): self.c = max(0, self.c - 1) self.update(doc)
[docs] def right(self, doc): self.c = min(len(self.string), self.c + 1) self.update(doc)
[docs] def home(self, doc): self.c = 0 self.update(doc)
[docs] def end(self, doc): self.c = len(self.string) self.update(doc)

Contents