From eaf74be0e50dabb92a2549d58745605c816b7faa Mon Sep 17 00:00:00 2001 From: ikozyris <80053394+ikozyris@users.noreply.github.com> Date: Sat, 2 Nov 2024 18:11:51 +0200 Subject: [PATCH] cleanup: backspace, tiny fix on delete --- main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 4e67918..a00c6fe 100755 --- a/main.cpp +++ b/main.cpp @@ -143,17 +143,17 @@ int main(int argc, char *argv[]) } else mvwdelch(text_win, y, x - 1); } else if (y != 0) { // x = 0; merge lines - std::list::iterator tmpi = it; + std::list::iterator curln = it; --it; mv_curs(*it, it->len); // delete \n - eras(*it); - unsigned temp = tmpi->len; - data(*tmpi, 0, temp); - apnd_s(*it, lnbuf, temp); // merge - text.erase(tmpi); // delete actual line + it->gpe = it->cpt - 1; + unsigned tmp = --(it->len); + data(*curln, 0, curln->len); + apnd_s(*it, lnbuf, curln->len); // merge + text.erase(curln); // delete actual line --curnum; print_text(y - 1); - wmove(text_win, y - 1, it->len - temp); + wmove(text_win, y - 1, tmp); } break; @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) break; if (it->buffer[it->gpe + 1u] == '\n') { // similar to backspace std::list::iterator curln = it; // current line - curln->gpe = curln->cpt; // delete newline + curln->gpe = curln->cpt - 1; // delete newline curln->len--; ++it; // next line data(*it, 0, it->len);