- while True:
- to_write = f'{prompt}{self._input_buffer[offset:]}{cursor}'
- len_too_much = len(to_write) - self._width
- if len_too_much <= 0:
- break
- offset += len_too_much
- prompt = f'<{offset}|{prompt_template}…'
- self._write(to_write[:-1], self._y, padding=False)
- self._write(to_write[-1], attribute='reverse', padding=False)
- self._write()
+ if len(to_write) > self._width and self._cursor_x > half_width:
+ prompt = f'{PROMPT_TEMPLATE}{PROMPT_ELL_IN}'
+ if self._cursor_x > len(content) - half_width:
+ offset = len(content) - self._width + len(prompt)
+ else:
+ offset = self._cursor_x - half_width + len(prompt) // 2
+ cursor_x_to_write = len(prompt) - 1 + self._cursor_x - offset
+ to_write = f'{prompt}{content[offset:]}'
+ if len(to_write) > self._width:
+ to_write = (to_write[:self._width - len(PROMPT_ELL_OUT)]
+ + PROMPT_ELL_OUT)
+ self._write(to_write[:cursor_x_to_write], self._y, padding=False)
+ self._write(to_write[cursor_x_to_write], attribute='reverse',
+ padding=False)
+ self._write(to_write[cursor_x_to_write + 1:])