sled

Једноставни уређивач текста
git clone https://git.sr.ht/~strahinja/sled
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 8c685a78a18c96a68d360569c54703bf5647f924
родитељ fddfc84494f22d245c1a23b2f67bb2bbe05a4dfe
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sat,  8 Jun 2024 14:12:51 +0200

Bugfix: cursor "spilling" into status line after paste when on last line

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

diff --git a/TODO b/TODO @@ -3,7 +3,8 @@ TODO [ ] *str*cpy -> memccpy? -[ ] Bugfix: cursor after paste when on last line +[~] Bugfix: cursor after paste when on last line + - [ ] Bugfix: copy copies the whole line to paste buffer [x] Bugfix: sled /; sled /etc; report "No such file or directory" diff --git a/sled.c b/sled.c @@ -1859,6 +1859,7 @@ paste_from_paste(struct DrawState* state) struct BufferLine* newbuf = NULL; uint32_t* rest = NULL; size_t rest_size = 0; + struct Coord newpos; if (!state->paste_count) return 0; @@ -1904,12 +1905,14 @@ paste_from_paste(struct DrawState* state) u32_strncpy(newtext, line->text, state->coord.col + 1); u32_strncat(newtext, state->paste[0].text, newsize); + assign_coord(&newpos, state->coord); + if (state->paste_count == 1) { u32_strncat(newtext, line->text + state->coord.col, newsize); line->length = u32_strncpy(line->text, newtext, newsize); line->size = newsize; - state->coord.col += state->paste[state->paste_count - 1].length; + newpos.col += state->paste[state->paste_count - 1].length; } else { @@ -1964,11 +1967,11 @@ paste_from_paste(struct DrawState* state) U32_SAFE_COPY(line->text, ptext, line->size, newtext, newsize, paste_from_paste_cleanup); line->length = u32_strlen(line->text); - state->coord.col = state->paste[state->paste_count - 1].length; - state->coord.row += state->paste_count - 1; + newpos.col = state->paste[state->paste_count - 1].length; + newpos.row += state->paste_count - 1; } - position_to(state, state->coord.row, state->coord.col); + position_to(state, newpos.row, newpos.col); state->dirty = 1; paste_from_paste_cleanup: