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.116 by root, Sun Nov 21 19:04:07 2004 UTC vs.
Revision 1.132 by root, Thu Feb 3 07:18:30 2005 UTC

32 32
33#include "../config.h" /* NECESSARY */ 33#include "../config.h" /* NECESSARY */
34#include "rxvt.h" /* NECESSARY */ 34#include "rxvt.h" /* NECESSARY */
35#include "main.intpro" /* PROTOS for internal routines */ 35#include "main.intpro" /* PROTOS for internal routines */
36 36
37#include <signal.h> 37#include <csignal>
38#include <cstring>
38 39
39#ifdef TTY_GID_SUPPORT 40#ifdef TTY_GID_SUPPORT
40# include <grp.h> 41# include <grp.h>
41#endif 42#endif
42 43
43#ifdef HAVE_TERMIOS_H 44#ifdef HAVE_TERMIOS_H
44# include <termios.h> 45# include <termios.h>
45#endif 46#endif
46 47
47#include <cstring> 48#ifdef KEYSYM_RESOURCE
49# include "keyboard.h"
50#endif
48 51
49vector<rxvt_term *> rxvt_term::termlist; 52vector<rxvt_term *> rxvt_term::termlist;
50 53
51static char curlocale[128]; 54static char curlocale[128];
52 55
156#endif 159#endif
157#ifdef USE_XIM 160#ifdef USE_XIM
158 im_ev (this, &rxvt_term::im_cb), 161 im_ev (this, &rxvt_term::im_cb),
159#endif 162#endif
160 sw_term (this, &rxvt_term::sig_term), 163 sw_term (this, &rxvt_term::sig_term),
164 sw_int (this, &rxvt_term::sig_term),
161 sw_chld (this, &rxvt_term::sig_chld), 165 sw_chld (this, &rxvt_term::sig_chld),
162 termwin_ev (this, &rxvt_term::x_cb), 166 termwin_ev (this, &rxvt_term::x_cb),
163 vt_ev (this, &rxvt_term::x_cb), 167 vt_ev (this, &rxvt_term::x_cb),
164 check_ev (this, &rxvt_term::check_cb), 168 check_ev (this, &rxvt_term::check_cb),
165 flush_ev (this, &rxvt_term::flush_cb), 169 flush_ev (this, &rxvt_term::flush_cb),
168 incr_ev (this, &rxvt_term::incr_cb) 172 incr_ev (this, &rxvt_term::incr_cb)
169{ 173{
170 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 174 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
171 175
172 termlist.push_back (this); 176 termlist.push_back (this);
177
178#ifdef KEYSYM_RESOURCE
179 keyboard = new keyboard_manager;
180
181 if (!keyboard)
182 rxvt_fatal ("out of memory, aborting.\n");
183#endif
173} 184}
174 185
175rxvt_term::~rxvt_term () 186rxvt_term::~rxvt_term ()
176{ 187{
177 termlist.erase (find (termlist.begin (), termlist.end(), this)); 188 termlist.erase (find (termlist.begin (), termlist.end(), this));
178 189
179 if (cmd_pid) 190 if (cmd_pid)
180 kill (-cmd_pid, SIGHUP); 191 kill (-cmd_pid, SIGHUP);
181 192
182 pty.put ();
183
184#ifdef UTMP_SUPPORT 193#ifdef UTMP_SUPPORT
185 privileged_utmp (RESTORE); 194 privileged_utmp (RESTORE);
186#endif 195#endif
196
197 pty.put ();
187 198
188#if ENABLE_STYLES 199#if ENABLE_STYLES
189 for (int i = RS_styleCount; --i; ) 200 for (int i = RS_styleCount; --i; )
190 if (TermWin.fontset[i] != TermWin.fontset[0]) 201 if (TermWin.fontset[i] != TermWin.fontset[0])
191 delete TermWin.fontset[i]; 202 delete TermWin.fontset[i];
259 free (env_windowid); 270 free (env_windowid);
260 free (env_display); 271 free (env_display);
261 free (env_term); 272 free (env_term);
262 free (env_colorfgbg); 273 free (env_colorfgbg);
263 free (locale); 274 free (locale);
264#if 0 275 free (v_buffer);
265 free (codeset); 276 free (incr_buf);
266#endif
267 277
268 delete envv; 278 delete envv;
269 delete argv; 279 delete argv;
280
281#ifdef KEYSYM_RESOURCE
282 delete keyboard;
283#endif
270} 284}
271 285
272void 286void
273rxvt_term::destroy () 287rxvt_term::destroy ()
274{ 288{
332bool 346bool
333rxvt_term::init (int argc, const char *const *argv) 347rxvt_term::init (int argc, const char *const *argv)
334{ 348{
335 SET_R (this); 349 SET_R (this);
336 350
351 set_locale ("");
352
337 if (!init_vars ()) 353 if (!init_vars ())
338 return false; 354 return false;
339 355
340 init_secondary (); 356 init_secondary ();
341 357
342 const char **cmd_argv = init_resources (argc, argv); 358 const char **cmd_argv = init_resources (argc, argv);
343 359
344 set_locale (""); 360#ifdef KEYSYM_RESOURCE
361 keyboard->register_done ();
362#endif
345 363
346#if MENUBAR_MAX 364#if MENUBAR_MAX
347 menubar_read (rs[Rs_menu]); 365 menubar_read (rs[Rs_menu]);
348#endif 366#endif
349#ifdef HAVE_SCROLLBARS 367#ifdef HAVE_SCROLLBARS
355 373
356 init_xlocale (); 374 init_xlocale ();
357 375
358 scr_reset (); /* initialize screen */ 376 scr_reset (); /* initialize screen */
359 377
360#if 1 378#if 0
361 XSynchronize (display->display, True); 379 XSynchronize (display->display, True);
362#endif 380#endif
363 381
364#ifdef HAVE_SCROLLBARS 382#ifdef HAVE_SCROLLBARS
365 if (options & Opt_scrollBar) 383 if (options & Opt_scrollBar)
382 XMapWindow (display->display, TermWin.parent[0]); 400 XMapWindow (display->display, TermWin.parent[0]);
383 401
384 set_colorfgbg (); 402 set_colorfgbg ();
385 403
386 init_command (cmd_argv); 404 init_command (cmd_argv);
405
406 free (cmd_argv);
387 407
388 pty_ev.start (pty.pty, EVENT_READ); 408 pty_ev.start (pty.pty, EVENT_READ);
389 409
390 check_ev.start (); 410 check_ev.start ();
391 411
783 803
784 delete TermWin.fontset[0]; 804 delete TermWin.fontset[0];
785 TermWin.fontset[0] = fs; 805 TermWin.fontset[0] = fs;
786 806
787 prop = (*fs)[1]->properties (); 807 prop = (*fs)[1]->properties ();
808 prop.height += TermWin.lineSpace;
788 fs->set_prop (prop); 809 fs->set_prop (prop);
789 810
790 TermWin.fwidth = prop.width; 811 TermWin.fwidth = prop.width;
791 TermWin.fheight = prop.height; 812 TermWin.fheight = prop.height;
792 TermWin.fweight = prop.weight; 813 TermWin.fweight = prop.weight;
831 } 852 }
832 853
833 return true; 854 return true;
834} 855}
835 856
857void rxvt_term::set_string_property (Atom prop, const char *str, int len)
858{
859 // TODO: SMART_WINDOW_TITLE
860 XChangeProperty (display->display, TermWin.parent[0],
861 prop, XA_STRING, 8, PropModeReplace,
862 (const unsigned char *)str, len >= 0 ? len : strlen (str));
863}
864
865void rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
866{
867 // TODO: SMART_WINDOW_TITLE
868 wchar_t *ws = rxvt_mbstowcs (str, len);
869 char *s = rxvt_wcstoutf8 (ws);
870
871 XChangeProperty (display->display, TermWin.parent[0],
872 prop, xa[XA_UTF8_STRING], 8, PropModeReplace,
873 (const unsigned char *)s, strlen (s));
874
875 free (s);
876 free (ws);
877}
878
836/*----------------------------------------------------------------------*/ 879/*----------------------------------------------------------------------*/
837/*----------------------------------------------------------------------*/ 880/*----------------------------------------------------------------------*/
838/* xterm sequences - title, iconName, color (exptl) */ 881/* xterm sequences - title, iconName, color (exptl) */
839void 882void
840rxvt_term::set_title (const char *str) 883rxvt_term::set_title (const char *str)
841{ 884{
842#ifdef SMART_WINDOW_TITLE 885 set_string_property (XA_WM_NAME, str);
843 char *name; 886#if ENABLE_FRILLS
844 887 set_utf8_property (xa[XA_NET_WM_NAME], str);
845 if (!XFetchName (display->display, TermWin.parent[0], &name))
846 name = NULL;
847
848 if (name == NULL || strcmp (name, str))
849#endif
850 XStoreName (display->display, TermWin.parent[0], str);
851
852#ifdef SMART_WINDOW_TITLE
853 if (name)
854 XFree (name);
855#endif 888#endif
856} 889}
857 890
858void 891void
859rxvt_term::set_icon_name (const char *str) 892rxvt_term::set_icon_name (const char *str)
860{ 893{
861#ifdef SMART_WINDOW_TITLE 894 set_string_property (XA_WM_ICON_NAME, str);
862 char *name; 895#if ENABLE_FRILLS
863 896 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str);
864 if (!XGetIconName (display->display, TermWin.parent[0], &name))
865 name = NULL;
866
867 if (name == NULL || strcmp (name, str))
868#endif
869 XSetIconName (display->display, TermWin.parent[0], str);
870
871#ifdef SMART_WINDOW_TITLE
872 if (name)
873 XFree (name);
874#endif 897#endif
875} 898}
876 899
877#ifdef XTERM_COLOR_CHANGE 900#ifdef XTERM_COLOR_CHANGE
878void 901void
997 1020
998 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); 1021 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr);
999} 1022}
1000 1023
1001/*----------------------------------------------------------------------*/ 1024/*----------------------------------------------------------------------*/
1002/*
1003 * Colour determination for low colour displays, routine from
1004 * Hans de Goede <hans@highrise.nl>
1005 */
1006 1025
1007int 1026int
1008rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) 1027rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour)
1009{ 1028{
1010 if (!screen_in_out->set (display, colour)) 1029 if (!screen_in_out->set (display, colour))
1097 TermWin_TotalWidth (), menuBar_TotalHeight ()); 1116 TermWin_TotalWidth (), menuBar_TotalHeight ());
1098 1117
1099 XMoveResizeWindow (display->display, TermWin.vt, 1118 XMoveResizeWindow (display->display, TermWin.vt,
1100 window_vt_x, window_vt_y, 1119 window_vt_x, window_vt_y,
1101 TermWin_TotalWidth (), TermWin_TotalHeight ()); 1120 TermWin_TotalWidth (), TermWin_TotalHeight ());
1121
1102 scr_clear (); 1122 scr_clear ();
1103#ifdef XPM_BACKGROUND 1123#ifdef XPM_BACKGROUND
1104 resize_pixmap (); 1124 resize_pixmap ();
1105#endif 1125#endif
1106 } 1126 }
1128 } 1148 }
1129 } 1149 }
1130 1150
1131 old_width = szHint.width; 1151 old_width = szHint.width;
1132 old_height = szHint.height; 1152 old_height = szHint.height;
1153
1154#ifdef XPM_BACKGROUND
1155 if (TermWin.pixmap)
1156 scr_touch (false);
1157#endif
1133 1158
1134#ifdef USE_XIM 1159#ifdef USE_XIM
1135 IMSetStatusPosition (); 1160 IMSetStatusPosition ();
1136#endif 1161#endif
1137} 1162}
1367 "*", 1392 "*",
1368 TermWin.fheight, 1393 TermWin.fheight,
1369 TermWin.fheight + 1, TermWin.fheight - 1, 1394 TermWin.fheight + 1, TermWin.fheight - 1,
1370 TermWin.fheight - 2, TermWin.fheight + 2); 1395 TermWin.fheight - 2, TermWin.fheight + 2);
1371 1396
1372 fs = XCreateFontSet (display->display, pat, 1397 fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat,
1373 &missing_charset_list, &missing_charset_count, &def_string); 1398 &missing_charset_list, &missing_charset_count, &def_string);
1374 1399
1375 if (missing_charset_list) 1400 if (missing_charset_list)
1376 XFreeStringList (missing_charset_list); 1401 XFreeStringList (missing_charset_list);
1377 1402

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines