1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
///this mod public use is for you to understand the ansi escape codes:)
pub mod colors;
use std::fmt;
use crate::colors::*;
#[derive(Clone)]
///This struct is the main way to utilize the coloring sceme in this crate.
///
///
///This struct contains a number of parameters inquiring to the strings state, such as
///style,color,base string, reset actions, background and several internal things.
///this structs, as it say's below implements the fmt::Display trait, that means that you will not
///need to do anything special in order to print after you have changed the color
///you can use only one color but you can have even all the styles together!
///
///here is a blue,bold,underlined and blinking string example(just a fromatted output) :
///```
///use ansi_colors::*;
///let mut str1 = ColouredStr::new("hello world");
///str1.blue();
///str1.bold();
///str1.underline();
///str1.blink();
///let str2 = format!("{}{}{}","\u{1b}[1;4;5;49;34m","hello world","\u{1b}[0m");
///assert_eq!(str1.coloured_string,str2);
///```
///here is a white,bold and hidden string example(good for passwords):
///
///
///```
///use ansi_colors::*;
///let mut str1 = ColouredStr::new("hello world");
///str1.white();
///str1.bold();
///str1.hidden();
///let str2 = format!("{}{}{}","\u{1b}[1;8;49;97m","hello world","\u{1b}[0m");
///assert_eq!(str1.coloured_string,str2);
pub struct ColouredStr<'a>{
    pub string:&'a str,
    pub coloured_string:String,
    colorer:String,
    closer:String,
    resets:Vec<Reset>,
    text_color:TextColours,
    background_color:BackColours,
    styles:Vec<Styles>,
}
impl <'a> fmt::Display for ColouredStr<'a> {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self.coloured_string)
    }
}
/*
impl <'a> Deref for ColouredStr<'a> {
    type Target = ColouredStr<'a>;
    fn deref(&self) -> &Self::Target{
        let col1 = ColouredStr{string:self.string,
        coloured_string:self.coloured_string,
        colorer:self.colorer,
        closer:self.closer,
        reset:self.reset,
        text_color:self.text_color,
        background_color:self.background_color,
        styles:self.styles};
        &col1
    }
}*/
impl <'a> ColouredStr<'a> {
    ///This functions recieves one parameter - a string and creates a defult struct for it.
    ///the color is natural(no change), as well as the styles and background.
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let str1 = ColouredStr::new("hello world");
    ///assert_eq!(str1.string,"hello world");
    ///```
    pub fn new(string:&str)->ColouredStr{
        let colorer = format!("{}{}",OPENING_COLOR,COLOR_CLOSER);
        let closer = format!("{}{}{}",OPENING_COLOR,"0",COLOR_CLOSER);
        let styles = vec![];
        let resets = vec![Reset::All];
        let coloured_string = format!("{}{}{}",&colorer[..],string,&closer[..]);
        let col1 = ColouredStr{
            string,coloured_string,colorer,closer,resets,text_color:TextColours::White,background_color:BackColours::NaN,styles
        };
        return col1;
    }
    fn refresh(&mut self){
        let clo1 = &(self.set_closer())[..];
        let col1 = &(self.set_colorer())[..];
        let strr = self.string;
        (*self).coloured_string = format!("{}{}{}",col1,strr,clo1);
}
    fn set_colorer(&self)->String{
        let mut tc = "".to_string();
        if (self.text_color as u8) != 0{
            tc = (self.text_color as u8).to_string();
        }
        let mut bc = "".to_string();
        if (self.background_color as u8) != 0{
            bc = (self.background_color as u8).to_string();
        }
        let mut strrr = "".to_string();
        if self.styles.len()>1{
            for i in 0..self.styles.len(){
                strrr.push_str(&(self.styles[i] as u8).to_string()[..]);
                strrr.push(';');
            }
        }else if self.styles.len()==1{
            strrr = format!("{};",&(self.styles[0] as u8).to_string()[..]);
        }
        return format!("{}{}{};{}{}",OPENING_COLOR,&strrr[..],&bc[..],&tc[..],COLOR_CLOSER);
    }
    fn set_closer(&mut self)->String {
        let mut res = "".to_string();
        if self.resets[0]==Reset::All && self.resets.len()>1{
            self.resets = self.resets[1..].to_vec();
        }
        if self.resets.len()>1{
            for i in 0..self.resets.len(){
                res.push_str(&(self.resets[i] as u8).to_string()[..]);
                res.push(';');
            }
        }else if self.resets.len()==1{
            res = format!("{}",&(self.resets[0] as u8).to_string()[..]);
        }
        return format!("{}{}{}",OPENING_COLOR,&res[..],COLOR_CLOSER);
    }
    ///This functions takes self and changes coloured string color into blue
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.blue();
    ///let str2 = format!("{}{}{}","\u{1b}[49;34m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn blue(&mut self){
        self.text_color = TextColours::Blue; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into black
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.black();
    ///let str2 = format!("{}{}{}","\u{1b}[49;30m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn black(&mut self){
        self.text_color = TextColours::Black;
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into red
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.red();
    ///let str2 = format!("{}{}{}","\u{1b}[49;31m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn red(&mut self){
        self.text_color = TextColours::Red; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into green
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.green();
    ///let str2 = format!("{}{}{}","\u{1b}[49;32m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn green(&mut self){
        self.text_color = TextColours::Green; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into yellow
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.yellow();
    ///let str2 = format!("{}{}{}","\u{1b}[49;33m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn yellow(&mut self){
        self.text_color = TextColours::Yellow; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into magenta
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.magenta();
    ///let str2 = format!("{}{}{}","\u{1b}[49;35m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn magenta(&mut self){
        self.text_color = TextColours::Magenta; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into cyan
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.cyan();
    ///let str2 = format!("{}{}{}","\u{1b}[49;36m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn cyan(&mut self){
        self.text_color = TextColours::Cyan; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into gray
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.gray();
    ///let str2 = format!("{}{}{}","\u{1b}[49;37m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn gray(&mut self){
        self.text_color = TextColours::Gray; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into dark gray
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.dark_gray();
    ///let str2 = format!("{}{}{}","\u{1b}[49;90m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn dark_gray(&mut self){
        self.text_color = TextColours::DarkGray; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into light red
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.light_red();
    ///let str2 = format!("{}{}{}","\u{1b}[49;91m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn light_red(&mut self){
        self.text_color = TextColours::LightRed; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into light green
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.light_green();
    ///let str2 = format!("{}{}{}","\u{1b}[49;92m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn light_green(&mut self){
        self.text_color = TextColours::LightGreen; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into light yellow
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.light_yellow();
    ///let str2 = format!("{}{}{}","\u{1b}[49;93m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn light_yellow(&mut self){
        self.text_color = TextColours::LightYellow; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into light blue
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.light_blue();
    ///let str2 = format!("{}{}{}","\u{1b}[49;94m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn light_blue(&mut self){
        self.text_color = TextColours::LightBlue; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into pink
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.pink();
    ///let str2 = format!("{}{}{}","\u{1b}[49;95m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn pink(&mut self){
        self.text_color = TextColours::Pink; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into light cyan
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.light_cyan();
    ///let str2 = format!("{}{}{}","\u{1b}[49;96m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn light_cyan(&mut self){
        self.text_color = TextColours::LightCyan; 
        self.refresh();
    }
    ///This functions takes self and changes coloured string color into white
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.white();
    ///let str2 = format!("{}{}{}","\u{1b}[49;97m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn white(&mut self){
        self.text_color = TextColours::White; 
        self.refresh();
    }
    ///This functions takes self and resets the string's color
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.none();
    ///let str2 = format!("{}{}{}","\u{1b}[49;39m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn none(&mut self){
        self.text_color = TextColours::NaN; 
        self.refresh();
    }
    ///This functions takes self and adds the bold style to the string
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.bold();
    ///let str2 = format!("{}{}{}","\u{1b}[1;49;97m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn bold(&mut self){
        self.styles.push(Styles::Bold); 
        self.refresh();
    }
    ///This functions takes self and adds the dim style to the string
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.dim();
    ///let str2 = format!("{}{}{}","\u{1b}[2;49;97m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn dim(&mut self){
        self.styles.push(Styles::Dim); 
        self.refresh();
    }
    ///This functions takes self and adds the underline style to the string
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.underline();
    ///let str2 = format!("{}{}{}","\u{1b}[4;49;97m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn underline(&mut self){
        self.styles.push(Styles::Underline); 
        self.refresh();
    }
    ///This functions takes self and adds the blinking style to the string
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.blink();
    ///let str2 = format!("{}{}{}","\u{1b}[5;49;97m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn blink(&mut self){
        self.styles.push(Styles::Blink); 
        self.refresh();
    }
    ///This functions takes self and adds the reverse style to the string
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.reverse();
    ///let str2 = format!("{}{}{}","\u{1b}[7;49;97m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn reverse(&mut self){
        self.styles.push(Styles::Reverse); 
        self.refresh();
    }
    ///This functions takes self and adds the hidden(   ) style to the string
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.hidden();
    ///let str2 = format!("{}{}{}","\u{1b}[8;49;97m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn hidden(&mut self){
        self.styles.push(Styles::Hidden); 
        self.refresh();
    }
    ///This functions takes self and changes the background to be black 
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.white();
    ///str1.back_black();
    ///let str2 = format!("{}{}{}","\u{1b}[40;97m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_black(&mut self){
        self.background_color = BackColours::Black;
        self.refresh();
    }
    ///This functions takes self and changes the background to be red 
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.blue();
    ///str1.back_red();
    ///let str2 = format!("{}{}{}","\u{1b}[41;34m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_red(&mut self){
        self.background_color = BackColours::Red;
        self.refresh();
    }
    ///This functions takes self and changes the background to be blue 
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.red();
    ///str1.back_blue();
    ///let str2 = format!("{}{}{}","\u{1b}[44;31m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_blue(&mut self){
        self.background_color = BackColours::Blue;
        self.refresh();
    }
    ///This functions takes self and changes the background to be green 
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.red();
    ///str1.back_green();
    ///let str2 = format!("{}{}{}","\u{1b}[42;31m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_green(&mut self){
        self.background_color = BackColours::Green;
        self.refresh();
    }
    ///This functions takes self and changes the background to be yellow
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.magenta();
    ///str1.back_yellow();
    ///let str2 = format!("{}{}{}","\u{1b}[43;35m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_yellow(&mut self){
        self.background_color = BackColours::Yellow;
        self.refresh();
    }
    ///This functions takes self and changes the background to be magenta
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.black();
    ///str1.back_magenta();
    ///let str2 = format!("{}{}{}","\u{1b}[45;30m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_magenta(&mut self){
        self.background_color = BackColours::Magenta;
        self.refresh();
    }
    ///This functions takes self and changes the background to be cyan  
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.red();
    ///str1.back_cyan();
    ///let str2 = format!("{}{}{}","\u{1b}[46;31m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_cyan(&mut self){
        self.background_color = BackColours::Cyan;
        self.refresh();
    }
    ///This functions takes self and changes the background to be gray  
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.yellow();
    ///str1.back_gray();
    ///let str2 = format!("{}{}{}","\u{1b}[47;33m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_gray(&mut self){
        self.background_color = BackColours::Gray;
        self.refresh();
    }
    ///This functions takes self and changes the background to be dark gray
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.white();
    ///str1.back_dark_gray();
    ///let str2 = format!("{}{}{}","\u{1b}[100;97m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_dark_gray(&mut self){
        self.background_color = BackColours::DarkGray;
        self.refresh();
    }
    ///This functions takes self and changes the background to be light red
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.black();
    ///str1.back_light_red();
    ///let str2 = format!("{}{}{}","\u{1b}[101;30m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_light_red(&mut self){
        self.background_color = BackColours::LightRed;
        self.refresh();
    }
    ///This functions takes self and changes the background to be light green 
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.red();
    ///str1.back_light_green();
    ///let str2 = format!("{}{}{}","\u{1b}[102;31m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_light_green(&mut self){
        self.background_color = BackColours::LightGreen;
        self.refresh();
    }
    ///This functions takes self and changes the background to be light yellow
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.blue();
    ///str1.back_light_yellow();
    ///let str2 = format!("{}{}{}","\u{1b}[103;34m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_light_yellow(&mut self){
        self.background_color = BackColours::LightYellow;
        self.refresh();
    }
    ///This functions takes self and changes the background to be light blue 
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.black();
    ///str1.back_light_blue();
    ///let str2 = format!("{}{}{}","\u{1b}[104;30m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_light_blue(&mut self){
        self.background_color = BackColours::LightBlue;
        self.refresh();
    }
    ///This functions takes self and changes the background to be pink        
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.black();
    ///str1.back_pink();
    ///let str2 = format!("{}{}{}","\u{1b}[105;30m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_pink(&mut self){
        self.background_color = BackColours::Pink;
        self.refresh();
    }
    ///This functions takes self and changes the background to be light cyan 
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.red();
    ///str1.back_light_green();
    ///let str2 = format!("{}{}{}","\u{1b}[102;31m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_light_cyan(&mut self){
        self.background_color = BackColours::LightCyan;
        self.refresh();
    }
    ///This functions takes self and changes the background to be white 
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.black();
    ///str1.back_white();
    ///let str2 = format!("{}{}{}","\u{1b}[107;30m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_white(&mut self){
        self.background_color = BackColours::White;
        self.refresh();
    }
    ///This functions takes self and changes the background to be none 
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.red();
    ///str1.back_none();
    ///let str2 = format!("{}{}{}","\u{1b}[49;31m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn back_none(&mut self){
        self.background_color = BackColours::NaN;
        self.refresh();
    }
    ///This functions takes self and adds the reset all operation to the reset
    ///
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.blink();
    ///str1.reset_all();
    ///let str2 = format!("{}{}{}","\u{1b}[5;49;97m","hello world","\u{1b}[0m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn reset_all(&mut self){
        self.resets.push(Reset::All); 
        self.refresh();
    }
    ///This functions takes self and adds the reset bold operation to the reset
    ///it means it resets only the bold style, not any other active styles or colors.
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.bold();
    ///str1.red();
    ///str1.reset_bold();
    ///let str2 = format!("{}{}{}","\u{1b}[1;49;31m","hello world","\u{1b}[21m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn reset_bold(&mut self){
        self.resets.push(Reset::Bold);
        self.refresh();
    }
    ///This functions takes self and adds the reset dim operation to the reset
    ///it means it resets only the dim style, not any other active styles or colors.
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.dim();
    ///str1.bold();
    ///str1.reset_dim();
    ///let str2 = format!("{}{}{}","\u{1b}[2;1;49;97m","hello world","\u{1b}[22m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn reset_dim(&mut self){
        self.resets.push(Reset::Dim);
        self.refresh();
    }
    ///This functions takes self and adds the reset underline operation to the reset
    ///it means it resets only the underline style, not any other active styles or colors.
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.underline();
    ///str1.back_green();
    ///str1.reset_underline();
    ///let str2 = format!("{}{}{}","\u{1b}[4;42;97m","hello world","\u{1b}[24m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn reset_underline(&mut self){
        self.resets.push(Reset::Underline);
        self.refresh();
    }
    ///This functions takes self and adds the reset blink operation to the reset
    ///it means it resets only the blink style, not any other active styles or colors.
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.blink();
    ///str1.red();
    ///str1.reset_blink();
    ///let str2 = format!("{}{}{}","\u{1b}[5;49;31m","hello world","\u{1b}[25m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn reset_blink(&mut self){
        self.resets.push(Reset::Blink);
        self.refresh();
    }
    ///This functions takes self and adds the reset reverse operation to the reset
    ///it means it resets only the reverse style, not any other active styles or colors.
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.reverse();
    ///str1.back_red();
    ///str1.reset_reverse();
    ///let str2 = format!("{}{}{}","\u{1b}[7;41;97m","hello world","\u{1b}[27m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn reset_reverse(&mut self){
        self.resets.push(Reset::Reverse);
        self.refresh();
    }
    ///This functions takes self and adds the reset hidden operation to the reset
    ///it means it resets only the hidden style, not any other active styles or colors.
    ///
    ///```
    ///use ansi_colors::*;
    ///let mut str1 = ColouredStr::new("hello world");
    ///str1.hidden();
    ///str1.back_black();
    ///str1.reset_hidden();
    ///let str2 = format!("{}{}{}","\u{1b}[8;40;97m","hello world","\u{1b}[28m");
    ///assert_eq!(str1.coloured_string,str2);
    ///```
    pub fn reset_hidden(&mut self){
        self.resets.push(Reset::Hidden);
        self.refresh();
    }
}