Example #1
0
    def record(self):
        global cur_word, keys, log

        # maintain state of keys (pressed or not)
        if self.event.Key in keys:
            keys.remove(self.event.Key)
            return True
        else:
            keys.add(self.event.Key)

        #print self.value, self.code
        # linux & win ctrls, alts, tab
        meta_keys = set(['Lcontrol','Rcontrol','Lmenu','Rmenu','Tab','Control_L','Control_R','Alt_L','Alt_R',
                         '[65027]'])
                        # my right alt..
        if meta_keys.intersection(keys):
            #print "meta key" # t,c,T,C   but these are 99 & 116... & 84 & 67 w/ Shift
            return True
          
        # filter out non-ascii keys or ascii keys we don't care about
        #print "value", self.value
        if not self.__class__.recordable.match(self.value):
            #print "not recordable"
            return True

        # if control is held, then don't record..

        #print 'scancode: %s     ascii: %s (%s)' % \
        #    (event.ScanCode, event.Ascii, chr(event.Ascii))

        if self.value not in " \n\t":
            cur_word += self.value
            print "word so far:", cur_word
        else:
            if cur_word == 'xxx':
                dump_logs()
                exit()
            if cur_word.strip():
              env.set_last_word(self.process, cur_word) # SOMETHING WRONG HERE..
              # window_name has more data..
              print "got word: %s" % cur_word
            cur_word = ''

        log[self.window_name] = log.setdefault(self.window_name, '') + self.value

        return True
Example #2
0
 def POST(self):
     if self.restrict_access(): return
     input = web.input(word='')
     
     if input.word:
         env.set_last_word('__context_agent__', input.word)