@@ -411,12 +411,22 @@ impl<'a> ToastWidget<'a> {
411411 }
412412
413413 if x < buf. area . width {
414- buf. set_string ( x, y, "|" , Style :: default ( ) . fg ( faded_color) . bg ( self . colors . surface_alt ) ) ;
414+ buf. set_string (
415+ x,
416+ y,
417+ "|" ,
418+ Style :: default ( ) . fg ( faded_color) . bg ( self . colors . surface_alt ) ,
419+ ) ;
415420 }
416421
417422 let icon_x = x + 2 ;
418423 if icon_x + 3 < buf. area . width {
419- buf. set_string ( icon_x, y, icon, Style :: default ( ) . fg ( faded_color) . bg ( self . colors . surface_alt ) ) ;
424+ buf. set_string (
425+ icon_x,
426+ y,
427+ icon,
428+ Style :: default ( ) . fg ( faded_color) . bg ( self . colors . surface_alt ) ,
429+ ) ;
420430 }
421431
422432 let msg_x = x + 6 ;
@@ -431,12 +441,22 @@ impl<'a> ToastWidget<'a> {
431441 } else {
432442 toast. message . clone ( )
433443 } ;
434- buf. set_string ( msg_x, y, & message, Style :: default ( ) . fg ( faded_text) . bg ( self . colors . surface_alt ) ) ;
444+ buf. set_string (
445+ msg_x,
446+ y,
447+ & message,
448+ Style :: default ( ) . fg ( faded_text) . bg ( self . colors . surface_alt ) ,
449+ ) ;
435450 }
436451
437452 let right_x = x + width. saturating_sub ( 1 ) ;
438453 if right_x < buf. area . width {
439- buf. set_string ( right_x, y, "|" , Style :: default ( ) . fg ( faded_color) . bg ( self . colors . surface_alt ) ) ;
454+ buf. set_string (
455+ right_x,
456+ y,
457+ "|" ,
458+ Style :: default ( ) . fg ( faded_color) . bg ( self . colors . surface_alt ) ,
459+ ) ;
440460 }
441461 }
442462}
@@ -505,6 +525,77 @@ fn lerp(start: f32, end: f32, t: f32) -> f32 {
505525 start + ( end - start) * t
506526}
507527
528+ // ============================================================
529+ // WIDGET IMPL FOR TOAST (standalone rendering)
530+ // ============================================================
531+
532+ impl Widget for & Toast {
533+ fn render ( self , area : Rect , buf : & mut Buffer ) {
534+ if area. width < 5 || area. height < 1 {
535+ return ;
536+ }
537+
538+ let scheme = ColorScheme :: default ( ) ;
539+ let color = self . level . color ( & scheme) ;
540+ let icon = self . level . icon ( ) ;
541+
542+ // Render: | [icon] message |
543+ let mut x = area. x ;
544+
545+ // Left border
546+ if x < area. right ( ) {
547+ buf. set_string ( x, area. y , "|" , Style :: default ( ) . fg ( color) ) ;
548+ x += 1 ;
549+ }
550+
551+ // Space
552+ if x < area. right ( ) {
553+ buf. set_string ( x, area. y , " " , Style :: default ( ) ) ;
554+ x += 1 ;
555+ }
556+
557+ // Icon
558+ let icon_len = icon. len ( ) as u16 ;
559+ if x + icon_len <= area. right ( ) {
560+ buf. set_string ( x, area. y , icon, Style :: default ( ) . fg ( color) ) ;
561+ x += icon_len;
562+ }
563+
564+ // Space
565+ if x < area. right ( ) {
566+ buf. set_string ( x, area. y , " " , Style :: default ( ) ) ;
567+ x += 1 ;
568+ }
569+
570+ // Message (truncated if needed)
571+ let remaining_width = area. right ( ) . saturating_sub ( x + 2 ) as usize ; // -2 for " |" at end
572+ if remaining_width > 0 {
573+ let msg = if self . message . len ( ) > remaining_width {
574+ if remaining_width > 3 {
575+ format ! ( "{}..." , & self . message[ ..remaining_width - 3 ] )
576+ } else {
577+ self . message . chars ( ) . take ( remaining_width) . collect ( )
578+ }
579+ } else {
580+ self . message . clone ( )
581+ } ;
582+ buf. set_string ( x, area. y , & msg, Style :: default ( ) . fg ( scheme. text ) ) ;
583+ x += msg. len ( ) as u16 ;
584+ }
585+
586+ // Padding to right border
587+ while x < area. right ( ) . saturating_sub ( 1 ) {
588+ buf. set_string ( x, area. y , " " , Style :: default ( ) ) ;
589+ x += 1 ;
590+ }
591+
592+ // Right border
593+ if x < area. right ( ) {
594+ buf. set_string ( x, area. y , "|" , Style :: default ( ) . fg ( color) ) ;
595+ }
596+ }
597+ }
598+
508599#[ cfg( test) ]
509600mod tests {
510601 use super :: * ;
0 commit comments