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.8 by pcg, Thu Nov 27 10:12:10 2003 UTC vs.
Revision 1.13 by pcg, Wed Dec 17 09:00:35 2003 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: main.c 2 * File: main.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: main.C,v 1.8 2003/11/27 10:12:10 pcg Exp $ 4 * $Id: main.C,v 1.13 2003/12/17 09:00:35 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>
66#endif 66#endif
67#ifdef POINTER_BLANK 67#ifdef POINTER_BLANK
68 pointer_ev (this, &rxvt_term::pointer_cb), 68 pointer_ev (this, &rxvt_term::pointer_cb),
69#endif 69#endif
70 x_ev (this, &rxvt_term::x_cb), 70 x_ev (this, &rxvt_term::x_cb),
71 destroy_ev (this, &rxvt_term::destroy_cb) 71 destroy_ev (this, &rxvt_term::destroy_cb),
72 check_ev (this, &rxvt_term::check_cb),
73 incr_ev (this, &rxvt_term::incr_cb)
72{ 74{
73 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 75 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
74} 76}
75 77
76rxvt_term::~rxvt_term () 78rxvt_term::~rxvt_term ()
77{ 79{
78 rxvt_scr_release (this); 80 scr_release ();
79 81
80#ifndef NO_SETOWNER_TTYDEV 82#ifndef NO_SETOWNER_TTYDEV
81 rxvt_privileged_ttydev (this, RESTORE); 83 rxvt_privileged_ttydev (this, RESTORE);
82#endif 84#endif
83#ifdef UTMP_SUPPORT 85#ifdef UTMP_SUPPORT
101} 103}
102 104
103void 105void
104rxvt_term::destroy () 106rxvt_term::destroy ()
105{ 107{
108 check_ev.stop ();
106 pty_ev.stop (); 109 pty_ev.stop ();
107 x_ev.stop (); 110 x_ev.stop ();
108#ifdef CURSOR_BLINK 111#ifdef CURSOR_BLINK
109 blink_ev.stop (); 112 blink_ev.stop ();
110#endif 113#endif
125 128
126/*----------------------------------------------------------------------*/ 129/*----------------------------------------------------------------------*/
127/* rxvt_init() */ 130/* rxvt_init() */
128/* LIBPROTO */ 131/* LIBPROTO */
129rxvt_t 132rxvt_t
130rxvt_init(int argc, const char *const *argv) 133rxvt_init (int argc, const char *const *argv)
131{ 134{
132 SET_R(new rxvt_term); 135 SET_R (new rxvt_term);
133 dR; 136 dR;
134 137
135 if (!R->init_vars () || !R->init (argc, argv)) 138 if (!R->init_vars () || !R->init (argc, argv))
136 { 139 {
137 delete R; 140 delete R;
148/* install exit handler for cleanup */ 151/* install exit handler for cleanup */
149#if 0 152#if 0
150#ifdef HAVE_ATEXIT 153#ifdef HAVE_ATEXIT
151 atexit(rxvt_clean_exit); 154 atexit(rxvt_clean_exit);
152#else 155#else
153# ifdef HAVE_ON_EXIT
154 on_exit(rxvt_clean_exit, NULL); /* non-ANSI exit handler */
155# endif
156#endif 156#endif
157#endif 157#endif
158 158
159 struct sigaction sa; 159 struct sigaction sa;
160 160
161 sigfillset (&sa.sa_mask); 161 sigfillset (&sa.sa_mask);
162 sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; 162 sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
163 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGHUP , &sa, 0); //TODO, also: SIGPIPE 163 sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0);
164 sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0);
164 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0); 165 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0);
165 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0); 166 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0);
166 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0); 167 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0);
167 sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0); 168 sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0);
168 169
202 203
203 rxvt_Create_Windows (this, argc, argv); 204 rxvt_Create_Windows (this, argc, argv);
204 205
205 rxvt_init_xlocale (this); 206 rxvt_init_xlocale (this);
206 207
207 rxvt_scr_reset (this); /* initialize screen */ 208 scr_reset (); /* initialize screen */
208#ifdef RXVT_GRAPHICS 209#ifdef RXVT_GRAPHICS
209 rxvt_Gr_reset (this); /* reset graphics */ 210 rxvt_Gr_reset (this); /* reset graphics */
210#endif 211#endif
211 212
212#if 0 213#if 0
237 rxvt_init_command (this, cmd_argv); 238 rxvt_init_command (this, cmd_argv);
238 239
239 x_ev.start (Xfd, EVENT_READ); 240 x_ev.start (Xfd, EVENT_READ);
240 pty_ev.start (cmd_fd, EVENT_READ); 241 pty_ev.start (cmd_fd, EVENT_READ);
241 242
242 flush (); 243 check_ev.start ();
244
245 process_x_events ();
243 246
244 return true; 247 return true;
245} 248}
246 249
247/* ------------------------------------------------------------------------- * 250/* ------------------------------------------------------------------------- *
614/*----------------------------------------------------------------------*/ 617/*----------------------------------------------------------------------*/
615/* 618/*
616 * Tell the teletype handler what size the window is. 619 * Tell the teletype handler what size the window is.
617 * Called after a window size change. 620 * Called after a window size change.
618 */ 621 */
619/* EXTPROTO */
620void 622void
621rxvt_tt_winsize(int fd, unsigned short col, unsigned short row, int pid) 623rxvt_term::tt_winch ()
622{ 624{
623 struct winsize ws; 625 struct winsize ws;
624 626
625 if (fd < 0) 627 if (cmd_fd < 0)
626 return; 628 return;
629
627 ws.ws_col = col; 630 ws.ws_col = TermWin.ncol;
628 ws.ws_row = row; 631 ws.ws_row = TermWin.nrow;
629 ws.ws_xpixel = ws.ws_ypixel = 0; 632 ws.ws_xpixel = ws.ws_ypixel = 0;
630#ifndef DEBUG_SIZE 633#ifndef DEBUG_SIZE
631 (void)ioctl(fd, TIOCSWINSZ, &ws); 634 (void)ioctl (cmd_fd, TIOCSWINSZ, &ws);
632#else 635#else
633 if (ioctl(fd, TIOCSWINSZ, &ws) < 0) { 636 if (ioctl (cmd_fd, TIOCSWINSZ, &ws) < 0)
634 D_SIZE((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); 637 D_SIZE((stderr, "Failed to send TIOCSWINSZ to fd %d", fd));
635 }
636# ifdef SIGWINCH 638# ifdef SIGWINCH
637 else if (pid) /* force through to the command */ 639 else if (cmd_pid) /* force through to the command */
638 kill(pid, SIGWINCH); 640 kill (cmd_pid, SIGWINCH);
639# endif 641# endif
640#endif 642#endif
641} 643}
642 644
643/*----------------------------------------------------------------------*/ 645/*----------------------------------------------------------------------*/
938 uint16_t old_ncol = R->prev_ncol; 940 uint16_t old_ncol = R->prev_ncol;
939 941
940 /* scr_reset only works on the primary screen */ 942 /* scr_reset only works on the primary screen */
941 if (R->old_height) /* this is not the first time through */ 943 if (R->old_height) /* this is not the first time through */
942 curr_screen = rxvt_scr_change_screen(aR_ PRIMARY); 944 curr_screen = rxvt_scr_change_screen(aR_ PRIMARY);
945
943 rxvt_scr_reset(aR); 946 R->scr_reset();
947
944 if (curr_screen >= 0) { /* this is not the first time through */ 948 if (curr_screen >= 0) { /* this is not the first time through */
945 rxvt_scr_change_screen(aR_ curr_screen); 949 rxvt_scr_change_screen(aR_ curr_screen);
946 rxvt_selection_check(aR_(old_ncol != R->TermWin.ncol ? 4 : 0)); 950 rxvt_selection_check(aR_(old_ncol != R->TermWin.ncol ? 4 : 0));
947 } 951 }
948 } 952 }
1062 return; 1066 return;
1063} 1067}
1064 1068
1065/* INTPROTO */ 1069/* INTPROTO */
1066void 1070void
1067rxvt_setPreeditArea(pR_ XRectangle * preedit_rect, XRectangle * status_rect, 1071rxvt_setPreeditArea (pR_ XRectangle * preedit_rect, XRectangle * status_rect,
1068 XRectangle * needed_rect) 1072 XRectangle * needed_rect)
1069{ 1073{
1070 int mbh, vtx = 0; 1074 int mbh, vtx = 0;
1071 1075
1072 if (scrollbar_visible(R) && !(R->Options & Opt_scrollBar_right)) 1076 if (scrollbar_visible(R) && !(R->Options & Opt_scrollBar_right))
1073 vtx = scrollbar_TotalWidth(); 1077 vtx = scrollbar_TotalWidth();
1117rxvt_IMInstantiateCallback(Display * unused 1121rxvt_IMInstantiateCallback(Display * unused
1118 __attribute__ ((unused)), XPointer client_data 1122 __attribute__ ((unused)), XPointer client_data
1119 __attribute__ ((unused)), XPointer call_data 1123 __attribute__ ((unused)), XPointer call_data
1120 __attribute__ ((unused))) 1124 __attribute__ ((unused)))
1121{ 1125{
1122 dR; 1126 dR;
1123 int i, found, had_im; 1127 int i, found, had_im;
1124 const char *p; 1128 const char *p;
1125 char **s; 1129 char **s;
1126 char buf[IMBUFSIZ]; 1130 char buf[IMBUFSIZ];
1127 1131
1128 D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); 1132 D_MAIN((stderr, "rxvt_IMInstantiateCallback()"));
1129 if (R->Input_Context) 1133 if (R->Input_Context)
1130 return; 1134 return;
1131 1135
1132 found = had_im = 0;
1133 p = R->rs[Rs_inputMethod]; 1136 p = R->rs[Rs_inputMethod];
1134 if (p && *p) { 1137 if (p && *p)
1135 had_im = 1; 1138 {
1139 bool found = false;
1140
1136 s = rxvt_splitcommastring(p); 1141 s = rxvt_splitcommastring (p);
1137 for (i = 0; s[i]; i++) { 1142 for (i = 0; s[i]; i++)
1143 {
1138 if (*s[i]) { 1144 if (*s[i])
1145 {
1139 STRCPY(buf, "@im="); 1146 STRCPY (buf, "@im=");
1140 STRNCAT(buf, s[i], IMBUFSIZ - 5); 1147 STRNCAT (buf, s[i], IMBUFSIZ - 5);
1141 if ((p = XSetLocaleModifiers(buf)) != NULL && *p 1148 if ((p = XSetLocaleModifiers (buf)) && *p
1142 && (rxvt_IM_get_IC(aR) == True)) { 1149 && rxvt_IM_get_IC (aR))
1150 {
1143 found = 1; 1151 found = true;
1144 break; 1152 break;
1145 } 1153 }
1146 } 1154 }
1147 } 1155 }
1148 for (i = 0; s[i]; i++) 1156 for (i = 0; s[i]; i++)
1149 free(s[i]); 1157 free(s[i]);
1150 free(s); 1158 free(s);
1151 } 1159
1152 if (found) 1160 if (found)
1153 return; 1161 return;
1162 }
1154 1163
1155/* try with XMODIFIERS env. var. */ 1164/* try with XMODIFIERS env. var. */
1156 if ((p = XSetLocaleModifiers("")) != NULL && *p) { 1165 if ((p = XSetLocaleModifiers ("")) && *p
1157 rxvt_IM_get_IC(aR); 1166 && rxvt_IM_get_IC (aR))
1158 return; 1167 return;
1159 }
1160 1168
1161/* try with no modifiers base IF the user didn't specify an IM */ 1169/* try with no modifiers base IF the user didn't specify an IM */
1162 if (!had_im && (p = XSetLocaleModifiers("@im=none")) != NULL && *p 1170 if ((p = XSetLocaleModifiers ("@im=none")) && *p
1163 && rxvt_IM_get_IC(aR) == True) 1171 && rxvt_IM_get_IC (aR) == True)
1164 return; 1172 return;
1165} 1173}
1166 1174
1167/* 1175/*
1168 * Try to open a XIM with the current modifiers, then see if we can 1176 * Try to open a XIM with the current modifiers, then see if we can
1169 * open a suitable preedit type 1177 * open a suitable preedit type

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines