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.3 by pcg, Tue Nov 25 11:52:42 2003 UTC vs.
Revision 1.4 by pcg, Tue Nov 25 15:25:17 2003 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: main.c 2 * File: main.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: main.C,v 1.3 2003/11/25 11:52:42 pcg Exp $ 4 * $Id: main.C,v 1.4 2003/11/25 15:25:17 pcg Exp $
5 * 5 *
6 * All portions of code are copyright by their respective author/s. 6 * All portions of code are copyright by their respective author/s.
7 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 7 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
8 * - original version 8 * - original version
9 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> 9 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
42 42
43#ifdef HAVE_TERMIOS_H 43#ifdef HAVE_TERMIOS_H
44# include <termios.h> 44# include <termios.h>
45#endif 45#endif
46 46
47void *
48rxvt_term::operator new (size_t s)
49{
50 void *p = malloc (s);
51
52 MEMSET (p, 0, s);
53 return p;
54}
55
56void
57rxvt_term::operator delete (void *p, size_t s)
58{
59 free (p);
60}
61
47rxvt_term::rxvt_term() 62rxvt_term::rxvt_term ()
48: pty_ev(this, &rxvt_term::pty_cb), 63: pty_ev(this, &rxvt_term::pty_cb),
49 x_ev (this, &rxvt_term::x_cb) 64 x_ev (this, &rxvt_term::x_cb)
50{ 65{
51 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 66 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
52} 67}
53 68
54void * 69rxvt_term::~rxvt_term ()
55rxvt_term::operator new (size_t s)
56{ 70{
57 void *p = malloc (s); 71 delete PixColors;
58
59 MEMSET (p, 0, s);
60 return p;
61}
62
63void
64rxvt_term::operator delete (void *p, size_t s)
65{
66 free (p);
67} 72}
68 73
69/*----------------------------------------------------------------------*/ 74/*----------------------------------------------------------------------*/
70/* rxvt_init() */ 75/* rxvt_init() */
71/* LIBPROTO */ 76/* LIBPROTO */
72rxvt_t 77rxvt_t
73rxvt_init(int argc, const char *const *argv) 78rxvt_init(int argc, const char *const *argv)
74{ 79{
75 const char **cmd_argv;
76
77 SET_R(new rxvt_term); 80 SET_R(new rxvt_term);
78 dR; 81 dR;
79 82
80 if (rxvt_init_vars(aR) < 0) 83 if (!R->init_vars () || !R->init (argc, argv))
81 { 84 {
82 free(R); 85 delete R;
83 return NULL; 86 return NULL;
84 } 87 }
85 88
86/* 89 return R;
90}
91
92bool
93rxvt_term::init (int argc, const char *const *argv)
94{
95 dR;//TODO (scrollbar, setidle)
96
97 /*
87 * Save and then give up any super-user privileges 98 * Save and then give up any super-user privileges
88 * If we need privileges in any area then we must specifically request it. 99 * If we need privileges in any area then we must specifically request it.
89 * We should only need to be root in these cases: 100 * We should only need to be root in these cases:
90 * 1. write utmp entries on some systems 101 * 1. write utmp entries on some systems
91 * 2. chown tty on some systems 102 * 2. chown tty on some systems
92 */ 103 */
93 rxvt_privileges(aR_ SAVE); 104 rxvt_privileges (this, SAVE);
94 rxvt_privileges(aR_ IGNORE); 105 rxvt_privileges (this, IGNORE);
95 106
96 rxvt_init_secondary(aR); 107 rxvt_init_secondary (this);
97 108
98 cmd_argv = rxvt_init_resources(aR_ argc, argv); 109 const char **cmd_argv = rxvt_init_resources (this, argc, argv);
99
100 R->x_ev.start (ConnectionNumber (R->Xdisplay), EVENT_READ);
101 110
102#if (MENUBAR_MAX) 111#if (MENUBAR_MAX)
103 rxvt_menubar_read(aR_ R->rs[Rs_menu]); 112 rxvt_menubar_read (this, rs[Rs_menu]);
104#endif 113#endif
105#ifdef HAVE_SCROLLBARS 114#ifdef HAVE_SCROLLBARS
106 if (R->Options & Opt_scrollBar) 115 if (Options & Opt_scrollBar)
107 scrollbar_setIdle(); /* set existence for size calculations */ 116 scrollbar_setIdle (); /* set existence for size calculations */
108#endif 117#endif
109 118
110 rxvt_Create_Windows(aR_ argc, argv); 119 rxvt_Create_Windows (this, argc, argv);
111 120
112 rxvt_init_xlocale(aR); 121 rxvt_init_xlocale (this);
113 122
114 rxvt_scr_reset(aR); /* initialize screen */ 123 rxvt_scr_reset (this); /* initialize screen */
115#ifdef RXVT_GRAPHICS 124#ifdef RXVT_GRAPHICS
116 rxvt_Gr_reset(aR); /* reset graphics */ 125 rxvt_Gr_reset (this); /* reset graphics */
117#endif 126#endif
118 127
119#if 0 128#if 0
120#ifdef DEBUG_X 129#ifdef DEBUG_X
121 XSynchronize(R->Xdisplay, True); 130 XSynchronize(Xdisplay, True);
122 XSetErrorHandler((XErrorHandler) abort); 131 XSetErrorHandler((XErrorHandler) abort);
123#else 132#else
124 XSetErrorHandler((XErrorHandler) rxvt_xerror_handler); 133 XSetErrorHandler((XErrorHandler) rxvt_xerror_handler);
125#endif 134#endif
126#endif 135#endif
127 136
128#ifdef HAVE_SCROLLBARS 137#ifdef HAVE_SCROLLBARS
129 if (R->Options & Opt_scrollBar) 138 if (Options & Opt_scrollBar)
130 rxvt_Resize_scrollBar(aR); /* create and map scrollbar */ 139 rxvt_Resize_scrollBar (this); /* create and map scrollbar */
131#endif 140#endif
132#if (MENUBAR_MAX) 141#if (MENUBAR_MAX)
133 if (menubar_visible(r)) 142 if (menubar_visible(r))
134 XMapWindow(R->Xdisplay, R->menuBar.win); 143 XMapWindow (Xdisplay, menuBar.win);
135#endif 144#endif
136#ifdef TRANSPARENT 145#ifdef TRANSPARENT
137 if (R->Options & Opt_transparent) 146 if (Options & Opt_transparent)
138 { 147 {
139 XSelectInput(R->Xdisplay, Xroot, PropertyChangeMask); 148 XSelectInput (Xdisplay, Xroot, PropertyChangeMask);
140 rxvt_check_our_parents(aR); 149 rxvt_check_our_parents (this);
141 } 150 }
142#endif 151#endif
143 XMapWindow(R->Xdisplay, R->TermWin.vt); 152 XMapWindow (Xdisplay, TermWin.vt);
144 XMapWindow(R->Xdisplay, R->TermWin.parent[0]); 153 XMapWindow (Xdisplay, TermWin.parent[0]);
145 154
146 rxvt_init_env(aR); 155 rxvt_init_env (this);
147 rxvt_init_command(aR_ cmd_argv); 156 rxvt_init_command (this, cmd_argv);
148 157
158 x_ev.start (Xfd, EVENT_READ);
149 R->pty_ev.start (R->cmd_fd, EVENT_READ); 159 pty_ev.start (cmd_fd, EVENT_READ);
150 160
151 return R; 161 return true;
152} 162}
153 163
154/* ------------------------------------------------------------------------- * 164/* ------------------------------------------------------------------------- *
155 * SIGNAL HANDLING & EXIT HANDLER * 165 * SIGNAL HANDLING & EXIT HANDLER *
156 * ------------------------------------------------------------------------- */ 166 * ------------------------------------------------------------------------- */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines