Exemple #1
0
int SLsmg_utf8_enable (int mode)
{
   if (mode == -1)
     {
	mode = _pSLutf8_mode;
	if (mode == -1)
	  mode = SLutf8_enable (-1);
     }
   return UTF8_Mode = mode;
}
Exemple #2
0
int ui__init(void)
{
	int err;

	SLutf8_enable(-1);
	SLtt_get_terminfo();
	SLtt_get_screen_size();

	err = SLsmg_init_smg();
	if (err < 0)
		goto out;
	err = SLang_init_tty(0, 0, 0);
	if (err < 0)
		goto out;

	err = SLkp_init();
	if (err < 0) {
		pr_err("TUI initialization failed.\n");
		goto out;
	}

	SLkp_define_keysym((char *)"^(kB)", SL_KEY_UNTAB);

	ui_helpline__init();
	ui_browser__init();
	tui_progress__init();

	signal(SIGSEGV, ui__signal_backtrace);
	signal(SIGFPE, ui__signal_backtrace);
	signal(SIGINT, ui__signal);
	signal(SIGQUIT, ui__signal);
	signal(SIGTERM, ui__signal);

	perf_error__register(&perf_tui_eops);

	hist_browser__init_hpp();
out:
	return err;
}
Exemple #3
0
/**
 * @brief Initialize the newt library
 * @return int - 0 for success, else < 0
 */
int newtInit(void) {
    char * MonoValue, * MonoEnv = "NEWT_MONO";
    const char *lang;
    int ret;

    if ((lang = getenv("LC_ALL")) == NULL)
        if ((lang = getenv("LC_CTYPE")) == NULL)
            if ((lang = getenv("LANG")) == NULL)
                lang = "";
    /* slang doesn't support multibyte encodings except UTF-8,
       avoid character corruption by redrawing the screen */
    if (strstr (lang, ".euc") != NULL)
	trashScreen = 1;

    (void) strlen(ident);

    SLutf8_enable(-1);
    SLtt_get_terminfo();
    SLtt_get_screen_size();

    MonoValue = getenv(MonoEnv);
    if ( MonoValue != NULL )
	SLtt_Use_Ansi_Colors = 0;

    if ((ret = SLsmg_init_smg()) < 0)
	return ret;
    if ((ret = SLang_init_tty(0, 0, 0)) < 0)
	return ret;

    initColors();
    newtCursorOff();
    initKeymap();

    SLsignal_intr(SIGWINCH, handleSigwinch);
    SLang_getkey_intr_hook = getkeyInterruptHook;

    return 0;
}
Exemple #4
0
int main (int argc, char **argv)
{
   int i;
   int utf8 = 0;

   for (i = 1; i < argc; i++)
     {
	char *arg = argv[i];
	if (*arg != '-')
	  break;

	if (0 == strcmp (arg, "-utf8"))
	  {
	     utf8 = 1;
	     continue;
	  }
	i = argc;
     }

   if (i >= argc)
     {
	fprintf (stderr, "Usage: %s [-utf8] FILE...\n", argv[0]);
	return 1;
     }
   (void) SLutf8_enable (utf8);

   if ((-1 == SLang_init_all ())
       || (-1 == SLang_init_array_extra ())
       || (-1 == SLadd_intrin_fun_table (Intrinsics, NULL))
       || (-1 == add_test_classes ()))
     return 1;

   SLang_Traceback = 1;

   if (-1 == SLang_set_argc_argv (argc, argv))
     return 1;

#ifdef HAVE_FPSETMASK
# ifndef FP_X_OFL
#  define FP_X_OFL 0
# endif
# ifndef FP_X_INV
#  define FP_X_INV 0
# endif
# ifndef FP_X_DZ
#  define FP_X_DZ 0
# endif
# ifndef FP_X_DNML
#  define FP_X_DNML 0
# endif
# ifndef FP_X_UFL
#  define FP_X_UFL 0
# endif
# ifndef FP_X_IMP
#  define FP_X_IMP 0
# endif
   fpsetmask (~(FP_X_OFL|FP_X_INV|FP_X_DZ|FP_X_DNML|FP_X_UFL|FP_X_IMP));
#endif

   if (i + 1 < argc)
     Ignore_Exit = 1;

   while (i < argc)
     {
	char *file = argv[i];
	if (0 == strncmp (SLpath_extname (file), ".slc", 4))
	  {
	     char *file_sl = SLmake_string (file);
	     file_sl[strlen(file_sl)-1] = 0;
	     if (-1 == SLang_byte_compile_file (file_sl, 0))
	       {
		  SLfree (file_sl);
		  return 1;
	       }
	     SLfree (file_sl);
	  }
	if (-1 == SLang_load_file (file))
	  return 1;
	i++;
     }

   return SLang_get_error ();
}
Exemple #5
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);
}
Exemple #6
0
SLcurses_Window_Type *SLcurses_initscr (void)
{
   SLcurses_Is_Endwin = 0;
   SLsmg_Newline_Behavior = SLSMG_NEWLINE_MOVES;
   SLtt_get_terminfo ();

#if !defined(IBMPC_SYSTEM) && !defined(VMS)
   if (-1 == (SLcurses_Num_Colors = SLtt_tgetnum ("Co")))
#endif
     SLcurses_Num_Colors = 8;

   /* Enable UTF-8 support if used on the terminal */
   (void) SLutf8_enable (-1);

   if ((-1 == SLkp_init ())
       || (-1 == SLcurses_cbreak ())
       || (NULL == (SLcurses_Stdscr = SLcurses_newwin (0, 0, 0, 0)))
       || (-1 == SLsmg_init_smg ()))
     {
	SLang_exit_error ("SLcurses_initscr: init failed\n");
	return NULL;
     }
   SLkp_set_getkey_function (getkey_function);

#ifdef SIGINT
   signal (SIGINT, sigint_handler);
#endif

#if defined(SIGTSTP) && defined(SIGSTOP)
   signal (SIGTSTP, sigtstp_handler);
#endif

   SLtt_set_mono (SLCURSES_EXTRACT_COLOR(A_BOLD), NULL, SLTT_BOLD_MASK);
   SLtt_set_mono (SLCURSES_EXTRACT_COLOR(A_UNDERLINE), NULL, SLTT_ULINE_MASK);
   SLtt_set_mono (SLCURSES_EXTRACT_COLOR(A_REVERSE), NULL, SLTT_REV_MASK);
   /* SLtt_set_mono (SLCURSES_EXTRACT_COLOR(A_BLINK), NULL, SLTT_BLINK_MASK); */
   /* SLtt_set_mono (SLCURSES_EXTRACT_COLOR(A_ITALIC), NULL, SLTT_ITALIC_MASK); */
   SLtt_set_mono ((SLCURSES_EXTRACT_COLOR(A_BOLD|A_UNDERLINE)), NULL, SLTT_ULINE_MASK|SLTT_BOLD_MASK);
   SLtt_set_mono ((SLCURSES_EXTRACT_COLOR(A_REVERSE|A_UNDERLINE)), NULL, SLTT_ULINE_MASK|SLTT_REV_MASK);

   if (SLtt_Has_Alt_Charset)
     {
       SLcurses_Acs_Map[SLSMG_ULCORN_CHAR] = SLSMG_ULCORN_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_URCORN_CHAR] = SLSMG_URCORN_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_LLCORN_CHAR] = SLSMG_LLCORN_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_LRCORN_CHAR] = SLSMG_LRCORN_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_UTEE_CHAR] = SLSMG_UTEE_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_DTEE_CHAR] = SLSMG_DTEE_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_LTEE_CHAR] = SLSMG_LTEE_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_RTEE_CHAR] = SLSMG_RTEE_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_VLINE_CHAR] = SLSMG_VLINE_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_HLINE_CHAR] = SLSMG_HLINE_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_PLUS_CHAR] = SLSMG_PLUS_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_CKBRD_CHAR] = SLSMG_CKBRD_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_DIAMOND_CHAR] = SLSMG_DIAMOND_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_DEGREE_CHAR] = SLSMG_DEGREE_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_PLMINUS_CHAR] = SLSMG_PLMINUS_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_BULLET_CHAR] = SLSMG_BULLET_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_LARROW_CHAR] = SLSMG_LARROW_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_RARROW_CHAR] = SLSMG_RARROW_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_DARROW_CHAR] = SLSMG_DARROW_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_UARROW_CHAR] = SLSMG_UARROW_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_BOARD_CHAR] = SLSMG_BOARD_CHAR | A_ALTCHARSET;
       SLcurses_Acs_Map[SLSMG_BLOCK_CHAR] = SLSMG_BLOCK_CHAR | A_ALTCHARSET;
     }
   else
     {
       /* ugly defaults to use on terminals which don't support graphics */
	SLcurses_Acs_Map[SLSMG_ULCORN_CHAR] = '+';
	SLcurses_Acs_Map[SLSMG_URCORN_CHAR] = '+';
	SLcurses_Acs_Map[SLSMG_LLCORN_CHAR] = '+';
	SLcurses_Acs_Map[SLSMG_LRCORN_CHAR] = '+';
	SLcurses_Acs_Map[SLSMG_UTEE_CHAR] = '+';
	SLcurses_Acs_Map[SLSMG_DTEE_CHAR] = '+';
	SLcurses_Acs_Map[SLSMG_LTEE_CHAR] = '+';
	SLcurses_Acs_Map[SLSMG_RTEE_CHAR] = '+';
	SLcurses_Acs_Map[SLSMG_VLINE_CHAR] = '|';
	SLcurses_Acs_Map[SLSMG_HLINE_CHAR] = '-';
	SLcurses_Acs_Map[SLSMG_PLUS_CHAR] = '+';
	SLcurses_Acs_Map[SLSMG_CKBRD_CHAR] = '#';
	SLcurses_Acs_Map[SLSMG_DIAMOND_CHAR] = '+';
	SLcurses_Acs_Map[SLSMG_DEGREE_CHAR] = '\\';
	SLcurses_Acs_Map[SLSMG_PLMINUS_CHAR] = '#';
	SLcurses_Acs_Map[SLSMG_BULLET_CHAR] = 'o';
	SLcurses_Acs_Map[SLSMG_LARROW_CHAR] = '<';
	SLcurses_Acs_Map[SLSMG_RARROW_CHAR] = '>';
	SLcurses_Acs_Map[SLSMG_DARROW_CHAR] = 'v';
	SLcurses_Acs_Map[SLSMG_UARROW_CHAR] = '^';
	SLcurses_Acs_Map[SLSMG_BOARD_CHAR] = '#';
	SLcurses_Acs_Map[SLSMG_BLOCK_CHAR] = '#';
     }

   return SLcurses_Stdscr;
}