def edit_pad(): # {{{1 """ Opens the currently selected note in the __pad__ buffer. """ path = get_selected_path() query=vim.eval('b:pad_query') vim.command("bd") open_pad(path=path, query=query)
def edit_pad(): # {{{1 """ Opens the currently selected note in the __pad__ buffer. """ path = get_selected_path() query = vim.eval('b:pad_query') vim.command("bd") open_pad(path=path, query=query)
def incremental_search(): # {{{1 """ Provides incremental search within the __pad__ buffer. """ query = "" should_create_on_enter = False vim.command("echohl None") vim.command('echo ">> "') while True: raw_char = vim.eval("getchar()") if raw_char in ("13", "27"): if raw_char == "13" and should_create_on_enter: vim.command("bw") open_pad(first_line=query) vim.command("echohl None") vim.command("redraw!") break else: try: # if we can convert to an int, we have a regular key int(raw_char) # we bring up an error on nr2char last_char = vim.eval("nr2char(" + raw_char + ")") query = query + last_char except: # if we don't, we have some special key keycode = unicode(raw_char, errors="ignore") if keycode == "kb": # backspace query = query[:-len(last_char)] vim.command("setlocal modifiable") pad_files = get_filelist(query) if pad_files != []: vim.command("let b:pad_query = '"+query+"'") fill_list(pad_files, query != "") vim.command("setlocal nomodifiable") info = "" vim.command("echohl None") should_create_on_enter = False else: # we will create a new pad del vim.current.buffer[:] info = "[NEW] " vim.command("echohl WarningMsg") should_create_on_enter = True vim.command("redraw") vim.command('echo ">> ' + info + query + '"')
def incremental_search(): # {{{1 """ Provides incremental search within the __pad__ buffer. """ query = "" should_create_on_enter = False vim.command("echohl None") vim.command('echo ">> "') while True: raw_char = vim.eval("getchar()") if raw_char in ("13", "27"): if raw_char == "13" and should_create_on_enter: vim.command("bw") open_pad(first_line=query) vim.command("echohl None") vim.command("redraw!") break else: try: # if we can convert to an int, we have a regular key int(raw_char) # we bring up an error on nr2char last_char = vim.eval("nr2char(" + raw_char + ")") query = query + last_char except: # if we don't, we have some special key keycode = unicode(raw_char, errors="ignore") if keycode == "kb": # backspace query = query[:-len(last_char)] vim.command("setlocal modifiable") pad_files = get_filelist(query) if pad_files != []: vim.command("let b:pad_query = '" + query + "'") fill_list(pad_files, query != "") vim.command("setlocal nomodifiable") info = "" vim.command("echohl None") should_create_on_enter = False else: # we will create a new pad del vim.current.buffer[:] info = "[NEW] " vim.command("echohl WarningMsg") should_create_on_enter = True vim.command("redraw") vim.command('echo ">> ' + info + query + '"')