void tty_color_try_alloc_pair_lib (tty_color_pair_t * mc_color_pair) { if (mc_color_pair->ifg <= (int) SPEC_A_REVERSE) { switch (mc_color_pair->ifg) { case SPEC_A_REVERSE: mc_tty_color_pair_init_special (mc_color_pair, COLOR_BLACK, COLOR_WHITE, COLOR_BLACK, COLOR_WHITE | A_BOLD, A_REVERSE); break; case SPEC_A_BOLD: mc_tty_color_pair_init_special (mc_color_pair, COLOR_WHITE, COLOR_BLACK, COLOR_WHITE, COLOR_BLACK, A_BOLD); break; case SPEC_A_BOLD_REVERSE: mc_tty_color_pair_init_special (mc_color_pair, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, A_BOLD | A_REVERSE); break; case SPEC_A_UNDERLINE: mc_tty_color_pair_init_special (mc_color_pair, COLOR_WHITE, COLOR_BLACK, COLOR_WHITE, COLOR_BLACK, A_UNDERLINE); break; default: break; } } else { int ifg, ibg, attr; ifg = mc_color_pair->ifg; ibg = mc_color_pair->ibg; attr = mc_color_pair->attr; /* In legacy color mode, change bright colors into bold */ if (!tty_use_256colors () && !tty_use_truecolors (NULL)) { if (ifg >= 8 && ifg < 16) { ifg &= 0x07; attr |= A_BOLD; } if (ibg >= 8 && ibg < 16) { ibg &= 0x07; /* attr | = A_BOLD | A_REVERSE ; */ } } init_pair (mc_color_pair->pair_index, ifg, ibg); mc_tty_color_save_attr (mc_color_pair->pair_index, attr); } }
gboolean mc_skin_init (const gchar * skin_override, GError ** mcerror) { gboolean is_good_init = TRUE; mc_return_val_if_error (mcerror, FALSE); mc_skin__default.have_256_colors = FALSE; mc_skin__default.name = skin_override != NULL ? g_strdup (skin_override) : mc_skin_get_default_name (); mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, mc_skin_hash_destroy_value); if (!mc_skin_ini_file_load (&mc_skin__default)) { mc_propagate_error (mcerror, 0, _("Unable to load '%s' skin.\nDefault skin has been loaded"), mc_skin__default.name); mc_skin_try_to_load_default (); is_good_init = FALSE; } mc_skin_colors_old_configure (&mc_skin__default); if (!mc_skin_ini_file_parse (&mc_skin__default)) { mc_propagate_error (mcerror, 0, _("Unable to parse '%s' skin.\nDefault skin has been loaded"), mc_skin__default.name); mc_skin_try_to_load_default (); mc_skin_colors_old_configure (&mc_skin__default); (void) mc_skin_ini_file_parse (&mc_skin__default); is_good_init = FALSE; } if (is_good_init && !tty_use_256colors () && mc_skin__default.have_256_colors) { mc_propagate_error (mcerror, 0, _ ("Unable to use '%s' skin with 256 colors support\non non-256 colors terminal.\nDefault skin has been loaded"), mc_skin__default.name); mc_skin_try_to_load_default (); mc_skin_colors_old_configure (&mc_skin__default); (void) mc_skin_ini_file_parse (&mc_skin__default); is_good_init = FALSE; } mc_skin_is_init = TRUE; return is_good_init; }
void tty_init (gboolean mouse_enable, gboolean is_xterm) { SLtt_Ignore_Beep = 1; SLutf8_enable (-1); /* has to be called first before any of the other functions. */ SLtt_get_terminfo (); /* * If the terminal in not in terminfo but begins with a well-known * string such as "linux" or "xterm" S-Lang will go on, but the * terminal size and several other variables won't be initialized * (as of S-Lang 1.4.4). Detect it and abort. Also detect extremely * small, large and negative screen dimensions. */ if ((COLS < 10) || (LINES < 5) || (COLS > SLTT_MAX_SCREEN_COLS) || (LINES > SLTT_MAX_SCREEN_ROWS)) { fprintf (stderr, _("Screen size %dx%d is not supported.\n" "Check the TERM environment variable.\n"), COLS, LINES); exit (EXIT_FAILURE); } tcgetattr (fileno (stdin), &boot_mode); /* 255 = ignore abort char; XCTRL('g') for abort char = ^g */ SLang_init_tty (XCTRL ('g'), 1, 0); if (mc_global.tty.ugly_line_drawing) SLtt_Has_Alt_Charset = 0; /* If SLang uses fileno(stderr) for terminal input MC will hang if we call SLang_getkey between calls to open_error_pipe and close_error_pipe, e.g. when we do a growing view of an gzipped file. */ if (SLang_TT_Read_FD == fileno (stderr)) SLang_TT_Read_FD = fileno (stdin); if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0) { #ifdef VDSUSP new_mode.c_cc[VDSUSP] = NULL_VALUE; /* to ignore ^Y */ #endif #ifdef VLNEXT new_mode.c_cc[VLNEXT] = NULL_VALUE; /* to ignore ^V */ #endif tcsetattr (SLang_TT_Read_FD, TCSADRAIN, &new_mode); } tty_reset_prog_mode (); load_terminfo_keys (); SLtt_Blink_Mode = tty_use_256colors ()? 1 : 0; tty_start_interrupt_key (); /* It's the small part from the previous init_key() */ init_key_input_fd (); /* For 8-bit locales, NCurses handles 154 (0x9A) symbol properly, while S-Lang * requires SLsmg_Display_Eight_Bit >= 154 (OR manual filtering if xterm display * detected - but checking TERM would fail under screen, OR running xterm * with allowC1Printable). */ tty_display_8bit (FALSE); SLsmg_init_smg (); if (!mouse_enable) use_mouse_p = MOUSE_DISABLED; tty_init_xterm_support (is_xterm); /* do it before do_enter_ca_mode() call */ init_mouse (); do_enter_ca_mode (); tty_keypad (TRUE); tty_nodelay (FALSE); tty_setup_sigwinch (sigwinch_handler); }