[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] knots: make current line knotted when deleting a knotted lin
From: |
Benno Schulenberg |
Subject: |
[PATCH 3/3] knots: make current line knotted when deleting a knotted line or region |
Date: |
Thu, 2 Apr 2020 11:03:29 +0200 |
Whenever two lines are joined, a line is deleted, or a region is deleted,
and any of the affected lines was knotted, then the line where the cursor
ends up after the operation becomes knotted. Thus a knot, once placed,
stays around until it is explicitly removed (or the buffer is closed).
Also, a knot does not travel into the cutbuffer, and will thus not be
pasted and duplicated elsewhere.
---
src/cut.c | 13 +++++++++++++
src/text.c | 1 +
2 files changed, 14 insertions(+)
diff --git a/src/cut.c b/src/cut.c
index 6c80e081..94cb61b4 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -87,6 +87,8 @@ void do_deletion(undo_type action)
openfile->mark = openfile->current;
openfile->mark_x += openfile->current_x;
}
+
+ openfile->current->knotted |= joining->knotted;
#endif
unlink_node(joining);
renumber_from(openfile->current);
@@ -249,9 +251,15 @@ void extract_segment(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_
(openfile->mark != top ||
openfile->mark_x >= top_x) &&
(openfile->mark != bot ||
openfile->mark_x <= bot_x));
bool same_line = (openfile->mark == top);
+ bool was_knotted = top->knotted;
if (top == bot && top_x == bot_x)
return;
+
+ if (top != bot) {
+ for (linestruct *line = top->next; line != bot->next; line =
line->next)
+ was_knotted |= line->knotted;
+ }
#endif
/* Reduce the buffer to cover just the text that needs to be extracted.
*/
@@ -302,6 +310,8 @@ void extract_segment(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_
} else if (same_line)
/* Update the pointer to this partially cut line. */
openfile->mark = openfile->current;
+
+ openfile->current->knotted = was_knotted;
#endif
/* Glue the texts before and after the extraction together. */
@@ -331,6 +341,7 @@ void ingraft_buffer(linestruct *topline)
/* Remember whether mark and cursor are on the same line, and their
order. */
bool right_side_up = (openfile->mark && mark_is_before_cursor());
bool same_line = (openfile->mark == openfile->current);
+ bool was_knotted = openfile->current->knotted;
#endif
size_t was_x = openfile->current_x;
@@ -364,6 +375,8 @@ void ingraft_buffer(linestruct *topline)
} else
openfile->mark = openfile->filetop;
}
+
+ openfile->filetop->knotted = was_knotted;
#endif
/* Add the number of characters in the copied text to the file size. */
diff --git a/src/text.c b/src/text.c
index 33013146..c334bbee 100644
--- a/src/text.c
+++ b/src/text.c
@@ -576,6 +576,7 @@ void do_undo(void)
line->data = charealloc(line->data, strlen(line->data) +
strlen(&u->strdata[u->tail_x]) + 1);
strcat(line->data, &u->strdata[u->tail_x]);
+ line->knotted |= line->next->knotted;
unlink_node(line->next);
renumber_from(line);
goto_line_posx(u->head_lineno, u->head_x);
--
2.25.2
- [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, (continued)
- [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, Benno Schulenberg, 2020/04/02
- Re: [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, Marco Diego Aurélio Mesquita, 2020/04/03
- Re: [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, Benno Schulenberg, 2020/04/05
- Message not available
- Fwd: [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, Marco Diego Aurélio Mesquita, 2020/04/05
- Re: Fwd: [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, Benno Schulenberg, 2020/04/05
- Re: Fwd: [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, Marco Diego Aurélio Mesquita, 2020/04/05
- Re: Fwd: [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, Benno Schulenberg, 2020/04/06
- Re: Fwd: [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, Brand Huntsman, 2020/04/05
- Re: Fwd: [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, Benno Schulenberg, 2020/04/06
- Re: Fwd: [PATCH 2/3] new feature: "knots" -- a kind of bookmarks, that can be cycled through, Brand Huntsman, 2020/04/06
[PATCH 3/3] knots: make current line knotted when deleting a knotted line or region,
Benno Schulenberg <=