Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def complete(self, tab=False):
if self.paste_mode and self.list_win_visible:
self.scr.touchwin()
if self.paste_mode:
return
if self.list_win_visible and not self.config.auto_display_list:
self.scr.touchwin()
self.list_win_visible = False
return
if self.config.auto_display_list or tab:
self.list_win_visible = Repl.complete(self, tab)
if self.list_win_visible:
try:
self.show_list(self.matches, self.argspec)
except curses.error:
# XXX: This is a massive hack, it will go away when I get
# cusswords into a good enough state that we can start
# using it.
self.list_win.border()
self.list_win.refresh()
self.list_win_visible = False
if not self.list_win_visible:
self.scr.redrawwin()
self.scr.refresh()
def update_completion(self, tab=False):
"""Update autocomplete info; self.matches and self.argspec"""
#TODO do we really have to do something this ugly? Can we rename it?
# this method stolen from bpython.cli
if self.list_win_visible and not self.config.auto_display_list:
self.list_win_visible = False
self.matches_iter.update(self.current_word)
return
if self.config.auto_display_list or tab:
self.list_win_visible = BpythonRepl.complete(self, tab)
def complete(self, tab=False):
"""Get Autocomplete list and window.
Called whenever these should be updated, and called
with tab
"""
if self.paste_mode:
self.scr.touchwin() # TODO necessary?
return
list_win_visible = repl.Repl.complete(self, tab)
if list_win_visible:
try:
self.show_list(
self.matches_iter.matches,
self.arg_pos,
topline=self.funcprops,
formatter=self.matches_iter.completer.format,
)
except curses.error:
# XXX: This is a massive hack, it will go away when I get
# cusswords into a good enough state that we can start
# using it.
self.list_win.border()
self.list_win.refresh()
list_win_visible = False
if not list_win_visible:
def complete(self):
if self.config.auto_display_list:
self.list_win_visible = repl.Repl.complete(self)
if self.list_win_visible:
self.list_win.update_argspec(self.argspec)
self.list_win.update_docstring(self.docstring or '')
self.list_win.update_matches(self.matches)
iter_rect = self.get_iter_location(self.get_cursor_iter())
x, y = self.window.get_origin()
_, height = self.get_line_yrange(self.get_cursor_iter())
self.list_win.move(x + iter_rect.x,
y + iter_rect.y + height)
self.list_win.show()
else:
self.list_win.hide()