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.6 by pcg, Tue Nov 25 17:11:33 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.6 2003/11/25 17:11:33 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
47rxvt_term::rxvt_term()
48: pty_ev(this, &rxvt_term::pty_cb),
49 x_ev (this, &rxvt_term::x_cb)
50{
51 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
52}
53
54void * 47void *
55rxvt_term::operator new (size_t s) 48rxvt_term::operator new (size_t s)
56{ 49{
57 void *p = malloc (s); 50 void *p = malloc (s);
58 51
62 55
63void 56void
64rxvt_term::operator delete (void *p, size_t s) 57rxvt_term::operator delete (void *p, size_t s)
65{ 58{
66 free (p); 59 free (p);
60}
61
62rxvt_term::rxvt_term ()
63: pty_ev (this, &rxvt_term::pty_cb),
64#ifdef CURSOR_BLINK
65 blink_ev (this, &rxvt_term::blink_cb),
66#endif
67#ifdef POINTER_BLANK
68 pointer_ev (this, &rxvt_term::pointer_cb),
69#endif
70 x_ev (this, &rxvt_term::x_cb)
71{
72 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
73}
74
75rxvt_term::~rxvt_term ()
76{
77 delete PixColors;
67} 78}
68 79
69/*----------------------------------------------------------------------*/ 80/*----------------------------------------------------------------------*/
70/* rxvt_init() */ 81/* rxvt_init() */
71/* LIBPROTO */ 82/* LIBPROTO */
72rxvt_t 83rxvt_t
73rxvt_init(int argc, const char *const *argv) 84rxvt_init(int argc, const char *const *argv)
74{ 85{
75 const char **cmd_argv;
76
77 SET_R(new rxvt_term); 86 SET_R(new rxvt_term);
78 dR; 87 dR;
79 88
80 if (rxvt_init_vars(aR) < 0) 89 if (!R->init_vars () || !R->init (argc, argv))
81 { 90 {
82 free(R); 91 delete R;
83 return NULL; 92 return NULL;
84 } 93 }
85 94
86/* 95 return R;
96}
97
98bool
99rxvt_term::init (int argc, const char *const *argv)
100{
101 dR;//TODO (scrollbar, setidle)
102
103 /*
87 * Save and then give up any super-user privileges 104 * Save and then give up any super-user privileges
88 * If we need privileges in any area then we must specifically request it. 105 * If we need privileges in any area then we must specifically request it.
89 * We should only need to be root in these cases: 106 * We should only need to be root in these cases:
90 * 1. write utmp entries on some systems 107 * 1. write utmp entries on some systems
91 * 2. chown tty on some systems 108 * 2. chown tty on some systems
92 */ 109 */
93 rxvt_privileges(aR_ SAVE); 110 rxvt_privileges (this, SAVE);
94 rxvt_privileges(aR_ IGNORE); 111 rxvt_privileges (this, IGNORE);
95 112
96 rxvt_init_secondary(aR); 113 rxvt_init_secondary (this);
97 114
98 cmd_argv = rxvt_init_resources(aR_ argc, argv); 115 const char **cmd_argv = rxvt_init_resources (this, argc, argv);
99
100 R->x_ev.start (ConnectionNumber (R->Xdisplay), EVENT_READ);
101 116
102#if (MENUBAR_MAX) 117#if (MENUBAR_MAX)
103 rxvt_menubar_read(aR_ R->rs[Rs_menu]); 118 rxvt_menubar_read (this, rs[Rs_menu]);
104#endif 119#endif
105#ifdef HAVE_SCROLLBARS 120#ifdef HAVE_SCROLLBARS
106 if (R->Options & Opt_scrollBar) 121 if (Options & Opt_scrollBar)
107 scrollbar_setIdle(); /* set existence for size calculations */ 122 scrollbar_setIdle (); /* set existence for size calculations */
108#endif 123#endif
109 124
110 rxvt_Create_Windows(aR_ argc, argv); 125 rxvt_Create_Windows (this, argc, argv);
111 126
112 rxvt_init_xlocale(aR); 127 rxvt_init_xlocale (this);
113 128
114 rxvt_scr_reset(aR); /* initialize screen */ 129 rxvt_scr_reset (this); /* initialize screen */
115#ifdef RXVT_GRAPHICS 130#ifdef RXVT_GRAPHICS
116 rxvt_Gr_reset(aR); /* reset graphics */ 131 rxvt_Gr_reset (this); /* reset graphics */
117#endif 132#endif
118 133
119#if 0 134#if 0
120#ifdef DEBUG_X 135#ifdef DEBUG_X
121 XSynchronize(R->Xdisplay, True); 136 XSynchronize(Xdisplay, True);
122 XSetErrorHandler((XErrorHandler) abort); 137 XSetErrorHandler((XErrorHandler) abort);
123#else 138#else
124 XSetErrorHandler((XErrorHandler) rxvt_xerror_handler); 139 XSetErrorHandler((XErrorHandler) rxvt_xerror_handler);
125#endif 140#endif
126#endif 141#endif
127 142
128#ifdef HAVE_SCROLLBARS 143#ifdef HAVE_SCROLLBARS
129 if (R->Options & Opt_scrollBar) 144 if (Options & Opt_scrollBar)
130 rxvt_Resize_scrollBar(aR); /* create and map scrollbar */ 145 rxvt_Resize_scrollBar (this); /* create and map scrollbar */
131#endif 146#endif
132#if (MENUBAR_MAX) 147#if (MENUBAR_MAX)
133 if (menubar_visible(r)) 148 if (menubar_visible(r))
134 XMapWindow(R->Xdisplay, R->menuBar.win); 149 XMapWindow (Xdisplay, menuBar.win);
135#endif 150#endif
136#ifdef TRANSPARENT 151#ifdef TRANSPARENT
137 if (R->Options & Opt_transparent) 152 if (Options & Opt_transparent)
138 { 153 {
139 XSelectInput(R->Xdisplay, Xroot, PropertyChangeMask); 154 XSelectInput (Xdisplay, Xroot, PropertyChangeMask);
140 rxvt_check_our_parents(aR); 155 rxvt_check_our_parents (this);
141 } 156 }
142#endif 157#endif
143 XMapWindow(R->Xdisplay, R->TermWin.vt); 158 XMapWindow (Xdisplay, TermWin.vt);
144 XMapWindow(R->Xdisplay, R->TermWin.parent[0]); 159 XMapWindow (Xdisplay, TermWin.parent[0]);
145 160
146 rxvt_init_env(aR); 161 rxvt_init_env (this);
147 rxvt_init_command(aR_ cmd_argv); 162 rxvt_init_command (this, cmd_argv);
148 163
164 x_ev.start (Xfd, EVENT_READ);
149 R->pty_ev.start (R->cmd_fd, EVENT_READ); 165 pty_ev.start (cmd_fd, EVENT_READ);
150 166
151 return R; 167 return true;
152} 168}
153 169
154/* ------------------------------------------------------------------------- * 170/* ------------------------------------------------------------------------- *
155 * SIGNAL HANDLING & EXIT HANDLER * 171 * SIGNAL HANDLING & EXIT HANDLER *
156 * ------------------------------------------------------------------------- */ 172 * ------------------------------------------------------------------------- */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines