@@ -30,10 +30,13 @@ pub enum IrcFormatEvent<'a> {
30
30
bg : Option < Color > ,
31
31
} ,
32
32
33
- /// Reverse current background and foreground
33
+ /// Reverse current background and foreground colors.
34
34
ReverseColor ,
35
35
36
- /// Reset formatting to the default
36
+ /// Reset background and foreground colors to the defaults.
37
+ ResetColors ,
38
+
39
+ /// Reset formatting to the default.
37
40
Reset ,
38
41
}
39
42
@@ -325,12 +328,10 @@ impl<'a> Iterator for FormatEventParser<'a> {
325
328
326
329
CHAR_COLOR => {
327
330
self . bump ( 1 ) ;
328
- match self . parse_color ( ) {
329
- Some ( ( fg, bg) ) => return Some ( IrcFormatEvent :: Color { fg, bg } ) ,
330
- None => {
331
- // Just skip the control char
332
- }
333
- }
331
+ return match self . parse_color ( ) {
332
+ Some ( ( fg, bg) ) => Some ( IrcFormatEvent :: Color { fg, bg } ) ,
333
+ None => Some ( IrcFormatEvent :: ResetColors ) ,
334
+ } ;
334
335
}
335
336
336
337
CHAR_HEX_COLOR => {
@@ -389,6 +390,7 @@ pub fn remove_irc_control_chars(str: &str) -> String {
389
390
| IrcFormatEvent :: Monospace
390
391
| IrcFormatEvent :: Color { .. }
391
392
| IrcFormatEvent :: ReverseColor
393
+ | IrcFormatEvent :: ResetColors
392
394
| IrcFormatEvent :: Reset => { }
393
395
IrcFormatEvent :: Text ( text) => s. push_str ( text) ,
394
396
}
@@ -431,6 +433,7 @@ fn test_parse_text_2() {
431
433
let s = "a\x03 " ;
432
434
let mut parser = parse_irc_formatting ( s) ;
433
435
assert_eq ! ( parser. next( ) , Some ( IrcFormatEvent :: Text ( "a" ) ) ) ;
436
+ assert_eq ! ( parser. next( ) , Some ( IrcFormatEvent :: ResetColors ) ) ;
434
437
assert_eq ! ( parser. next( ) , None ) ;
435
438
}
436
439
@@ -439,6 +442,7 @@ fn test_parse_text_3() {
439
442
let s = "a\x03 b" ;
440
443
let mut parser = parse_irc_formatting ( s) ;
441
444
assert_eq ! ( parser. next( ) , Some ( IrcFormatEvent :: Text ( "a" ) ) ) ;
445
+ assert_eq ! ( parser. next( ) , Some ( IrcFormatEvent :: ResetColors ) ) ;
442
446
assert_eq ! ( parser. next( ) , Some ( IrcFormatEvent :: Text ( "b" ) ) ) ;
443
447
assert_eq ! ( parser. next( ) , None ) ;
444
448
}
@@ -511,6 +515,7 @@ fn test_parse_text_5() {
511
515
512
516
let s = "\x03 ,a" ;
513
517
let mut parser = parse_irc_formatting ( s) ;
518
+ assert_eq ! ( parser. next( ) , Some ( IrcFormatEvent :: ResetColors ) ) ;
514
519
assert_eq ! ( parser. next( ) , Some ( IrcFormatEvent :: Text ( ",a" ) ) ) ;
515
520
assert_eq ! ( parser. next( ) , None ) ;
516
521
}
0 commit comments