@@ -31,12 +31,13 @@ use torin::{
31
31
use super :: utils:: ElementUtils ;
32
32
use crate :: {
33
33
dom:: DioxusNode ,
34
- prelude:: {
35
- align_highlights_and_cursor_paragraph ,
34
+ prelude:: TextGroupMeasurement ,
35
+ render :: {
36
36
align_main_align_paragraph,
37
- TextGroupMeasurement ,
37
+ create_paragraph,
38
+ draw_cursor,
39
+ draw_cursor_highlights,
38
40
} ,
39
- render:: create_paragraph,
40
41
} ;
41
42
42
43
pub struct ParagraphElement ;
@@ -230,80 +231,3 @@ impl ElementUtils for ParagraphElement {
230
231
area
231
232
}
232
233
}
233
-
234
- fn draw_cursor_highlights (
235
- area : & Area ,
236
- paragraph : & Paragraph ,
237
- canvas : & Canvas ,
238
- node_ref : & DioxusNode ,
239
- ) -> Option < ( ) > {
240
- let node_cursor_state = & * node_ref. get :: < CursorState > ( ) . unwrap ( ) ;
241
-
242
- let highlights = node_cursor_state. highlights . as_ref ( ) ?;
243
- let highlight_color = node_cursor_state. highlight_color ;
244
-
245
- for ( from, to) in highlights. iter ( ) {
246
- let ( from, to) = {
247
- if from < to {
248
- ( from, to)
249
- } else {
250
- ( to, from)
251
- }
252
- } ;
253
- let cursor_rects = paragraph. get_rects_for_range (
254
- * from..* to,
255
- RectHeightStyle :: Tight ,
256
- RectWidthStyle :: Tight ,
257
- ) ;
258
- for cursor_rect in cursor_rects {
259
- let rect = align_highlights_and_cursor_paragraph (
260
- node_ref,
261
- area,
262
- paragraph,
263
- & cursor_rect,
264
- None ,
265
- ) ;
266
-
267
- let mut paint = Paint :: default ( ) ;
268
- paint. set_anti_alias ( true ) ;
269
- paint. set_style ( PaintStyle :: Fill ) ;
270
- paint. set_color ( highlight_color) ;
271
-
272
- canvas. draw_rect ( rect, & paint) ;
273
- }
274
- }
275
-
276
- Some ( ( ) )
277
- }
278
-
279
- fn draw_cursor (
280
- area : & Area ,
281
- paragraph : & Paragraph ,
282
- canvas : & Canvas ,
283
- node_ref : & DioxusNode ,
284
- ) -> Option < ( ) > {
285
- let node_cursor_state = & * node_ref. get :: < CursorState > ( ) . unwrap ( ) ;
286
-
287
- let cursor = node_cursor_state. position ?;
288
- let cursor_color = node_cursor_state. color ;
289
- let cursor_position = cursor as usize ;
290
-
291
- let cursor_rects = paragraph. get_rects_for_range (
292
- cursor_position..cursor_position + 1 ,
293
- RectHeightStyle :: Tight ,
294
- RectWidthStyle :: Tight ,
295
- ) ;
296
- let cursor_rect = cursor_rects. first ( ) ?;
297
-
298
- let rect =
299
- align_highlights_and_cursor_paragraph ( node_ref, area, paragraph, cursor_rect, Some ( 1.0 ) ) ;
300
-
301
- let mut paint = Paint :: default ( ) ;
302
- paint. set_anti_alias ( true ) ;
303
- paint. set_style ( PaintStyle :: Fill ) ;
304
- paint. set_color ( cursor_color) ;
305
-
306
- canvas. draw_rect ( rect, & paint) ;
307
-
308
- Some ( ( ) )
309
- }
0 commit comments