@@ -5,7 +5,7 @@ use std::{
55 } ,
66 cell:: {
77 RefCell ,
8- RefMut ,
8+ RefMut , Ref ,
99 } ,
1010} ;
1111use enum_variant_eq:: {
@@ -470,12 +470,12 @@ mod color_test {
470470/// ```
471471#[ derive( Clone , Debug ) ]
472472pub struct ScreenBuffer {
473- pub colors : RefCell < Vec < Color > > ,
473+ colors : RefCell < Vec < Color > > ,
474474 /// Colors present in the output area
475- pub background_colors : RefCell < Vec < Color > > ,
475+ background_colors : RefCell < Vec < Color > > ,
476476 /// The value of this field should be the color of the last change.
477477 /// Subscript 0 is the background color, and subscript 1 is the foreground color
478- pub prev_color : RefCell < [ Color ; 2 ] > ,
478+ prev_color : RefCell < [ Color ; 2 ] > ,
479479 size : Position ,
480480 /// config
481481 pub cfg : Config ,
@@ -592,6 +592,14 @@ impl ScreenBuffer {
592592 pub fn init_prev_color ( & self ) {
593593 * self . prev_color . borrow_mut ( ) = [ Color :: None ; 2 ] ;
594594 }
595+ /// get prev_color ref
596+ pub fn get_prev_color ( & self ) -> Ref < [ Color ; 2 ] > {
597+ self . prev_color . borrow ( )
598+ }
599+ /// get prev_color mut ref
600+ pub fn get_prev_color_mut ( & self ) -> RefMut < [ Color ; 2 ] > {
601+ self . prev_color . borrow_mut ( )
602+ }
595603 /// 两颜色在此缓冲区是否判定为相似
596604 fn color_similarity ( & self , color1 : & Color , color2 : & Color ) -> bool {
597605 color1. chromatic_aberration ( color2) < self . cfg . chromatic_aberration
0 commit comments