MCPcopy Index your code
hub / github.com/bpython/bpython / cw

Method cw

bpython/urwid.py:709–732  ·  view source on GitHub ↗

Return the current word (incomplete word left of cursor).

(self)

Source from the content-addressed store, hash-verified

707 )
708
709 def cw(self):
710 """Return the current word (incomplete word left of cursor)."""
711 if self.edit is None:
712 return
713
714 pos = self.edit.edit_pos
715 text = self.edit.get_edit_text()
716 if pos != len(text):
717 # Disable autocomplete if not at end of line, like cli does.
718 return
719
720 # Stolen from cli. TODO: clean up and split out.
721 if not text or (not text[-1].isalnum() and text[-1] not in (".", "_")):
722 return
723
724 # Seek backwards in text for the first non-identifier char:
725 for i, c in enumerate(reversed(text)):
726 if not c.isalnum() and c not in (".", "_"):
727 break
728 else:
729 # No non-identifiers, return everything.
730 return text
731 # Return everything to the right of the non-identifier.
732 return text[-i:]
733
734 @property
735 def cpos(self):

Callers 1

tabMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected