1- /// Incrementally convert to wincon calls for non-contiguous data
1+ /// Incrementally convert to styled string fragments for non-contiguous data
22#[ derive( Default , Clone , Debug , PartialEq , Eq ) ]
3- pub ( crate ) struct WinconBytes {
3+ pub ( crate ) struct AnsiBytes {
44 parser : anstyle_parse:: Parser ,
5- capture : WinconCapture ,
5+ capture : AnsiCapture ,
66}
77
8- impl WinconBytes {
8+ impl AnsiBytes {
99 /// Initial state
1010 pub ( crate ) fn new ( ) -> Self {
1111 Default :: default ( )
1212 }
1313
1414 /// Strip the next segment of data
15- pub ( crate ) fn extract_next < ' s > ( & ' s mut self , bytes : & ' s [ u8 ] ) -> WinconBytesIter < ' s > {
15+ pub ( crate ) fn extract_next < ' s > ( & ' s mut self , bytes : & ' s [ u8 ] ) -> AnsiBytesIter < ' s > {
1616 self . capture . reset ( ) ;
1717 self . capture . printable . reserve ( bytes. len ( ) ) ;
18- WinconBytesIter {
18+ AnsiBytesIter {
1919 bytes,
2020 parser : & mut self . parser ,
2121 capture : & mut self . capture ,
2222 }
2323 }
2424}
2525
26- /// See [`WinconBytes `]
26+ /// See [`AnsiBytes `]
2727#[ derive( Debug , PartialEq , Eq ) ]
28- pub ( crate ) struct WinconBytesIter < ' s > {
28+ pub ( crate ) struct AnsiBytesIter < ' s > {
2929 bytes : & ' s [ u8 ] ,
3030 parser : & ' s mut anstyle_parse:: Parser ,
31- capture : & ' s mut WinconCapture ,
31+ capture : & ' s mut AnsiCapture ,
3232}
3333
34- impl Iterator for WinconBytesIter < ' _ > {
34+ impl Iterator for AnsiBytesIter < ' _ > {
3535 type Item = ( anstyle:: Style , String ) ;
3636
3737 #[ inline]
@@ -44,7 +44,7 @@ impl Iterator for WinconBytesIter<'_> {
4444fn next_bytes (
4545 bytes : & mut & [ u8 ] ,
4646 parser : & mut anstyle_parse:: Parser ,
47- capture : & mut WinconCapture ,
47+ capture : & mut AnsiCapture ,
4848) -> Option < ( anstyle:: Style , String ) > {
4949 capture. reset ( ) ;
5050 while capture. ready . is_none ( ) {
@@ -65,19 +65,19 @@ fn next_bytes(
6565}
6666
6767#[ derive( Default , Clone , Debug , PartialEq , Eq ) ]
68- struct WinconCapture {
68+ struct AnsiCapture {
6969 style : anstyle:: Style ,
7070 printable : String ,
7171 ready : Option < anstyle:: Style > ,
7272}
7373
74- impl WinconCapture {
74+ impl AnsiCapture {
7575 fn reset ( & mut self ) {
7676 self . ready = None ;
7777 }
7878}
7979
80- impl anstyle_parse:: Perform for WinconCapture {
80+ impl anstyle_parse:: Perform for AnsiCapture {
8181 /// Draw a character to the screen and update states.
8282 fn print ( & mut self , c : char ) {
8383 self . printable . push ( c) ;
@@ -309,7 +309,7 @@ mod test {
309309 . into_iter ( )
310310 . map ( |( style, value) | ( style, value. to_owned ( ) ) )
311311 . collect :: < Vec < _ > > ( ) ;
312- let mut state = WinconBytes :: new ( ) ;
312+ let mut state = AnsiBytes :: new ( ) ;
313313 let actual = state. extract_next ( input. as_bytes ( ) ) . collect :: < Vec < _ > > ( ) ;
314314 assert_eq ! ( expected, actual, "{input:?}" ) ;
315315 }
@@ -370,7 +370,7 @@ mod test {
370370 } else {
371371 vec![ ( anstyle:: Style :: default ( ) , s. clone( ) ) ]
372372 } ;
373- let mut state = WinconBytes :: new( ) ;
373+ let mut state = AnsiBytes :: new( ) ;
374374 let actual = state. extract_next( s. as_bytes( ) ) . collect:: <Vec <_>>( ) ;
375375 assert_eq!( expected, actual) ;
376376 }
0 commit comments