Beispiel #1
0
void
display_bits_box (void)
{
    const char *cpname;

    new_display_codepage = mc_global.display_codepage;

    cpname = (new_display_codepage < 0) ? _("Other 8 bit")
        : ((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;

    {
        int new_meta;

        quick_widget_t quick_widgets[] = {
            /* *INDENT-OFF* */
            QUICK_START_COLUMNS,
                QUICK_LABEL (N_("Input / display codepage:"), NULL),
            QUICK_NEXT_COLUMN,
                QUICK_BUTTON (cpname, B_USER, sel_charset_button, NULL),
            QUICK_STOP_COLUMNS,
            QUICK_SEPARATOR (TRUE),
                QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta, NULL),
            QUICK_BUTTONS_OK_CANCEL,
            QUICK_END
            /* *INDENT-ON* */
        };

        quick_dialog_t qdlg = {
            -1, -1, 46,
            N_("Display bits"), "[Display bits]",
            quick_widgets, NULL, NULL
        };

        new_meta = !use_8th_bit_as_meta;
        application_keypad_mode ();

        if (quick_dialog (&qdlg) == B_ENTER)
        {
            char *errmsg;

            mc_global.display_codepage = new_display_codepage;

            errmsg = init_translation_table (mc_global.source_codepage, mc_global.display_codepage);
            if (errmsg != NULL)
            {
                message (D_ERROR, MSG_ERROR, "%s", errmsg);
                g_free (errmsg);
            }

#ifdef HAVE_SLANG
            tty_display_8bit (mc_global.display_codepage != 0 && mc_global.display_codepage != 1);
#else
            tty_display_8bit (mc_global.display_codepage != 0);
#endif
            use_8th_bit_as_meta = !new_meta;

            repaint_screen ();
        }
    }
}
Beispiel #2
0
void
display_bits_box (void)
{
    Dlg_head *dbits_dlg;
    new_display_codepage = display_codepage;

    application_keypad_mode ();
    dbits_dlg = init_disp_bits_box ();

    run_dlg (dbits_dlg);

    if (dbits_dlg->ret_value == B_ENTER)
    {
        char *errmsg;

        display_codepage = new_display_codepage;
        errmsg = init_translation_table (source_codepage, display_codepage);
        if (errmsg != NULL)
        {
            message (D_ERROR, MSG_ERROR, "%s", errmsg);
            g_free (errmsg);
        }
#ifdef HAVE_SLANG
        tty_display_8bit (display_codepage != 0 && display_codepage != 1);
#else
        tty_display_8bit (display_codepage != 0);
#endif
        use_8th_bit_as_meta = !(inpcheck->state & C_BOOL);
    }
    destroy_dlg (dbits_dlg);
    repaint_screen ();
}
Beispiel #3
0
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);
}