… | |
… | |
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 | |
49 | vector<rxvt_term *> rxvt_term::termlist; |
52 | vector<rxvt_term *> rxvt_term::termlist; |
50 | |
53 | |
51 | static char curlocale[128]; |
54 | static 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 | |
175 | rxvt_term::~rxvt_term () |
186 | rxvt_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]; |
… | |
… | |
264 | free (v_buffer); |
275 | free (v_buffer); |
265 | free (incr_buf); |
276 | free (incr_buf); |
266 | |
277 | |
267 | delete envv; |
278 | delete envv; |
268 | delete argv; |
279 | delete argv; |
|
|
280 | |
|
|
281 | #ifdef KEYSYM_RESOURCE |
|
|
282 | delete keyboard; |
|
|
283 | #endif |
269 | } |
284 | } |
270 | |
285 | |
271 | void |
286 | void |
272 | rxvt_term::destroy () |
287 | rxvt_term::destroy () |
273 | { |
288 | { |
… | |
… | |
331 | bool |
346 | bool |
332 | rxvt_term::init (int argc, const char *const *argv) |
347 | rxvt_term::init (int argc, const char *const *argv) |
333 | { |
348 | { |
334 | SET_R (this); |
349 | SET_R (this); |
335 | |
350 | |
|
|
351 | set_locale (""); |
|
|
352 | |
336 | if (!init_vars ()) |
353 | if (!init_vars ()) |
337 | return false; |
354 | return false; |
338 | |
355 | |
339 | init_secondary (); |
356 | init_secondary (); |
340 | |
357 | |
341 | const char **cmd_argv = init_resources (argc, argv); |
358 | const char **cmd_argv = init_resources (argc, argv); |
342 | |
359 | |
343 | set_locale (""); |
360 | #ifdef KEYSYM_RESOURCE |
|
|
361 | keyboard->register_done (); |
|
|
362 | #endif |
344 | |
363 | |
345 | #if MENUBAR_MAX |
364 | #if MENUBAR_MAX |
346 | menubar_read (rs[Rs_menu]); |
365 | menubar_read (rs[Rs_menu]); |
347 | #endif |
366 | #endif |
348 | #ifdef HAVE_SCROLLBARS |
367 | #ifdef HAVE_SCROLLBARS |
… | |
… | |
381 | XMapWindow (display->display, TermWin.parent[0]); |
400 | XMapWindow (display->display, TermWin.parent[0]); |
382 | |
401 | |
383 | set_colorfgbg (); |
402 | set_colorfgbg (); |
384 | |
403 | |
385 | init_command (cmd_argv); |
404 | init_command (cmd_argv); |
|
|
405 | |
|
|
406 | free (cmd_argv); |
386 | |
407 | |
387 | pty_ev.start (pty.pty, EVENT_READ); |
408 | pty_ev.start (pty.pty, EVENT_READ); |
388 | |
409 | |
389 | check_ev.start (); |
410 | check_ev.start (); |
390 | |
411 | |
… | |
… | |
782 | |
803 | |
783 | delete TermWin.fontset[0]; |
804 | delete TermWin.fontset[0]; |
784 | TermWin.fontset[0] = fs; |
805 | TermWin.fontset[0] = fs; |
785 | |
806 | |
786 | prop = (*fs)[1]->properties (); |
807 | prop = (*fs)[1]->properties (); |
|
|
808 | prop.height += TermWin.lineSpace; |
787 | fs->set_prop (prop); |
809 | fs->set_prop (prop); |
788 | |
810 | |
789 | TermWin.fwidth = prop.width; |
811 | TermWin.fwidth = prop.width; |
790 | TermWin.fheight = prop.height; |
812 | TermWin.fheight = prop.height; |
791 | TermWin.fweight = prop.weight; |
813 | TermWin.fweight = prop.weight; |
… | |
… | |
1094 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1116 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1095 | |
1117 | |
1096 | XMoveResizeWindow (display->display, TermWin.vt, |
1118 | XMoveResizeWindow (display->display, TermWin.vt, |
1097 | window_vt_x, window_vt_y, |
1119 | window_vt_x, window_vt_y, |
1098 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1120 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
|
|
1121 | |
1099 | scr_clear (); |
1122 | scr_clear (); |
1100 | #ifdef XPM_BACKGROUND |
1123 | #ifdef XPM_BACKGROUND |
1101 | resize_pixmap (); |
1124 | resize_pixmap (); |
1102 | #endif |
1125 | #endif |
1103 | } |
1126 | } |
… | |
… | |
1125 | } |
1148 | } |
1126 | } |
1149 | } |
1127 | |
1150 | |
1128 | old_width = szHint.width; |
1151 | old_width = szHint.width; |
1129 | old_height = szHint.height; |
1152 | old_height = szHint.height; |
|
|
1153 | |
|
|
1154 | #ifdef XPM_BACKGROUND |
|
|
1155 | if (TermWin.pixmap) |
|
|
1156 | scr_touch (false); |
|
|
1157 | #endif |
1130 | |
1158 | |
1131 | #ifdef USE_XIM |
1159 | #ifdef USE_XIM |
1132 | IMSetStatusPosition (); |
1160 | IMSetStatusPosition (); |
1133 | #endif |
1161 | #endif |
1134 | } |
1162 | } |
… | |
… | |
1364 | "*", |
1392 | "*", |
1365 | TermWin.fheight, |
1393 | TermWin.fheight, |
1366 | TermWin.fheight + 1, TermWin.fheight - 1, |
1394 | TermWin.fheight + 1, TermWin.fheight - 1, |
1367 | TermWin.fheight - 2, TermWin.fheight + 2); |
1395 | TermWin.fheight - 2, TermWin.fheight + 2); |
1368 | |
1396 | |
1369 | fs = XCreateFontSet (display->display, pat, |
1397 | fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat, |
1370 | &missing_charset_list, &missing_charset_count, &def_string); |
1398 | &missing_charset_list, &missing_charset_count, &def_string); |
1371 | |
1399 | |
1372 | if (missing_charset_list) |
1400 | if (missing_charset_list) |
1373 | XFreeStringList (missing_charset_list); |
1401 | XFreeStringList (missing_charset_list); |
1374 | |
1402 | |