Temporarily inserts newlines to the text if the wrap option is enabled.
(textobj)
| 35 | |
| 36 | @contextlib.contextmanager |
| 37 | def _wrap_text(textobj): |
| 38 | """Temporarily inserts newlines to the text if the wrap option is enabled. |
| 39 | """ |
| 40 | if textobj.get_wrap(): |
| 41 | old_text = textobj.get_text() |
| 42 | try: |
| 43 | textobj.set_text(textobj._get_wrapped_text()) |
| 44 | yield textobj |
| 45 | finally: |
| 46 | textobj.set_text(old_text) |
| 47 | else: |
| 48 | yield textobj |
| 49 | |
| 50 | |
| 51 | # Extracted from Text's method to serve as a function |
no test coverage detected