def command(): c = lisp.completing_read("Enter command:",["update","reload","complete"]) lisp.message(str(c)) if c=="update" or c=="reload": update_state() elif c=="complete": complete_type()
def read_language(): """Reads a paste language from minibuffer. Provides completion based on the list ov available languages""" # guess language from major mode major_mode = lisp.major_mode.value().text def_language = major_mode[:-5] if def_language not in languages(): def_language = 'text' msg = 'Language of paste snippet (%s): ' % def_language language = (lisp.completing_read(msg, languages()).strip() or def_language) return language
def read_language(): """Reads a paste language from minibuffer. Provides completion based on the list ov available languages""" # guess language from major mode major_mode = lisp.major_mode.value().text def_language = major_mode[:-5] if def_language not in languages(): def_language = 'text' msg = 'Language of paste snippet ({0}): '.format(def_language) language = (lisp.completing_read(msg, languages()).strip() or def_language) return language
def complete_type(): """ UI attempt to grab completions for a class """ c = lisp.completing_read("Type to complete:",cpp.CppObject.classes) lisp.message("Looking for:"+str(c)) try: t = cpp.CppObject.getByName(c) completions = t.getChildrenByWeakName("") lisp.pos_tip_show(make_help_message(completions),None,None,None,0) except: lisp.message("Couldn't find class "+c)
def read_from_minibuffer(): """Reads a license name from minibuffer. It supports completion with both upper and lower case names. """ prompt = "Enter a license (default %s): " % DEFAULT return (lisp.completing_read(prompt, license_names) or DEFAULT).upper()
def autocomplete_list(prompt, listy): """Presents the user with a minibuffer prompt and the given auto-completion list.""" completion_list = make_symbol_list(listy) return lisp.completing_read(prompt, completion_list)
# Test if the test file name exists if os.path.exists(testfilename) and False: lisp.message("Test %s already exists" % testfilename) else: # Find the snippets that starts with test_ and finish by _create.py snippetdirnames = utils.get_snippet_dir_names() tests = [] for snippetdirname in snippetdirnames: tests += [t for t in os.listdir(snippetdirname)] tests = filter(lambda x: x.startswith("test_") and x.endswith("_create.py"), tests) tests = map(lambda x:x[5:-10], tests) # Ask for the kind of test to create testtypename = lisp.completing_read("What kind of test do you want to create ?", tests) if testtypename == None or len(testtypename) == 0: testtypename = "simple" # Create the test filename f = open(testfilename, "w") # Find the variable names module = module_name shortmodule = module_name.split(".")[-1] testclassname = "".join(map(lambda x: x.capitalize(), module_name.split("."))) class_names = utils.find_class_names(filename) if len(class_names) != 1: # Ask for the kind of test to create
else: # Find the snippets that starts with test_ and finish by _create.py snippetdirnames = utils.get_snippet_dir_names() tests = [] # raise Exception(str(snippetdirnames)) for snippetdirname in snippetdirnames: tests += [t for t in os.listdir(snippetdirname)] tests = filter(lambda x: x.startswith("test_") and x.endswith("_create"), tests) tests = map(lambda x: x[5:-7], tests) # Ask for the kind of test to create testtypename = lisp.completing_read( "What kind of test do you want to create ?", tests) if testtypename == None or len(testtypename) == 0: testtypename = "simple" # Create the test filename f = open(testfilename, "w") # Find the variable names module = module_name shortmodule = module_name.split(".")[-1] testclassname = "".join( map(lambda x: x.capitalize(), module_name.split("."))) class_names = utils.find_class_names(filename) if len(class_names) != 1: