Skip to content

Commit

Permalink
cleanup: backspace, tiny fix on delete
Browse files Browse the repository at this point in the history
  • Loading branch information
ikozyris committed Nov 2, 2024
1 parent 41f959c commit eaf74be
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<gap_buf>::iterator tmpi = it;
std::list<gap_buf>::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;

Expand All @@ -162,7 +162,7 @@ int main(int argc, char *argv[])
break;
if (it->buffer[it->gpe + 1u] == '\n') { // similar to backspace
std::list<gap_buf>::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);
Expand Down

0 comments on commit eaf74be

Please sign in to comment.