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.94 by root, Sun Aug 15 22:09:24 2004 UTC vs.
Revision 1.108 by root, Wed Aug 25 05:03:33 2004 UTC

123 return len; 123 return len;
124 124
125} 125}
126#endif 126#endif
127 127
128void *
129rxvt_term::operator new (size_t s)
130{
131 void *p = malloc (s);
132
133 memset (p, 0, s);
134 return p;
135}
136
137void
138rxvt_term::operator delete (void *p, size_t s)
139{
140 free (p);
141}
142
143rxvt_term::rxvt_term () 128rxvt_term::rxvt_term ()
144 : 129 :
145#if TRANSPARENT 130#if TRANSPARENT
146 rootwin_ev (this, &rxvt_term::rootwin_cb), 131 rootwin_ev (this, &rxvt_term::rootwin_cb),
147#endif 132#endif
196 181
197#ifdef UTMP_SUPPORT 182#ifdef UTMP_SUPPORT
198 privileged_utmp (RESTORE); 183 privileged_utmp (RESTORE);
199#endif 184#endif
200 185
186#if ENABLE_STYLES
187 for (int i = RS_styleCount; --i; )
188 if (TermWin.fontset[i] != TermWin.fontset[0])
189 delete TermWin.fontset[i];
190#endif
201 delete TermWin.fontset; 191 delete TermWin.fontset[0];
202 192
203 if (display) 193 if (display)
204 { 194 {
205 selection_clear (); 195 selection_clear ();
206 196
386 } 376 }
387#endif 377#endif
388 378
389 XMapWindow (display->display, TermWin.vt); 379 XMapWindow (display->display, TermWin.vt);
390 XMapWindow (display->display, TermWin.parent[0]); 380 XMapWindow (display->display, TermWin.parent[0]);
381
382 set_colorfgbg ();
391 383
392 init_command (cmd_argv); 384 init_command (cmd_argv);
393 385
394 pty_ev.start (pty.pty, EVENT_READ); 386 pty_ev.start (pty.pty, EVENT_READ);
395 387
793 kill (cmd_pid, SIGWINCH); 785 kill (cmd_pid, SIGWINCH);
794#endif 786#endif
795} 787}
796 788
797/*----------------------------------------------------------------------*/ 789/*----------------------------------------------------------------------*/
798/* rxvt_change_font () - Switch to a new font */ 790/* set_fonts () - load and set the various fonts
799/* 791/*
800 * init = 1 - initialize 792 * init = 1 - initialize
801 * 793 *
802 * fontname == FONT_UP - switch to bigger font 794 * fontname == FONT_UP - switch to bigger font
803 * fontname == FONT_DN - switch to smaller font 795 * fontname == FONT_DN - switch to smaller font
804 */ 796 */
805bool 797bool
806rxvt_term::change_font (const char *fontname) 798rxvt_term::set_fonts ()
807{ 799{
808 if (fontname == FONT_UP)
809 {
810 // TODO
811 }
812 else if (fontname == FONT_DN)
813 {
814 // TODO
815 }
816 else
817 {
818 rxvt_fontset *fs = new rxvt_fontset (this); 800 rxvt_fontset *fs = new rxvt_fontset (this);
801 rxvt_fontprop prop;
819 802
820 if (fs && fs->populate (fontname ? fontname : "fixed")) 803 prop.width = prop.height = prop.weight = prop.slant
804 = rxvt_fontprop::unset;
805
806 if (!fs
807 || !fs->populate (rs[Rs_font] ? rs[Rs_font] : "fixed", prop)
808 || !fs->realize_font (1))
809 {
810 delete fs;
811 return false;
812 }
813
814#if ENABLE_STYLES
815 for (int i = RS_styleCount; --i; )
816 if (TermWin.fontset[i] != TermWin.fontset[0])
817 delete TermWin.fontset[i];
818#endif
819
820 delete TermWin.fontset[0];
821 TermWin.fontset[0] = fs;
822
823 fs->prop = prop = (*fs)[1]->properties ();
824
825 TermWin.fwidth = prop.width;
826 TermWin.fheight = prop.height;
827 TermWin.fweight = prop.weight;
828 TermWin.fslant = prop.slant;
829 TermWin.fbase = (*fs)[1]->ascent;
830
831 for (int style = 1; style < 4; style++)
832 {
833#if ENABLE_STYLES
834 const char *res = rs[Rs_font + style];
835
836 if (res && !*res)
837 TermWin.fontset[style] = TermWin.fontset[0];
838 else
821 { 839 {
822 delete TermWin.fontset; 840 TermWin.fontset[style] = fs = new rxvt_fontset (this);
823 TermWin.fontset = fs; 841 rxvt_fontprop prop2 = prop;
824 TermWin.fwidth = fs->base_font ()->width;
825 TermWin.fheight = fs->base_font ()->height;
826 TermWin.fbase = fs->base_font ()->ascent;
827 842
828 if (TermWin.parent[0]) 843 if (res)
844 prop2.weight = prop2.slant = rxvt_fontprop::unset;
845 else
829 { 846 {
830 resize_all_windows (0, 0, 0); 847 res = TermWin.fontset[0]->fontdesc;
831 scr_remap_chars (); 848
832 scr_touch (true); 849 if (SET_STYLE (0, style) & RS_Bold) prop2.weight = rxvt_fontprop::bold;
850 if (SET_STYLE (0, style) & RS_Italic) prop2.slant = rxvt_fontprop::italic;
833 } 851 }
834 852
835 for (unicode_t ch = 0x20; ch <= 0x7f; ch++) 853 fs->populate (res, prop2);
836 TermWin.ascii_map [ch - 0x20] = fs->find_font (ch);
837
838 return true;
839 } 854 }
855#else
856 TermWin.fontset[style] = TermWin.fontset[0];
857#endif
858 }
859
860 if (TermWin.parent[0])
840 } 861 {
862 resize_all_windows (0, 0, 0);
863 scr_remap_chars ();
864 scr_touch (true);
865 }
841 866
842 return false; 867 return true;
843}
844
845bool
846rxvt_term::font_up_down (int n, int direction)
847{
848 return false;
849} 868}
850 869
851/*----------------------------------------------------------------------*/ 870/*----------------------------------------------------------------------*/
852/*----------------------------------------------------------------------*/ 871/*----------------------------------------------------------------------*/
853/* xterm sequences - title, iconName, color (exptl) */ 872/* xterm sequences - title, iconName, color (exptl) */
947 966
948 /* XSetWindowAttributes attr; */ 967 /* XSetWindowAttributes attr; */
949 /* Cursor cursor; */ 968 /* Cursor cursor; */
950Done: 969Done:
951#ifdef OFF_FOCUS_FADING 970#ifdef OFF_FOCUS_FADING
971 if (rs[Rs_fade])
952 pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade])); 972 pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade]));
953#endif 973#endif
954 if (idx == Color_bg && ! (options & Opt_transparent))
955 XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]);
956 974
957 /* handle Color_BD, scrollbar background, etc. */ 975 /*TODO: handle Color_BD, scrollbar background, etc. */
958 976
959 set_colorfgbg ();
960 recolour_cursor (); 977 recolour_cursor ();
961 scr_touch (true); 978 scr_recolour ();
962} 979}
963 980
964#else 981#else
965# define set_window_color (idx,color) ((void)0) 982# define set_window_color (idx,color) ((void)0)
966#endif /* XTERM_COLOR_CHANGE */ 983#endif /* XTERM_COLOR_CHANGE */
968void 985void
969rxvt_term::recolour_cursor () 986rxvt_term::recolour_cursor ()
970{ 987{
971 XColor xcol[2]; 988 XColor xcol[2];
972 989
973 xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? pix_colors_focused[Color_pointer_fg] : pix_colors_focused[Color_fg]; 990 xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg)
974 xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? pix_colors_focused[Color_pointer_bg] : pix_colors_focused[Color_bg]; 991 ? pix_colors_focused[Color_pointer_fg]
992 : pix_colors_focused[Color_fg];
993 xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg)
994 ? pix_colors_focused[Color_pointer_bg]
995 : pix_colors_focused[Color_bg];
996
975 XQueryColors (display->display, display->cmap, xcol, 2); 997 XQueryColors (display->display, display->cmap, xcol, 2);
976 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1); 998 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1);
977} 999}
978 1000
979/*----------------------------------------------------------------------*/ 1001/*----------------------------------------------------------------------*/
981 * find if fg/bg matches any of the normal (low-intensity) colors 1003 * find if fg/bg matches any of the normal (low-intensity) colors
982 */ 1004 */
983void 1005void
984rxvt_term::set_colorfgbg () 1006rxvt_term::set_colorfgbg ()
985{ 1007{
986 unsigned int i; 1008 unsigned int i;
987 const char *xpmb = "\0"; 1009 const char *xpmb = "\0";
988 char fstr[sizeof ("default") + 1], bstr[sizeof ("default") + 1]; 1010 char fstr[sizeof ("default") + 1], bstr[sizeof ("default") + 1];
989 1011
990 env_colorfgbg =
991 (char *)rxvt_malloc (sizeof ("COLORFGBG=default;default;bg") + 1); 1012 env_colorfgbg = (char *)rxvt_malloc (sizeof ("COLORFGBG=default;default;bg") + 1);
992 strcpy (fstr, "default"); 1013 strcpy (fstr, "default");
993 strcpy (bstr, "default"); 1014 strcpy (bstr, "default");
994 for (i = Color_Black; i <= Color_White; i++) 1015 for (i = Color_Black; i <= Color_White; i++)
995 if (pix_colors[Color_fg] == pix_colors[i]) 1016 if (pix_colors[Color_fg] == pix_colors[i])
996 { 1017 {
997 sprintf (fstr, "%d", (i - Color_Black)); 1018 sprintf (fstr, "%d", (i - Color_Black));
998 break; 1019 break;
999 } 1020 }
1021
1000 for (i = Color_Black; i <= Color_White; i++) 1022 for (i = Color_Black; i <= Color_White; i++)
1001 if (pix_colors[Color_bg] == pix_colors[i]) 1023 if (pix_colors[Color_bg] == pix_colors[i])
1002 { 1024 {
1003 sprintf (bstr, "%d", (i - Color_Black)); 1025 sprintf (bstr, "%d", (i - Color_Black));
1004#ifdef XPM_BACKGROUND 1026#ifdef XPM_BACKGROUND
1006#endif 1028#endif
1007 break; 1029 break;
1008 } 1030 }
1009 1031
1010 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); 1032 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr);
1011
1012#ifndef NO_BRIGHTCOLOR
1013 colorfgbg = DEFAULT_RSTYLE;
1014 for (i = minCOLOR; i <= maxCOLOR; i++)
1015 {
1016 if (pix_colors[Color_fg] == pix_colors[i])
1017 colorfgbg = SET_FGCOLOR (colorfgbg, i);
1018 if (pix_colors[Color_bg] == pix_colors[i])
1019 colorfgbg = SET_BGCOLOR (colorfgbg, i);
1020 }
1021#endif
1022} 1033}
1023 1034
1024/*----------------------------------------------------------------------*/ 1035/*----------------------------------------------------------------------*/
1025/* 1036/*
1026 * Colour determination for low colour displays, routine from 1037 * Colour determination for low colour displays, routine from

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines