pub fn initialize_system() -> Option<Self> {
    // https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html#method.compare_and_swap
    // This method call is goofy as hell but basically we try to turn
    // `curses_is_on` to true and then we're told if we actually changed it
    // or not. If we did that means it was off and it's safe to turn it on.
    // If we didn't change it that means it was already on and we should
    // back out.
    if !curses_is_on.compare_and_swap(false, true, Ordering::SeqCst) {
      let w = pancurses::initscr();
      let color_support = if pancurses::has_colors() {
        to_bool(pancurses::start_color())
      } else {
        false
      };
      if color_support {
        let color_count = pancurses::COLORS();
        let pair_count = pancurses::COLOR_PAIRS();
        if color_count >= 8 && pair_count >= 8 * 8 {
          for fg in Color::color_iterator() {
            for bg in Color::color_iterator() {
              let fgi: i16 = color_to_i16(fg);
              let bgi: i16 = color_to_i16(bg);
              let pair_id: i16 = ColorPair::fgbg_pairid(fgi, bgi);
              debug_assert!(
                fgi as i32 <= color_count,
                "Curses reported {} color ids available, but {:?} has id {}",
                color_count,
                fg,
                fgi
              );
              debug_assert!(
                bgi as i32 <= color_count,
                "Curses reported {} color ids available, but {:?} has id {}",
                color_count,
                bg,
                bgi
              );
              debug_assert!(
                pair_id as i32 <= pair_count,
                "Curses reported {} colorpair ids available, but {:?} on {:?} would be id {}",
                pair_count,
                fg,
                bg,
                pair_id
              );
              pancurses::init_pair(pair_id, fgi, bgi);
            }
          }
        }
      }
      Some(EasyCurses {
        win: w,
        color_support: color_support,
        auto_resize: true,
      })
    } else {
      None
    }
  }
/// Initializes the curses system so that you can begin using curses.
///
/// The name is long to remind you of the seriousness of attempting to turn
/// on curses: If the C layer encounters an error while trying to initialize
/// the user's terminal into curses mode it will "helpfully" print an error
/// message and exit the process on its own. There's no way to prevent this
/// from happening at the Rust level.
///
/// If the terminal supports colors, they are automatically activated and
/// `ColorPair` values are initialized for all color foreground and
/// background combinations.
///
/// # Errors
///
/// Curses must not be double-initialized. This is tracked by easycurses
/// with an `AtomicBool` being flipped on and off. If it is on when you call
/// this method you get `None` back instead.
Initializes the curses system so that you can begin using curses.
The name is long to remind you of the seriousness of attempting to turn
on curses: If the C layer encounters an error while trying to initialize
the user's terminal into curses mode it will "helpfully" print an error
message and exit the process on its own. There's no way to prevent this
from happening at the Rust level.

If the terminal supports colors, they are automatically activated and
`ColorPair` values are initialized for all color foreground and
background combinations.
Initializes the curses system so that you can begin using curses . The name is long to remind you of the seriousness of attempting to turn on curses : If the C layer encounters an error while trying to initialize the user ' s terminal into curses mode it will " helpfully " print an error message and exit the process on its own . There ' s no way to prevent this from happening at the Rust level . If the terminal supports colors they are automatically activated and ` ColorPair ` values are initialized for all color foreground and background combinations .
pub fn initialize_system() -> Option<Self> {
    // https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html#method.compare_and_swap
    // This method call is goofy as hell but basically we try to turn
    // `curses_is_on` to true and then we're told if we actually changed it
    // or not. If we did that means it was off and it's safe to turn it on.
    // If we didn't change it that means it was already on and we should
    // back out.
    if !curses_is_on.compare_and_swap(false, true, Ordering::SeqCst) {
      let w = pancurses::initscr();
      let color_support = if pancurses::has_colors() {
        to_bool(pancurses::start_color())
      } else {
        false
      };
      if color_support {
        let color_count = pancurses::COLORS();
        let pair_count = pancurses::COLOR_PAIRS();
        if color_count >= 8 && pair_count >= 8 * 8 {
          for fg in Color::color_iterator() {
            for bg in Color::color_iterator() {
              let fgi: i16 = color_to_i16(fg);
              let bgi: i16 = color_to_i16(bg);
              let pair_id: i16 = ColorPair::fgbg_pairid(fgi, bgi);
              debug_assert!(
                fgi as i32 <= color_count,
                "Curses reported {} color ids available, but {:?} has id {}",
                color_count,
                fg,
                fgi
              );
              debug_assert!(
                bgi as i32 <= color_count,
                "Curses reported {} color ids available, but {:?} has id {}",
                color_count,
                bg,
                bgi
              );
              debug_assert!(
                pair_id as i32 <= pair_count,
                "Curses reported {} colorpair ids available, but {:?} on {:?} would be id {}",
                pair_count,
                fg,
                bg,
                pair_id
              );
              pancurses::init_pair(pair_id, fgi, bgi);
            }
          }
        }
      }
      Some(EasyCurses {
        win: w,
        color_support: color_support,
        auto_resize: true,
      })
    } else {
      None
    }
  }
pub fn initialize_system ( ) -> Option < Self > { // https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html#method.compare_and_swap // This method call is goofy as hell but basically we try to turn // `curses_is_on` to true and then we're told if we actually changed it // or not. If we did that means it was off and it's safe to turn it on. // If we didn't change it that means it was already on and we should // back out. if ! curses_is_on . compare_and_swap ( false , true , Ordering :: SeqCst ) { let w = pancurses :: initscr ( ) ; let color_support = if pancurses :: has_colors ( ) { to_bool ( pancurses :: start_color ( ) ) } else { false } ; if color_support { let color_count = pancurses :: COLORS ( ) ; let pair_count = pancurses :: COLOR_PAIRS ( ) ; if color_count >= 8 && pair_count >= 8 * 8 { for fg in Color :: color_iterator ( ) { for bg in Color :: color_iterator ( ) { let fgi : i16 = color_to_i16 ( fg ) ; let bgi : i16 = color_to_i16 ( bg ) ; let pair_id : i16 = ColorPair :: fgbg_pairid ( fgi , bgi ) ; debug_assert ! ( fgi as i32 color_count " " color_count fg fgi ) ; debug_assert ! ( bgi as i32 color_count " " color_count bg bgi ) ; debug_assert ! ( pair_id as i32 pair_count " " pair_count fg bg pair_id ) ; pancurses :: init_pair ( pair_id , fgi , bgi ) ; } } } } Some ( EasyCurses { win : w , color_support : color_support , auto_resize : true , } ) } else { None } }
Initializes the curses system so that you can begin using curses.
Initializes the curses system so that you can begin using curses .
errors
Curses must not be double-initialized. This is tracked by easycurses
with an `AtomicBool` being flipped on and off. If it is on when you call
this method you get `None` back instead.
Curses must not be double - initialized . This is tracked by easycurses with an ` AtomicBool ` being flipped on and off . If it is on when you call this method you get ` None ` back instead .