sled

Једноставни уређивач текста
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување a74f8ecb72d1d269db94b48cb7a8120558514704
родитељ 021fe0f7a633c38fba3bdfe0a1450ab9e96fc513
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sat, 16 Apr 2022 18:03:17 +0200

Fix: wrapping logic under specific conditions (typing in the middle of a long line)

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
Msled.1.in | 3+--
Msled.c | 19++++++++-----------
измењених датотека: 2, додавања: 9(+), брисања: 13(-)

diff --git a/sled.1.in b/sled.1.in @@ -98,8 +98,7 @@ _ \fCBackspace\fP@Erase character before cursor \fCC-\\\fP@Switch between command and insert mode \fCC-C\fP@Yank to paste buffer -\fCC-D\fP@Erase character under cursor -\fCDelete\fP@Erase character under cursor +\fCDelete\fP or \fCC-D\fP@Erase character under cursor \fCEnd\fP or \fCC-E\fP@Go to end of line \fCInsert\fP@Toggle overwrite \fCPgDown\fP or \fCC-F\fP@Go to next page diff --git a/sled.c b/sled.c @@ -236,7 +236,7 @@ handle_key_event(struct tb_event* ev, struct DrawState* state) if (state->prompt_callback) state->prompt_callback(state, ev); CLEAR(state->mode, M_PROMPT); - *state->prompt = 0; + *state->prompt = 0; } else if (ev->key == TB_KEY_ESC) cancel_close(state); @@ -417,10 +417,8 @@ insert_char(struct DrawState* state, uint32_t ch) while (state->display_column >= WRAP_WIDTH) { int saved_column = state->coord.col; - int distance_to_eol; buffer_line = state->buffer + state->coord.row; - distance_to_eol = buffer_line->length - saved_column; - state->coord.col = WRAP_WIDTH + 1; + state->coord.col = WRAP_WIDTH; while (state->coord.col > 0 && !u32_is_word_boundary(buffer_line->text[state->coord.col - 1], @@ -434,8 +432,7 @@ insert_char(struct DrawState* state, uint32_t ch) simple_insert_line(state); state->saved_column = -1; position_to(state, state->coord.row + 1, - state->buffer[state->coord.row + 1].length - - distance_to_eol); + saved_column - state->coord.col); } #endif /* ENABLE_WRAP */ @@ -846,8 +843,8 @@ cancel_close(struct DrawState* state) } else { - *state->error = 0; - *state->prompt = 0; + *state->error = 0; + *state->prompt = 0; CLEAR(state->mode, M_PROMPT | M_HELP); } @@ -1657,8 +1654,8 @@ show_go_to_line(struct DrawState* state) } } SET(state->mode, M_INPUT | M_INPUT_NUM); - *state->input = 0; - *state->error = 0; + *state->input = 0; + *state->error = 0; input_position_to(state, 0); return 0; } @@ -1700,7 +1697,7 @@ int show_help(struct DrawState* state) { SET(state->mode, M_HELP); - *state->error = 0; + *state->error = 0; return 0; }