ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/main.C
(Generate patch)

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.60 by pcg, Sun Mar 28 02:07:08 2004 UTC vs.
Revision 1.65 by pcg, Fri Apr 2 15:15:26 2004 UTC

44# include <termios.h> 44# include <termios.h>
45#endif 45#endif
46 46
47#include <cstring> 47#include <cstring>
48 48
49vector<rxvt_term *> rxvt_term::termlist;
50
49static char curlocale[128]; 51static char curlocale[128];
50 52
51void 53bool
52rxvt_set_locale (const char *locale) 54rxvt_set_locale (const char *locale)
53{ 55{
54 if (locale && STRNCMP (locale, curlocale, 128)) 56 if (!locale || !STRNCMP (locale, curlocale, 128))
55 { 57 return false;
58
56 STRNCPY (curlocale, locale, 128); 59 STRNCPY (curlocale, locale, 128);
57 setlocale (LC_CTYPE, curlocale); 60 setlocale (LC_CTYPE, curlocale);
58 } 61 return true;
59} 62}
60 63
61#if ENABLE_COMBINING 64#if ENABLE_COMBINING
62class rxvt_composite_vec rxvt_composite; 65class rxvt_composite_vec rxvt_composite;
63 66
164 destroy_ev (this, &rxvt_term::destroy_cb), 167 destroy_ev (this, &rxvt_term::destroy_cb),
165 pty_ev (this, &rxvt_term::pty_cb), 168 pty_ev (this, &rxvt_term::pty_cb),
166 incr_ev (this, &rxvt_term::incr_cb) 169 incr_ev (this, &rxvt_term::incr_cb)
167{ 170{
168 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 171 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
172
173 termlist.push_back (this);
169} 174}
170 175
171rxvt_term::~rxvt_term () 176rxvt_term::~rxvt_term ()
172{ 177{
178 termlist.erase (find (termlist.begin (), termlist.end(), this));
179
173 if (cmd_fd >= 0) 180 if (cmd_fd >= 0)
174 close (cmd_fd); 181 close (cmd_fd);
175 182
176#ifndef NO_SETOWNER_TTYDEV 183#ifndef NO_SETOWNER_TTYDEV
177 privileged_ttydev (RESTORE); 184 privileged_ttydev (RESTORE);
405 * SIGNAL HANDLING & EXIT HANDLER * 412 * SIGNAL HANDLING & EXIT HANDLER *
406 * ------------------------------------------------------------------------- */ 413 * ------------------------------------------------------------------------- */
407/* 414/*
408 * Catch a SIGCHLD signal and exit if the direct child has died 415 * Catch a SIGCHLD signal and exit if the direct child has died
409 */ 416 */
417
418void rxvt_term::child_exited (int pid)
419{
420 for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++)
421 if (pid == (*t)->cmd_pid)
422 {
423 (*t)->destroy ();
424 break;
425 }
426}
427
410/* ARGSUSED */ 428/* ARGSUSED */
411/* EXTPROTO */ 429/* EXTPROTO */
412RETSIGTYPE 430RETSIGTYPE
413rxvt_Child_signal (int sig __attribute__ ((unused))) 431rxvt_Child_signal (int sig __attribute__ ((unused)))
414{ 432{
415 int pid, save_errno = errno; 433 int pid, save_errno = errno;
434
416 while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) 435 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
417 ; 436 rxvt_term::child_exited (pid);
437
418 errno = save_errno; 438 errno = save_errno;
419
420#if 0
421 if (pid == cmd_pid)
422 exit (EXIT_SUCCESS);
423#endif
424} 439}
425 440
426/* 441/*
427 * Catch a fatal signal and tidy up before quitting 442 * Catch a fatal signal and tidy up before quitting
428 */ 443 */
867/*----------------------------------------------------------------------*/ 882/*----------------------------------------------------------------------*/
868/* xterm sequences - title, iconName, color (exptl) */ 883/* xterm sequences - title, iconName, color (exptl) */
869void 884void
870rxvt_term::set_title (const char *str) 885rxvt_term::set_title (const char *str)
871{ 886{
872#ifndef SMART_WINDOW_TITLE 887#ifdef SMART_WINDOW_TITLE
873 XStoreName (display->display, TermWin.parent[0], str);
874#else
875 char *name; 888 char *name;
876 889
877 if (!XFetchName (display->display, TermWin.parent[0], &name)) 890 if (!XFetchName (display->display, TermWin.parent[0], &name))
878 name = NULL; 891 name = NULL;
879 892
880 if (name == NULL || STRCMP (name, str)) 893 if (name == NULL || STRCMP (name, str))
894#endif
881 XStoreName (display->display, TermWin.parent[0], str); 895 XStoreName (display->display, TermWin.parent[0], str);
882 896
897#ifdef SMART_WINDOW_TITLE
883 if (name) 898 if (name)
884 XFree (name); 899 XFree (name);
885#endif 900#endif
886} 901}
887 902
888void 903void
889rxvt_term::set_icon_name (const char *str) 904rxvt_term::set_icon_name (const char *str)
890{ 905{
891#ifndef SMART_WINDOW_TITLE 906#ifdef SMART_WINDOW_TITLE
892 XSetIconName (display->display, TermWin.parent[0], str);
893#else
894 char *name; 907 char *name;
895 908
896 if (!XGetIconName (display->display, TermWin.parent[0], &name)) 909 if (!XGetIconName (display->display, TermWin.parent[0], &name))
897 name = NULL; 910 name = NULL;
898 911
899 if (name == NULL || STRCMP (name, str)) 912 if (name == NULL || STRCMP (name, str))
913#endif
900 XSetIconName (display->display, TermWin.parent[0], str); 914 XSetIconName (display->display, TermWin.parent[0], str);
901 915
916#ifdef SMART_WINDOW_TITLE
902 if (name) 917 if (name)
903 XFree (name); 918 XFree (name);
904#endif 919#endif
905} 920}
906 921
933 PixColors[idx] = PixColors[minCOLOR + i]; 948 PixColors[idx] = PixColors[minCOLOR + i];
934 SET_PIXCOLOR (idx); 949 SET_PIXCOLOR (idx);
935 goto Done; 950 goto Done;
936 } 951 }
937 } 952 }
953
938 if (!rXParseAllocColor (& xcol, color)) 954 if (!rXParseAllocColor (& xcol, color))
939 return; 955 return;
956
940 /* XStoreColor (display->display, XCMAP, XColor*); */ 957 /* XStoreColor (display->display, XCMAP, XColor*); */
941 958
942 /* 959 /*
943 * FIXME: should free colors here, but no idea how to do it so instead, 960 * FIXME: should free colors here, but no idea how to do it so instead,
944 * so just keep gobbling up the colormap 961 * so just keep gobbling up the colormap
967 984
968 /* handle Color_BD, scrollbar background, etc. */ 985 /* handle Color_BD, scrollbar background, etc. */
969 986
970 set_colorfgbg (); 987 set_colorfgbg ();
971 recolour_cursor (); 988 recolour_cursor ();
972 /* the only reasonable way to enforce a clean update */ 989 scr_touch (true);
973 scr_poweron ();
974} 990}
975 991
976#else 992#else
977# define set_window_color (idx,color) ((void)0) 993# define set_window_color (idx,color) ((void)0)
978#endif /* XTERM_COLOR_CHANGE */ 994#endif /* XTERM_COLOR_CHANGE */
979 995
980void 996void
981rxvt_term::recolour_cursor () 997rxvt_term::recolour_cursor ()
982{ 998{
983#if TODO
984 rxvt_color xcol[2]; 999 XColor xcol[2];
985 1000
986 xcol[0] = PixColors[Color_pointer]; 1001 xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColors[Color_pointer_fg] : PixColors[Color_fg];
987 xcol[1] = PixColors[Color_bg]; 1002 xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColors[Color_pointer_bg] : PixColors[Color_bg];
988 XQueryColors (display->display, XCMAP, xcol, 2); 1003 XQueryColors (display->display, XCMAP, xcol, 2);
989 XRecolorCursor (display->display, TermWin_cursor, & (xcol[0]), & (xcol[1])); 1004 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1);
990#endif
991} 1005}
992 1006
993/*----------------------------------------------------------------------*/ 1007/*----------------------------------------------------------------------*/
994/* 1008/*
995 * find if fg/bg matches any of the normal (low-intensity) colors 1009 * find if fg/bg matches any of the normal (low-intensity) colors

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines