def igoto(win): try: choice = stdwin.askstr('Go to node (full name):', '') except KeyboardInterrupt: return if not choice: stdwin.message('Sorry, Go to has no default') return imove(win, choice)
def key_G(self): # goto try: reply = stdwin.askstr('Go to document:', self.cur_addr) except KeyboardInterrupt: return addr = string.strip(reply) if not addr: return self.follow(addr)
def key_f(self): # Find string if last_regex: prog, pat = last_regex else: prog, pat = None, '' try: pat = stdwin.askstr('Enter regular expression:', pat) except KeyboardInterrupt: return self.find(pat)
def isearch(win): try: pat = stdwin.askstr('Search pattern:', win.pat) except KeyboardInterrupt: return if not pat: pat = win.pat if not pat: stdwin.message('No previous pattern') return try: cpat = regexp.compile(pat) except regexp.error, msg: stdwin.message('Bad pattern: ' + msg) return
def key_i(self): # find keyword in index try: reply = stdwin.askstr('Find keyword(s) in index:', '') except KeyboardInterrupt: return words = string.split(reply) if not words: return scheme, host, port, path, search, anchor = \ wwwlib.parse_addr(self.cur_addr) if len(search) > 1: hist = H_NOP else: hist = H_PUSH search = '?' + string.joinfields(words, '+') addr = wwwlib.unparse_addr(scheme,host,port,path,search,'') self.follow(addr, hist)
def key_i(self): # find keyword in index try: reply = stdwin.askstr('Find keyword(s) in index:', '') except KeyboardInterrupt: return words = string.split(reply) if not words: return scheme, host, port, path, search, anchor = \ wwwlib.parse_addr(self.cur_addr) if len(search) > 1: hist = H_NOP else: hist = H_PUSH search = '?' + string.joinfields(words, '+') addr = wwwlib.unparse_addr(scheme, host, port, path, search, '') self.follow(addr, hist)
def ichoice(win, prompt, list, default): if not list: stdwin.fleep() return if not default: topic, ref = list[0] default = topic try: choice = stdwin.askstr(prompt, default) except KeyboardInterrupt: return if not choice: return choice = string.lower(choice) n = len(choice) for topic, ref in list: topic = string.lower(topic) if topic[:n] == choice: imove(win, ref) return stdwin.message('Sorry, no topic matches ' + `choice`)
def ichoice(win, prompt, list, default): if not list: stdwin.fleep() return if not default: topic, ref = list[0] default = topic try: choice = stdwin.askstr(prompt, default) except KeyboardInterrupt: return if not choice: return choice = string.lower(choice) n = len(choice) for topic, ref in list: topic = string.lower(topic) if topic[:n] == choice: imove(win, ref) return stdwin.message('Sorry, no topic matches ' + ` choice `)
def askstr(prompt, default): return stdwin.askstr(prompt, default)