aboutsummaryrefslogtreecommitdiff
path: root/src/frame.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2017-03-27 08:22:17 +0200
committerThomas White <taw@bitwiz.org.uk>2017-03-27 08:22:17 +0200
commit3413239509a9a00d89199f8aa661504f43dcf585 (patch)
tree648b236b56c28d35ad9f24d45efe71fd9a8f2e97 /src/frame.c
parent4b0854d62b4b4e7ce0c721a6f9f43df595aacd72 (diff)
Delete selected text
Diffstat (limited to 'src/frame.c')
-rw-r--r--src/frame.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/frame.c b/src/frame.c
index 866ae31..d69f0fb 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -886,7 +886,48 @@ void insert_text_in_paragraph(Paragraph *para, size_t offs, const char *t)
}
-void delete_text_in_paragraph(Paragraph *para, size_t offs1, size_t offs2)
+static void delete_paragraph(struct frame *fr, int p)
+{
+}
+
+
+void delete_text_from_frame(struct frame *fr, struct edit_pos p1, struct edit_pos p2,
+ double wrapw)
+{
+ int i;
+
+ for ( i=p1.para; i<=p2.para; i++ ) {
+
+ size_t start;
+ ssize_t finis;
+
+ Paragraph *para = fr->paras[i];
+
+ if ( i == p1.para ) {
+ start = pos_trail_to_offset(para, p1.pos, p1.trail);
+ } else {
+ start = 0;
+ }
+
+ if ( i == p2.para ) {
+ finis = pos_trail_to_offset(para, p2.pos, p2.trail);
+ } else {
+ finis = -1;
+ }
+
+ if ( (start == 0) && (finis == -1) ) {
+ delete_paragraph(fr, para);
+ } else {
+ delete_text_in_paragraph(para, start, finis);
+ wrap_paragraph(para, NULL, wrapw, 0, 0);
+ }
+
+ }
+}
+
+
+/* offs2 negative means "to end" */
+void delete_text_in_paragraph(Paragraph *para, size_t offs1, ssize_t offs2)
{
int nrun1, nrun2, nrun;
int i;