1 | /*--------------------------------*-C-*---------------------------------*; |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: main.c |
2 | * File: main.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * - original version |
7 | * - original version |
… | |
… | |
44 | # include <termios.h> |
44 | # include <termios.h> |
45 | #endif |
45 | #endif |
46 | |
46 | |
47 | #include <cstring> |
47 | #include <cstring> |
48 | |
48 | |
|
|
49 | vector<rxvt_term *> rxvt_term::termlist; |
|
|
50 | |
49 | static char curlocale[128]; |
51 | static char curlocale[128]; |
50 | |
52 | |
51 | void |
53 | bool |
52 | rxvt_set_locale (const char *locale) |
54 | rxvt_set_locale (const char *locale) |
53 | { |
55 | { |
54 | if (locale && STRNCMP (locale, curlocale, 128)) |
56 | if (!locale || !STRNCMP (locale, curlocale, 128)) |
55 | { |
57 | return false; |
|
|
58 | |
56 | STRNCPY (curlocale, locale, 128); |
59 | STRNCPY (curlocale, locale, 128); |
57 | setlocale (LC_CTYPE, curlocale); |
60 | setlocale (LC_CTYPE, curlocale); |
58 | } |
61 | return true; |
59 | } |
62 | } |
60 | |
63 | |
61 | #if ENABLE_COMBINING |
64 | #if ENABLE_COMBINING |
62 | class rxvt_composite_vec rxvt_composite; |
65 | class rxvt_composite_vec rxvt_composite; |
63 | |
66 | |
64 | text_t rxvt_composite_vec::compose (uint32_t c1, uint32_t c2) |
67 | text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2) |
65 | { |
68 | { |
66 | compose_char *cc; |
69 | compose_char *cc; |
67 | |
70 | |
68 | // break compose chains, as stupid readline really likes to duplicate |
71 | // break compose chains, as stupid readline really likes to duplicate |
69 | // composing characters for some reason near the end of a line. |
72 | // composing characters for some reason near the end of a line. |
… | |
… | |
95 | v.push_back (compose_char (c1, c2)); |
98 | v.push_back (compose_char (c1, c2)); |
96 | |
99 | |
97 | return v.size () - 1 + COMPOSE_LO; |
100 | return v.size () - 1 + COMPOSE_LO; |
98 | } |
101 | } |
99 | |
102 | |
100 | int rxvt_composite_vec::expand (uint32_t c, wchar_t *r) |
103 | int rxvt_composite_vec::expand (unicode_t c, wchar_t *r) |
101 | { |
104 | { |
102 | compose_char *cc = (*this)[c]; |
105 | compose_char *cc = (*this)[c]; |
103 | |
106 | |
104 | if (!cc) |
107 | if (!cc) |
105 | { |
108 | { |
… | |
… | |
164 | destroy_ev (this, &rxvt_term::destroy_cb), |
167 | destroy_ev (this, &rxvt_term::destroy_cb), |
165 | pty_ev (this, &rxvt_term::pty_cb), |
168 | pty_ev (this, &rxvt_term::pty_cb), |
166 | incr_ev (this, &rxvt_term::incr_cb) |
169 | incr_ev (this, &rxvt_term::incr_cb) |
167 | { |
170 | { |
168 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
171 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
|
|
172 | |
|
|
173 | termlist.push_back (this); |
169 | } |
174 | } |
170 | |
175 | |
171 | rxvt_term::~rxvt_term () |
176 | rxvt_term::~rxvt_term () |
172 | { |
177 | { |
|
|
178 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
|
|
179 | |
173 | if (cmd_fd >= 0) |
180 | if (cmd_fd >= 0) |
174 | close (cmd_fd); |
181 | close (cmd_fd); |
175 | |
182 | |
176 | #ifndef NO_SETOWNER_TTYDEV |
183 | #ifndef NO_SETOWNER_TTYDEV |
177 | privileged_ttydev (RESTORE); |
184 | privileged_ttydev (RESTORE); |
… | |
… | |
182 | |
189 | |
183 | delete TermWin.fontset; |
190 | delete TermWin.fontset; |
184 | |
191 | |
185 | if (display) |
192 | if (display) |
186 | { |
193 | { |
|
|
194 | selection_clear (); |
|
|
195 | |
|
|
196 | #ifdef MENUBAR |
|
|
197 | if (menubarGC) XFreeGC (display->display, menubarGC); |
|
|
198 | #endif |
|
|
199 | #ifdef XTERM_SCROLLBAR |
|
|
200 | if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); |
|
|
201 | if (ShadowGC) XFreeGC (display->display, ShadowGC); |
|
|
202 | #endif |
|
|
203 | #ifdef PLAIN_SCROLLBAR |
|
|
204 | if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC); |
|
|
205 | #endif |
|
|
206 | #ifdef NEXT_SCROLLBAR |
|
|
207 | if (blackGC) XFreeGC (display->display, blackGC); |
|
|
208 | if (whiteGC) XFreeGC (display->display, whiteGC); |
|
|
209 | if (grayGC) XFreeGC (display->display, grayGC); |
|
|
210 | if (darkGC) XFreeGC (display->display, darkGC); |
|
|
211 | if (stippleGC) XFreeGC (display->display, stippleGC); |
|
|
212 | if (dimple) XFreePixmap (display->display, dimple); |
|
|
213 | if (upArrow) XFreePixmap (display->display, upArrow); |
|
|
214 | if (downArrow) XFreePixmap (display->display, downArrow); |
|
|
215 | if (upArrowHi) XFreePixmap (display->display, upArrowHi); |
|
|
216 | if (downArrowHi) XFreePixmap (display->display, downArrowHi); |
|
|
217 | #endif |
|
|
218 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
|
|
219 | if (topShadowGC) XFreeGC (display->display, topShadowGC); |
|
|
220 | if (botShadowGC) XFreeGC (display->display, botShadowGC); |
|
|
221 | if (scrollbarGC) XFreeGC (display->display, scrollbarGC); |
|
|
222 | #endif |
|
|
223 | if (TermWin.gc) XFreeGC (display->display, TermWin.gc); |
|
|
224 | |
187 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
225 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
188 | delete menuBar.drawable; |
226 | delete menuBar.drawable; |
189 | //if (menuBar.win) |
227 | //if (menuBar.win) |
190 | // XDestroyWindow (display->display, menuBar.win); |
228 | // XDestroyWindow (display->display, menuBar.win); |
191 | #endif |
229 | #endif |
… | |
… | |
201 | |
239 | |
202 | displays.put (display); |
240 | displays.put (display); |
203 | |
241 | |
204 | scr_release (); |
242 | scr_release (); |
205 | |
243 | |
|
|
244 | /* clear all resources */ |
|
|
245 | for (int i = 0; i < allocated.size (); i++) |
|
|
246 | free (allocated[i]); |
|
|
247 | |
|
|
248 | free (selection.text); |
|
|
249 | // TODO: manage env vars in child only(!) |
206 | free (env_windowid); |
250 | free (env_windowid); |
207 | free (env_display); |
251 | free (env_display); |
208 | free (env_term); |
252 | free (env_term); |
209 | free (env_colorfgbg); |
253 | free (env_colorfgbg); |
210 | free (locale); |
254 | free (locale); |
|
|
255 | #if 0 |
211 | free (codeset); |
256 | free (codeset); |
|
|
257 | #endif |
212 | |
258 | |
213 | delete envv; |
259 | delete envv; |
214 | delete argv; |
260 | delete argv; |
215 | } |
261 | } |
216 | |
262 | |
… | |
… | |
257 | delete this; |
303 | delete this; |
258 | } |
304 | } |
259 | |
305 | |
260 | /*----------------------------------------------------------------------*/ |
306 | /*----------------------------------------------------------------------*/ |
261 | /* rxvt_init () */ |
307 | /* rxvt_init () */ |
262 | /* LIBPROTO */ |
|
|
263 | rxvt_t |
|
|
264 | rxvt_init (int argc, const char *const *argv) |
|
|
265 | { |
|
|
266 | SET_R (new rxvt_term); |
|
|
267 | |
|
|
268 | if (!GET_R->init_vars () || !GET_R->init (argc, argv)) |
|
|
269 | { |
|
|
270 | delete GET_R; |
|
|
271 | SET_R (0); |
|
|
272 | } |
|
|
273 | |
|
|
274 | return GET_R; |
|
|
275 | } |
|
|
276 | |
|
|
277 | static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); |
|
|
278 | |
|
|
279 | void |
|
|
280 | rxvt_init_signals () |
|
|
281 | { |
|
|
282 | /* install exit handler for cleanup */ |
|
|
283 | #if 0 |
|
|
284 | #ifdef HAVE_ATEXIT |
|
|
285 | atexit (rxvt_clean_exit); |
|
|
286 | #else |
|
|
287 | #endif |
|
|
288 | #endif |
|
|
289 | |
|
|
290 | struct sigaction sa; |
|
|
291 | |
|
|
292 | sigfillset (&sa.sa_mask); |
|
|
293 | sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; |
|
|
294 | sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0); |
|
|
295 | sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); |
|
|
296 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0); |
|
|
297 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0); |
|
|
298 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0); |
|
|
299 | sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0); |
|
|
300 | |
|
|
301 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
|
|
302 | /* signal (SIGURG, SIG_DFL); */ |
|
|
303 | |
|
|
304 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
|
|
305 | //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); |
|
|
306 | } |
|
|
307 | |
|
|
308 | bool |
308 | bool |
309 | rxvt_term::init (int argc, const char *const *argv) |
309 | rxvt_term::init (int argc, const char *const *argv) |
310 | { |
310 | { |
|
|
311 | SET_R (this); |
|
|
312 | |
|
|
313 | if (!init_vars ()) |
|
|
314 | return false; |
|
|
315 | |
311 | /* |
316 | /* |
312 | * Save and then give up any super-user privileges |
317 | * Save and then give up any super-user privileges |
313 | * If we need privileges in any area then we must specifically request it. |
318 | * If we need privileges in any area then we must specifically request it. |
314 | * We should only need to be root in these cases: |
319 | * We should only need to be root in these cases: |
315 | * 1. write utmp entries on some systems |
320 | * 1. write utmp entries on some systems |
… | |
… | |
370 | check_ev.start (); |
375 | check_ev.start (); |
371 | |
376 | |
372 | return true; |
377 | return true; |
373 | } |
378 | } |
374 | |
379 | |
|
|
380 | static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); |
|
|
381 | |
|
|
382 | void |
|
|
383 | rxvt_init_signals () |
|
|
384 | { |
|
|
385 | /* install exit handler for cleanup */ |
|
|
386 | #if 0 |
|
|
387 | #ifdef HAVE_ATEXIT |
|
|
388 | atexit (rxvt_clean_exit); |
|
|
389 | #else |
|
|
390 | #endif |
|
|
391 | #endif |
|
|
392 | |
|
|
393 | struct sigaction sa; |
|
|
394 | |
|
|
395 | sigfillset (&sa.sa_mask); |
|
|
396 | sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; |
|
|
397 | sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0); |
|
|
398 | sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); |
|
|
399 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0); |
|
|
400 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0); |
|
|
401 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0); |
|
|
402 | sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0); |
|
|
403 | |
|
|
404 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
|
|
405 | /* signal (SIGURG, SIG_DFL); */ |
|
|
406 | |
|
|
407 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
|
|
408 | //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); |
|
|
409 | } |
|
|
410 | |
375 | /* ------------------------------------------------------------------------- * |
411 | /* ------------------------------------------------------------------------- * |
376 | * SIGNAL HANDLING & EXIT HANDLER * |
412 | * SIGNAL HANDLING & EXIT HANDLER * |
377 | * ------------------------------------------------------------------------- */ |
413 | * ------------------------------------------------------------------------- */ |
378 | /* |
414 | /* |
379 | * Catch a SIGCHLD signal and exit if the direct child has died |
415 | * Catch a SIGCHLD signal and exit if the direct child has died |
380 | */ |
416 | */ |
|
|
417 | |
|
|
418 | void rxvt_term::child_exited (int pid) |
|
|
419 | { |
|
|
420 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
|
|
421 | if (pid == (*t)->cmd_pid) |
|
|
422 | { |
|
|
423 | (*t)->destroy (); |
|
|
424 | break; |
|
|
425 | } |
|
|
426 | } |
|
|
427 | |
381 | /* ARGSUSED */ |
428 | /* ARGSUSED */ |
382 | /* EXTPROTO */ |
429 | /* EXTPROTO */ |
383 | RETSIGTYPE |
430 | RETSIGTYPE |
384 | rxvt_Child_signal (int sig __attribute__ ((unused))) |
431 | rxvt_Child_signal (int sig __attribute__ ((unused))) |
385 | { |
432 | { |
386 | int pid, save_errno = errno; |
433 | int pid, save_errno = errno; |
|
|
434 | |
387 | while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) |
435 | while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) |
388 | ; |
436 | rxvt_term::child_exited (pid); |
|
|
437 | |
389 | errno = save_errno; |
438 | errno = save_errno; |
390 | |
|
|
391 | #if 0 |
|
|
392 | if (pid == cmd_pid) |
|
|
393 | exit (EXIT_SUCCESS); |
|
|
394 | #endif |
|
|
395 | } |
439 | } |
396 | |
440 | |
397 | /* |
441 | /* |
398 | * Catch a fatal signal and tidy up before quitting |
442 | * Catch a fatal signal and tidy up before quitting |
399 | */ |
443 | */ |
… | |
… | |
401 | RETSIGTYPE |
445 | RETSIGTYPE |
402 | rxvt_Exit_signal (int sig) |
446 | rxvt_Exit_signal (int sig) |
403 | { |
447 | { |
404 | signal (sig, SIG_DFL); |
448 | signal (sig, SIG_DFL); |
405 | #ifdef DEBUG_CMD |
449 | #ifdef DEBUG_CMD |
406 | rxvt_print_error ("signal %d", sig); |
450 | rxvt_warn ("caught signal %d, exiting.\n", sig); |
407 | #endif |
451 | #endif |
408 | rxvt_clean_exit (); |
452 | rxvt_clean_exit (); |
409 | kill (getpid (), sig); |
453 | kill (getpid (), sig); |
410 | } |
454 | } |
411 | |
455 | |
… | |
… | |
697 | |
741 | |
698 | szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; |
742 | szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; |
699 | |
743 | |
700 | sb_w = mb_h = 0; |
744 | sb_w = mb_h = 0; |
701 | window_vt_x = window_vt_y = 0; |
745 | window_vt_x = window_vt_y = 0; |
|
|
746 | |
702 | if (scrollbar_visible ()) |
747 | if (scrollbar_visible ()) |
703 | { |
748 | { |
704 | sb_w = scrollbar_TotalWidth (); |
749 | sb_w = scrollbar_TotalWidth (); |
705 | szHint.base_width += sb_w; |
750 | szHint.base_width += sb_w; |
706 | if (! (Options & Opt_scrollBar_right)) |
751 | if (! (Options & Opt_scrollBar_right)) |
707 | window_vt_x = sb_w; |
752 | window_vt_x = sb_w; |
708 | } |
753 | } |
|
|
754 | |
709 | if (menubar_visible ()) |
755 | if (menubar_visible ()) |
710 | { |
756 | { |
711 | mb_h = menuBar_TotalHeight (); |
757 | mb_h = menuBar_TotalHeight (); |
712 | szHint.base_height += mb_h; |
758 | szHint.base_height += mb_h; |
713 | window_vt_y = mb_h; |
759 | window_vt_y = mb_h; |
714 | } |
760 | } |
|
|
761 | |
715 | szHint.width_inc = TermWin.fwidth; |
762 | szHint.width_inc = TermWin.fwidth; |
716 | szHint.height_inc = TermWin.fheight; |
763 | szHint.height_inc = TermWin.fheight; |
717 | szHint.min_width = szHint.base_width + szHint.width_inc; |
764 | szHint.min_width = szHint.base_width + szHint.width_inc; |
718 | szHint.min_height = szHint.base_height + szHint.height_inc; |
765 | szHint.min_height = szHint.base_height + szHint.height_inc; |
719 | |
766 | |
… | |
… | |
725 | else |
772 | else |
726 | { |
773 | { |
727 | MIN_IT (TermWin.width, max_width); |
774 | MIN_IT (TermWin.width, max_width); |
728 | szHint.width = szHint.base_width + TermWin.width; |
775 | szHint.width = szHint.base_width + TermWin.width; |
729 | } |
776 | } |
|
|
777 | |
730 | if (height && height - szHint.base_height < max_height) |
778 | if (height && height - szHint.base_height < max_height) |
731 | { |
779 | { |
732 | szHint.height = height; |
780 | szHint.height = height; |
733 | TermWin.height = height - szHint.base_height; |
781 | TermWin.height = height - szHint.base_height; |
734 | } |
782 | } |
735 | else |
783 | else |
736 | { |
784 | { |
737 | MIN_IT (TermWin.height, max_height); |
785 | MIN_IT (TermWin.height, max_height); |
738 | szHint.height = szHint.base_height + TermWin.height; |
786 | szHint.height = szHint.base_height + TermWin.height; |
739 | } |
787 | } |
|
|
788 | |
740 | if (scrollbar_visible () && (Options & Opt_scrollBar_right)) |
789 | if (scrollbar_visible () && (Options & Opt_scrollBar_right)) |
741 | window_sb_x = szHint.width - sb_w; |
790 | window_sb_x = szHint.width - sb_w; |
742 | |
791 | |
743 | if (recalc_x) |
792 | if (recalc_x) |
744 | szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) |
793 | szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) |
… | |
… | |
838 | /*----------------------------------------------------------------------*/ |
887 | /*----------------------------------------------------------------------*/ |
839 | /* xterm sequences - title, iconName, color (exptl) */ |
888 | /* xterm sequences - title, iconName, color (exptl) */ |
840 | void |
889 | void |
841 | rxvt_term::set_title (const char *str) |
890 | rxvt_term::set_title (const char *str) |
842 | { |
891 | { |
843 | #ifndef SMART_WINDOW_TITLE |
892 | #ifdef SMART_WINDOW_TITLE |
844 | XStoreName (display->display, TermWin.parent[0], str); |
|
|
845 | #else |
|
|
846 | char *name; |
893 | char *name; |
847 | |
894 | |
848 | if (XFetchName (display->display, TermWin.parent[0], &name) == 0) |
895 | if (!XFetchName (display->display, TermWin.parent[0], &name)) |
849 | name = NULL; |
896 | name = NULL; |
|
|
897 | |
850 | if (name == NULL || STRCMP (name, str)) |
898 | if (name == NULL || STRCMP (name, str)) |
|
|
899 | #endif |
851 | XStoreName (display->display, TermWin.parent[0], str); |
900 | XStoreName (display->display, TermWin.parent[0], str); |
|
|
901 | |
|
|
902 | #ifdef SMART_WINDOW_TITLE |
852 | if (name) |
903 | if (name) |
853 | XFree (name); |
904 | XFree (name); |
854 | #endif |
905 | #endif |
855 | } |
906 | } |
856 | |
907 | |
857 | void |
908 | void |
858 | rxvt_term::set_iconName (const char *str) |
909 | rxvt_term::set_icon_name (const char *str) |
859 | { |
910 | { |
860 | #ifndef SMART_WINDOW_TITLE |
911 | #ifdef SMART_WINDOW_TITLE |
861 | XSetIconName (display->display, TermWin.parent[0], str); |
|
|
862 | #else |
|
|
863 | char *name; |
912 | char *name; |
864 | |
913 | |
865 | if (XGetIconName (display->display, TermWin.parent[0], &name)) |
914 | if (!XGetIconName (display->display, TermWin.parent[0], &name)) |
866 | name = NULL; |
915 | name = NULL; |
|
|
916 | |
867 | if (name == NULL || STRCMP (name, str)) |
917 | if (name == NULL || STRCMP (name, str)) |
|
|
918 | #endif |
868 | XSetIconName (display->display, TermWin.parent[0], str); |
919 | XSetIconName (display->display, TermWin.parent[0], str); |
|
|
920 | |
|
|
921 | #ifdef SMART_WINDOW_TITLE |
869 | if (name) |
922 | if (name) |
870 | XFree (name); |
923 | XFree (name); |
871 | #endif |
924 | #endif |
872 | } |
925 | } |
873 | |
926 | |
… | |
… | |
900 | PixColors[idx] = PixColors[minCOLOR + i]; |
953 | PixColors[idx] = PixColors[minCOLOR + i]; |
901 | SET_PIXCOLOR (idx); |
954 | SET_PIXCOLOR (idx); |
902 | goto Done; |
955 | goto Done; |
903 | } |
956 | } |
904 | } |
957 | } |
|
|
958 | |
905 | if (!rXParseAllocColor (& xcol, color)) |
959 | if (!rXParseAllocColor (& xcol, color)) |
906 | return; |
960 | return; |
|
|
961 | |
907 | /* XStoreColor (display->display, XCMAP, XColor*); */ |
962 | /* XStoreColor (display->display, XCMAP, XColor*); */ |
908 | |
963 | |
909 | /* |
964 | /* |
910 | * FIXME: should free colors here, but no idea how to do it so instead, |
965 | * FIXME: should free colors here, but no idea how to do it so instead, |
911 | * so just keep gobbling up the colormap |
966 | * so just keep gobbling up the colormap |
… | |
… | |
934 | |
989 | |
935 | /* handle Color_BD, scrollbar background, etc. */ |
990 | /* handle Color_BD, scrollbar background, etc. */ |
936 | |
991 | |
937 | set_colorfgbg (); |
992 | set_colorfgbg (); |
938 | recolour_cursor (); |
993 | recolour_cursor (); |
939 | /* the only reasonable way to enforce a clean update */ |
994 | scr_touch (true); |
940 | scr_poweron (); |
|
|
941 | } |
995 | } |
942 | |
996 | |
943 | #else |
997 | #else |
944 | # define set_window_color (idx,color) ((void)0) |
998 | # define set_window_color (idx,color) ((void)0) |
945 | #endif /* XTERM_COLOR_CHANGE */ |
999 | #endif /* XTERM_COLOR_CHANGE */ |
946 | |
1000 | |
947 | void |
1001 | void |
948 | rxvt_term::recolour_cursor () |
1002 | rxvt_term::recolour_cursor () |
949 | { |
1003 | { |
950 | #if TODO |
|
|
951 | rxvt_color xcol[2]; |
1004 | XColor xcol[2]; |
952 | |
1005 | |
953 | xcol[0] = PixColors[Color_pointer]; |
1006 | xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColors[Color_pointer_fg] : PixColors[Color_fg]; |
954 | xcol[1] = PixColors[Color_bg]; |
1007 | xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColors[Color_pointer_bg] : PixColors[Color_bg]; |
955 | XQueryColors (display->display, XCMAP, xcol, 2); |
1008 | XQueryColors (display->display, XCMAP, xcol, 2); |
956 | XRecolorCursor (display->display, TermWin_cursor, & (xcol[0]), & (xcol[1])); |
1009 | XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1); |
957 | #endif |
|
|
958 | } |
1010 | } |
959 | |
1011 | |
960 | /*----------------------------------------------------------------------*/ |
1012 | /*----------------------------------------------------------------------*/ |
961 | /* |
1013 | /* |
962 | * find if fg/bg matches any of the normal (low-intensity) colors |
1014 | * find if fg/bg matches any of the normal (low-intensity) colors |
… | |
… | |
1011 | int |
1063 | int |
1012 | rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) |
1064 | rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) |
1013 | { |
1065 | { |
1014 | if (!screen_in_out->set (display, colour)) |
1066 | if (!screen_in_out->set (display, colour)) |
1015 | { |
1067 | { |
1016 | rxvt_print_error ("can't allocate colour: %s", colour); |
1068 | rxvt_warn ("can't get colour '%s', continuing without.\n", colour); |
1017 | return false; |
1069 | return false; |
1018 | } |
1070 | } |
1019 | |
1071 | |
1020 | return true; |
1072 | return true; |
1021 | } |
1073 | } |
… | |
… | |
1032 | int old_width = szHint.width, old_height = szHint.height; |
1084 | int old_width = szHint.width, old_height = szHint.height; |
1033 | #endif |
1085 | #endif |
1034 | |
1086 | |
1035 | window_calc (width, height); |
1087 | window_calc (width, height); |
1036 | XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); |
1088 | XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); |
|
|
1089 | |
1037 | if (!ignoreparent) |
1090 | if (!ignoreparent) |
1038 | { |
1091 | { |
1039 | #ifdef SMART_RESIZE |
1092 | #ifdef SMART_RESIZE |
1040 | /* |
1093 | /* |
1041 | * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> |
1094 | * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> |
… | |
… | |
1076 | dy /= 2; |
1129 | dy /= 2; |
1077 | |
1130 | |
1078 | XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, |
1131 | XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, |
1079 | szHint.width, szHint.height); |
1132 | szHint.width, szHint.height); |
1080 | #else |
1133 | #else |
1081 | XResizeWindow (display->display, TermWin.parent[0], szHint.width, |
1134 | XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); |
1082 | szHint.height); |
|
|
1083 | #endif |
1135 | #endif |
1084 | |
|
|
1085 | } |
1136 | } |
1086 | |
1137 | |
1087 | fix_screen = (TermWin.ncol != prev_ncol |
1138 | fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; |
1088 | || TermWin.nrow != prev_nrow); |
|
|
1089 | |
1139 | |
1090 | if (fix_screen || width != old_width || height != old_height) |
1140 | if (fix_screen || width != old_width || height != old_height) |
1091 | { |
1141 | { |
1092 | if (scrollbar_visible ()) |
1142 | if (scrollbar_visible ()) |
1093 | { |
1143 | { |
1094 | XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, |
1144 | XMoveResizeWindow (display->display, scrollBar.win, |
|
|
1145 | window_sb_x, 0, |
1095 | 0, scrollbar_TotalWidth (), szHint.height); |
1146 | scrollbar_TotalWidth (), szHint.height); |
1096 | resize_scrollbar (); |
1147 | resize_scrollbar (); |
1097 | } |
1148 | } |
1098 | |
1149 | |
1099 | if (menubar_visible ()) |
1150 | if (menubar_visible ()) |
1100 | XMoveResizeWindow (display->display, menuBar.win, window_vt_x, |
1151 | XMoveResizeWindow (display->display, menuBar.win, |
|
|
1152 | window_vt_x, 0, |
1101 | 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1153 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1102 | |
1154 | |
1103 | XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, |
1155 | XMoveResizeWindow (display->display, TermWin.vt, |
1104 | window_vt_y, TermWin_TotalWidth (), |
1156 | window_vt_x, window_vt_y, |
1105 | TermWin_TotalHeight ()); |
1157 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1106 | scr_clear (height != old_height); |
1158 | scr_clear (); |
1107 | #ifdef XPM_BACKGROUND |
1159 | #ifdef XPM_BACKGROUND |
1108 | resize_pixmap (); |
1160 | resize_pixmap (); |
1109 | #endif |
1161 | #endif |
1110 | |
|
|
1111 | } |
1162 | } |
1112 | |
1163 | |
1113 | if (fix_screen || old_height == 0) |
1164 | if (fix_screen || old_height == 0) |
1114 | { |
1165 | { |
1115 | int curr_screen = -1; |
1166 | int curr_screen = -1; |
… | |
… | |
1388 | if (preedit_attr) XFree (preedit_attr); |
1439 | if (preedit_attr) XFree (preedit_attr); |
1389 | if (status_attr) XFree (status_attr); |
1440 | if (status_attr) XFree (status_attr); |
1390 | |
1441 | |
1391 | if (Input_Context == NULL) |
1442 | if (Input_Context == NULL) |
1392 | { |
1443 | { |
1393 | rxvt_print_error ("failed to create input context"); |
1444 | rxvt_warn ("failed to create input context, continuing without XIM.\n"); |
1394 | display->put_xim (input_method); |
1445 | display->put_xim (input_method); |
1395 | return false; |
1446 | return false; |
1396 | } |
1447 | } |
1397 | |
1448 | |
1398 | if (input_style & XIMPreeditArea) |
1449 | if (input_style & XIMPreeditArea) |