- int rc;
- if (mine->fake_nl) {
- buf[0]='\n';
- mine->fake_nl=0;
- return 1;
- }
-
- if (!mine->input_available_p) return 0;
-
- rc=read (fileno (mine->pipe), (void *) buf, n);
- if (rc>0) mine->lastc=buf[rc-1];
-
- if (rc<=0)
- {
- terminal_closegen(mine);
-
- if (mine->lastc != '\n') { /* add a newline at eof if there wasn't one */
- mine->fake_nl=1;
- }
-
- /* Set up a timer to re-launch the subproc in a bit. */
- mine->timeout_id =
- XtAppAddTimeOut(app, subproc_relaunch_delay,
- relaunch_generator_timer,
- (XtPointer) mine);
- }
-
- mine->input_available_p = False;
-
- return rc;
-}
-
-
-/* The interpretation of the ModN modifiers is dependent on what keys
- are bound to them: Mod1 does not necessarily mean "meta". It only
- means "meta" if Meta_L or Meta_R are bound to it. If Meta_L is on
- Mod5, then Mod5 is the one that means Meta. Oh, and Meta and Alt
- aren't necessarily the same thing. Icepicks in my forehead!
- */
-static unsigned int
-do_icccm_meta_key_stupidity (Display *dpy)
-{
- unsigned int modbits = 0;
- int i, j, k;
- XModifierKeymap *modmap = XGetModifierMapping (dpy);
- for (i = 3; i < 8; i++)
- for (j = 0; j < modmap->max_keypermod; j++)
- {
- int code = modmap->modifiermap[i * modmap->max_keypermod + j];
- KeySym *syms;
- int nsyms = 0;
- if (code == 0) continue;
- syms = XGetKeyboardMapping (dpy, code, 1, &nsyms);
- for (k = 0; k < nsyms; k++)
- if (syms[k] == XK_Meta_L || syms[k] == XK_Meta_R ||
- syms[k] == XK_Alt_L || syms[k] == XK_Alt_R)
- modbits |= (1 << i);
- XFree (syms);
- }
- XFreeModifiermap (modmap);
- return modbits;
-}
-
-/* Returns a mask of the bit or bits of a KeyPress event that mean "meta".
- */
-static unsigned int
-meta_modifier (Display *dpy)
-{
- static Bool done_once = False;
- static unsigned int mask = 0;
- if (!done_once)
- {
- /* Really, we are supposed to recompute this if a KeymapNotify
- event comes in, but fuck it. */
- done_once = True;
- mask = do_icccm_meta_key_stupidity (dpy);