| 269 | } |
| 270 | |
| 271 | pub fn update_content(&mut self, content: &str) -> Result<String> { |
| 272 | let old_blocks = mem::take(&mut self.blocks); |
| 273 | let (nodes, strcts, folds, any_changed) = self.content.process(content, old_blocks)?; |
| 274 | |
| 275 | self.strcts = strcts; |
| 276 | self.blocks = nodes; |
| 277 | |
| 278 | let ret = RedrawState { |
| 279 | should_redraw: any_changed, |
| 280 | update_folding: Some(folds), |
| 281 | }; |
| 282 | |
| 283 | Ok(json::to_string(&ret)) |
| 284 | } |
| 285 | |
| 286 | pub fn set_folds(&mut self, folds: &str) -> Result<usize> { |
| 287 | let folds: Folds = json::from_str(folds).unwrap(); |