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.12 by pcg, Tue Dec 16 23:04:13 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.12 2003/12/16 23:04:13 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 ()
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
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/*----------------------------------------------------------------------*/
1062 return; 1064 return;
1063} 1065}
1064 1066
1065/* INTPROTO */ 1067/* INTPROTO */
1066void 1068void
1067rxvt_setPreeditArea(pR_ XRectangle * preedit_rect, XRectangle * status_rect, 1069rxvt_setPreeditArea (pR_ XRectangle * preedit_rect, XRectangle * status_rect,
1068 XRectangle * needed_rect) 1070 XRectangle * needed_rect)
1069{ 1071{
1070 int mbh, vtx = 0; 1072 int mbh, vtx = 0;
1071 1073
1072 if (scrollbar_visible(R) && !(R->Options & Opt_scrollBar_right)) 1074 if (scrollbar_visible(R) && !(R->Options & Opt_scrollBar_right))
1073 vtx = scrollbar_TotalWidth(); 1075 vtx = scrollbar_TotalWidth();
1117rxvt_IMInstantiateCallback(Display * unused 1119rxvt_IMInstantiateCallback(Display * unused
1118 __attribute__ ((unused)), XPointer client_data 1120 __attribute__ ((unused)), XPointer client_data
1119 __attribute__ ((unused)), XPointer call_data 1121 __attribute__ ((unused)), XPointer call_data
1120 __attribute__ ((unused))) 1122 __attribute__ ((unused)))
1121{ 1123{
1122 dR; 1124 dR;
1123 int i, found, had_im; 1125 int i, found, had_im;
1124 const char *p; 1126 const char *p;
1125 char **s; 1127 char **s;
1126 char buf[IMBUFSIZ]; 1128 char buf[IMBUFSIZ];
1127 1129
1128 D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); 1130 D_MAIN((stderr, "rxvt_IMInstantiateCallback()"));
1129 if (R->Input_Context) 1131 if (R->Input_Context)
1130 return; 1132 return;
1131 1133
1132 found = had_im = 0;
1133 p = R->rs[Rs_inputMethod]; 1134 p = R->rs[Rs_inputMethod];
1134 if (p && *p) { 1135 if (p && *p)
1135 had_im = 1; 1136 {
1137 bool found = false;
1138
1136 s = rxvt_splitcommastring(p); 1139 s = rxvt_splitcommastring (p);
1137 for (i = 0; s[i]; i++) { 1140 for (i = 0; s[i]; i++)
1141 {
1138 if (*s[i]) { 1142 if (*s[i])
1143 {
1139 STRCPY(buf, "@im="); 1144 STRCPY (buf, "@im=");
1140 STRNCAT(buf, s[i], IMBUFSIZ - 5); 1145 STRNCAT (buf, s[i], IMBUFSIZ - 5);
1141 if ((p = XSetLocaleModifiers(buf)) != NULL && *p 1146 if ((p = XSetLocaleModifiers (buf)) && *p
1142 && (rxvt_IM_get_IC(aR) == True)) { 1147 && rxvt_IM_get_IC (aR))
1148 {
1143 found = 1; 1149 found = true;
1144 break; 1150 break;
1145 } 1151 }
1146 } 1152 }
1147 } 1153 }
1148 for (i = 0; s[i]; i++) 1154 for (i = 0; s[i]; i++)
1149 free(s[i]); 1155 free(s[i]);
1150 free(s); 1156 free(s);
1151 } 1157
1152 if (found) 1158 if (found)
1153 return; 1159 return;
1160 }
1154 1161
1155/* try with XMODIFIERS env. var. */ 1162/* try with XMODIFIERS env. var. */
1156 if ((p = XSetLocaleModifiers("")) != NULL && *p) { 1163 if ((p = XSetLocaleModifiers ("")) && *p
1157 rxvt_IM_get_IC(aR); 1164 && rxvt_IM_get_IC (aR))
1158 return; 1165 return;
1159 }
1160 1166
1161/* try with no modifiers base IF the user didn't specify an IM */ 1167/* try with no modifiers base IF the user didn't specify an IM */
1162 if (!had_im && (p = XSetLocaleModifiers("@im=none")) != NULL && *p 1168 if ((p = XSetLocaleModifiers ("@im=none")) && *p
1163 && rxvt_IM_get_IC(aR) == True) 1169 && rxvt_IM_get_IC (aR) == True)
1164 return; 1170 return;
1165} 1171}
1166 1172
1167/* 1173/*
1168 * Try to open a XIM with the current modifiers, then see if we can 1174 * Try to open a XIM with the current modifiers, then see if we can
1169 * open a suitable preedit type 1175 * open a suitable preedit type

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines