… | |
… | |
33 | |
33 | |
34 | #include "../config.h" /* NECESSARY */ |
34 | #include "../config.h" /* NECESSARY */ |
35 | #include "rxvt.h" /* NECESSARY */ |
35 | #include "rxvt.h" /* NECESSARY */ |
36 | #include "rxvtutil.h" |
36 | #include "rxvtutil.h" |
37 | #include "init.h" |
37 | #include "init.h" |
|
|
38 | |
|
|
39 | #include <limits> |
38 | |
40 | |
39 | #include <csignal> |
41 | #include <csignal> |
40 | |
42 | |
41 | const char *const def_colorName[] = |
43 | const char *const def_colorName[] = |
42 | { |
44 | { |
… | |
… | |
369 | if (!rs[Rs_iconName]) |
371 | if (!rs[Rs_iconName]) |
370 | rs[Rs_iconName] = rs[Rs_name]; |
372 | rs[Rs_iconName] = rs[Rs_name]; |
371 | } |
373 | } |
372 | |
374 | |
373 | if (rs[Rs_saveLines] && (i = atoi (rs[Rs_saveLines])) >= 0) |
375 | if (rs[Rs_saveLines] && (i = atoi (rs[Rs_saveLines])) >= 0) |
374 | saveLines = BOUND_POSITIVE_INT16 (i); |
376 | saveLines = min (i, MAX_SAVELINES); |
375 | |
377 | |
376 | #if ENABLE_FRILLS |
378 | #if ENABLE_FRILLS |
377 | if (rs[Rs_int_bwidth] && (i = atoi (rs[Rs_int_bwidth])) >= 0) |
379 | if (rs[Rs_int_bwidth] && (i = atoi (rs[Rs_int_bwidth])) >= 0) |
378 | int_bwidth = min (i, 100); /* arbitrary limit */ |
380 | int_bwidth = min (i, std::numeric_limits<int16_t>::max ()); |
|
|
381 | |
379 | if (rs[Rs_ext_bwidth] && (i = atoi (rs[Rs_ext_bwidth])) >= 0) |
382 | if (rs[Rs_ext_bwidth] && (i = atoi (rs[Rs_ext_bwidth])) >= 0) |
380 | ext_bwidth = min (i, 100); /* arbitrary limit */ |
383 | ext_bwidth = min (i, std::numeric_limits<int16_t>::max ()); |
|
|
384 | |
381 | if (rs[Rs_lineSpace] && (i = atoi (rs[Rs_lineSpace])) >= 0) |
385 | if (rs[Rs_lineSpace] && (i = atoi (rs[Rs_lineSpace])) >= 0) |
382 | lineSpace = min (i, 100); /* arbitrary limit */ |
386 | lineSpace = min (i, std::numeric_limits<int16_t>::max ()); |
383 | #endif |
387 | #endif |
384 | |
388 | |
385 | #ifdef POINTER_BLANK |
389 | #ifdef POINTER_BLANK |
386 | if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0) |
390 | if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0) |
387 | pointerBlankDelay = i; |
391 | pointerBlankDelay = i; |
… | |
… | |
458 | rs[Rs_color + i] = def_colorName[i]; |
462 | rs[Rs_color + i] = def_colorName[i]; |
459 | |
463 | |
460 | #ifndef XTERM_REVERSE_VIDEO |
464 | #ifndef XTERM_REVERSE_VIDEO |
461 | /* this is how we implement reverseVideo */ |
465 | /* this is how we implement reverseVideo */ |
462 | if (options & Opt_reverseVideo) |
466 | if (options & Opt_reverseVideo) |
463 | SWAP_IT (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg], const char *); |
467 | ::swap (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg]); |
464 | #endif |
468 | #endif |
465 | |
469 | |
466 | /* convenient aliases for setting fg/bg to colors */ |
470 | /* convenient aliases for setting fg/bg to colors */ |
467 | color_aliases (Color_fg); |
471 | color_aliases (Color_fg); |
468 | color_aliases (Color_bg); |
472 | color_aliases (Color_bg); |
… | |
… | |
521 | |
525 | |
522 | /* avoiding the math library: |
526 | /* avoiding the math library: |
523 | * i = (int) (ceil (log10 ((unsigned int)parent[0]))) */ |
527 | * i = (int) (ceil (log10 ((unsigned int)parent[0]))) */ |
524 | for (i = 0, u = (unsigned int)parent[0]; u; u /= 10, i++) |
528 | for (i = 0, u = (unsigned int)parent[0]; u; u /= 10, i++) |
525 | ; |
529 | ; |
526 | MAX_IT (i, 1); |
530 | max_it (i, 1); |
527 | env_windowid = (char *)rxvt_malloc ((i + 10) * sizeof (char)); |
531 | env_windowid = (char *)rxvt_malloc ((i + 10) * sizeof (char)); |
528 | |
532 | |
529 | sprintf (env_windowid, "WINDOWID=%u", |
533 | sprintf (env_windowid, "WINDOWID=%u", |
530 | (unsigned int)parent[0]); |
534 | (unsigned int)parent[0]); |
531 | |
535 | |
… | |
… | |
1193 | /* |
1197 | /* |
1194 | * standard System V termios interface |
1198 | * standard System V termios interface |
1195 | */ |
1199 | */ |
1196 | if (GET_TERMIOS (STDIN_FILENO, tio) < 0) |
1200 | if (GET_TERMIOS (STDIN_FILENO, tio) < 0) |
1197 | { |
1201 | { |
1198 | /* return error - use system defaults */ |
1202 | // return error - use system defaults, |
|
|
1203 | // where possible, and zero elsewhere |
|
|
1204 | memset (tio, 0, sizeof (ttymode_t)); |
|
|
1205 | |
1199 | tio->c_cc[VINTR] = CINTR; |
1206 | tio->c_cc[VINTR] = CINTR; |
1200 | tio->c_cc[VQUIT] = CQUIT; |
1207 | tio->c_cc[VQUIT] = CQUIT; |
1201 | tio->c_cc[VERASE] = CERASE; |
1208 | tio->c_cc[VERASE] = CERASE; |
|
|
1209 | #ifdef VERASE2 |
|
|
1210 | tio->c_cc[VERASE2] = CERASE2; |
|
|
1211 | #endif |
1202 | tio->c_cc[VKILL] = CKILL; |
1212 | tio->c_cc[VKILL] = CKILL; |
1203 | tio->c_cc[VSTART] = CSTART; |
1213 | tio->c_cc[VSTART] = CSTART; |
1204 | tio->c_cc[VSTOP] = CSTOP; |
1214 | tio->c_cc[VSTOP] = CSTOP; |
1205 | tio->c_cc[VSUSP] = CSUSP; |
1215 | tio->c_cc[VSUSP] = CSUSP; |
1206 | # ifdef VDSUSP |
1216 | # ifdef VDSUSP |
… | |
… | |
1400 | { |
1410 | { |
1401 | #if ENABLE_FRILLS |
1411 | #if ENABLE_FRILLS |
1402 | if (rs[Rs_pty_fd]) |
1412 | if (rs[Rs_pty_fd]) |
1403 | { |
1413 | { |
1404 | pty.pty = atoi (rs[Rs_pty_fd]); |
1414 | pty.pty = atoi (rs[Rs_pty_fd]); |
|
|
1415 | |
|
|
1416 | if (getfd_hook) |
|
|
1417 | pty.pty = (*getfd_hook) (pty.pty); |
|
|
1418 | |
1405 | fcntl (pty.pty, F_SETFL, O_NONBLOCK); |
1419 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
|
|
1420 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1406 | } |
1421 | } |
1407 | else |
1422 | else |
1408 | #endif |
1423 | #endif |
1409 | if (!pty.get ()) |
1424 | if (!pty.get ()) |
1410 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1425 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |