chiark / gitweb /
push_para
authorSimon Tatham <anakin@pobox.com>
Mon, 25 Dec 2023 15:56:08 +0000 (15:56 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 25 Dec 2023 15:56:08 +0000 (15:56 +0000)
src/text.rs

index 20e7399fb14c240ecbb675b59e020dfaae4ee304..6cbcf3ed1c608093bbc5d92e7fd8563a2daa0335 100644 (file)
@@ -240,6 +240,20 @@ impl Paragraph {
         self
     }
 
+    pub fn push_para(mut self, para: &Paragraph) -> Self {
+        let tail = if let Some(last_existing_word) = self.words.last_mut() {
+            if let Some(first_new_word) = para.words.first() {
+                if last_existing_word.is_space() ==
+                    first_new_word.is_space() {
+                    last_existing_word.push_str(&first_new_word.slice());
+                    1
+                } else { 0 }
+            } else { 0 }
+        } else { 0 };
+        self.words.extend_from_slice(&para.words[tail..]);
+        self
+    }
+
     pub fn into_box(self) -> Box<dyn TextFragment> { Box::new(self) }
 }
 
@@ -474,3 +488,12 @@ fn test_fileheader() {
         });
 }
 
+// TODO:
+// ExtendableIndicator at file header (with an 'active' flag)
+// InReplyToLine, with first line of included paragraph
+// NotificationLog, also with included toot
+// UserListEntry
+// Media
+// FileStatusLine, with priorities
+// MenuKeypressLine
+// And, of course, the HTML parsing