def run(self):
     curses.cbreak()
     curses.noecho()
     output.lastline()
     output.overwriteline()
     self.prompt()
     output.scr.refresh()
     last = None
     for item in self.data:
         if item[0] != None:
             if not self.inahurry:
                 if last != None:
                     curses.napms(600 + len(last)*30)
                 else:
                     curses.napms(1000)
             self.receive(item[0], item[1])
             output.scr.refresh()
             last = item[1]
         else:
             self.send(item[1])
             output.openline()
             self.prompt()
             output.scr.refresh()
             last = None
     output.removelastline()
示例#2
0
def decr(f, f2):
    global gamesate
    gamestate["localhost"].files.remove(f)
    scr = output.scr
    output.openline()
    scr.addstr("Decrypting %s:" % f)
    output.openline()
    scr.addstr("[" + 30 * " " + "]")
    output.lastline()
    scr.addstr("[")
    scr.refresh()
    for i in range(30):
        curses.napms(100)
        scr.addstr("#")
        scr.refresh()
    output.openline()
    scr.addstr("File %s was decrypted successfully. Result saved in %s" % (f, f2))
    gamestate["localhost"].addfile(f2)
    def send(self, msg):
        curses.curs_set(1)
        scr = output.scr
        output.lastline()
        self.prompt()
        curses.flushinp()
        for c in msg:
            # take out for release
#            if scr.getch() == ord('\n'):
#               break
            if not self.inahurry:
                scr.getch()
            scr.addch(c)
        if not self.inahurry:
            while scr.getch() != ord('\n'):
                pass
        output.overwriteline()
        scr.addstr("Sent: ", output.yellow | curses.A_BOLD)
        scr.addstr(msg, output.white)
        scr.refresh()
        curses.curs_set(0)