def _vim_getkey(self, timeout=0): def getchar(): if self.enableCursor: key = vim.eval("getchar(0)") else: key = vim.eval("getchar()") try: key = int(key) if key > 0 and key < 256: key = chr(key) elif key > 255: key = u"%c" % key key = key.encode("utf-8") except: pass return key ioutil.CScreen().showPrompt(self._buildPrompt()) if self.enableCursor and timeout > 0: count = 0 tmnow = time.time() tmend = tmnow + timeout tm = tmnow key = getchar() while key == 0: progress = int((tm - int(tm)) * 100) self._drawFilterCursor(progress >= 50) self._drawBackgroundTask(progress / 25) time.sleep(0.05) key = getchar() tm = time.time() if tm > tmend or tm < tmnow: break return key return getchar()
def process(self): ioutil.CheckColorScheme() nch = self.displayLabels() line = 0 enc = vim.eval("&encoding") while nch > 0: ch = ioutil.CScreen().getkey() ch = ch.decode(enc, "replace") if ch == self.wchar: self.stripPos = (self.stripPos + 1) % 3 vim.command("redraw!") self.displayLabels() elif self.chars.find(ch) >= 0: line = line * len(self.chars) + self.chars.find(ch) nch -= 1 else: line = -1 break if line >= 0: line = line * self.groupLines + self.groupLines / 2 if line > vim.current.window.height: line = vim.current.window.height if line < 0: line = 0 cy, cx = vim.current.window.wcursor dy = line - cy if dy > 0: vim.command("norm %s" % ("gj" * dy)) elif dy < 0: vim.command("norm %s" % ("gk" * -dy)) vim.command("redraw!")
def hide(self): if self.wcontent != None: w = self.wcontent self.wcontent = None w.clear() w.refresh() del w if self.window != None: w = self.window self.window = None w.clear() w.refresh() del w ioutil.CScreen().refresh() vim.command("redraw!")
def _vim_getkey(self, timeout=0): def getchar(): # (7.2.320) getchar(0) blocks in console when Esc is pressed; it is unblocked with next keypress key = vim.eval("getchar()") try: key = int(key) if key > 0 and key < 256: key = chr(key) elif key > 255: key = u"%c" % key key = key.encode("utf-8") except: pass return key # TODO: Capture mouse position # Useless... v:mouse_lnum contains text line number, not screen line number # ( variables added with pathch 7.0.155, eval.c, vim.h ) # print vim.eval('v:mouse_win . " " . v:mouse_lnum . " " . v:mouse_col') # self.lastclick = (screen.mousex - self.left, screen.mousey - self.top) # print self.lastclick ioutil.CScreen().showPrompt(self._buildPrompt()) return getchar()
def process(self): ioutil.CheckColorScheme() nch = self.displayLabels() iwin = 0 enc = vim.eval("&encoding") while nch > 0: ch = ioutil.CScreen().getkey() ch = ch.decode(enc, "replace") if ch == self.wchar: self.stripPos = (self.stripPos + 1) % 3 vim.command("redraw!") self.displayLabels() elif self.chars.find(ch) >= 0: iwin = iwin * len(self.chars) + self.chars.find(ch) nch -= 1 else: iwin = -1 break if iwin >= 0: if iwin >= len(vim.windows): iwin = len(vim.windows) vim.command("exe \"%dwincmd w\"" % (iwin + 1)) vim.command("redraw!")
def _prepareScreen(self): scr = ioutil.CScreen() scr.clear() scr.showPrompt("") scr.refresh() vim.command("redraw!")