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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines