чување 4d938d958f348e96ef8898e6926ba4352009ac4d
родитељ dff3284098db0eaca35dab0560be726da73984cb
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Tue, 15 Mar 2022 14:46:09 +0100
sled.c(insert_char): Word boundary for wrapping is only whitespace; move to proper position when typing in the middle of the line, rather than the end of line
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
| M | sled.c | | | 23 | +++++++++++------------ |
измењених датотека: 1, додавања: 11(+), брисања: 12(-)
diff --git a/sled.c b/sled.c
@@ -417,32 +417,31 @@ insert_char(struct DrawState* state, uint32_t ch)
check_wrap:
if (state->display_column >= WRAP_WIDTH)
{
- int saved_column = state->column;
- state->column = WRAP_WIDTH - 1;
+ int saved_column = state->column;
+ int distance_to_eol = buffer_line->length - saved_column;
+ state->column = WRAP_WIDTH - 1;
while (state->column > 0
&& u32_is_word_boundary(buffer_line->text[state->column
- 1],
- 0))
+ 1))
state->column--;
if (state->column == 0)
- {
- state->column = saved_column;
goto skip_insert_line;
- }
while (state->column > 0
&& !u32_is_word_boundary(buffer_line->text[state->column
- 1],
- 0))
+ 1))
state->column--;
if (state->column == 0)
- {
- state->column = saved_column;
goto skip_insert_line;
- }
insert_line(state);
- move_end(state);
+ position_to(state, state->row,
+ state->buffer[state->row].length - distance_to_eol);
+ /* TODO: Line several times longer than WRAP_WIDTH should wrap
+ * at word boundaries */
goto check_wrap;
- skip_insert_line:;
+ skip_insert_line:
+ state->column = saved_column;
}
#endif /* ENABLE_WRAP */