*** empty log message ***
authorpcg <pcg>
Sun, 1 Feb 2004 01:34:41 +0000 (01:34 +0000)
committerpcg <pcg>
Sun, 1 Feb 2004 01:34:41 +0000 (01:34 +0000)
18 files changed:
src/command.C
src/grkelot.C
src/init.C
src/iom.C
src/logging.C
src/main.C
src/menubar.C
src/misc.C
src/netdisp.C
src/screen.C
src/scrollbar-next.C
src/scrollbar-plain.C
src/scrollbar-rxvt.C
src/scrollbar-xterm.C
src/scrollbar.C
src/strings.C
src/xdefaults.C
src/xpm.C

index 7ecf6e7..49efc8e 100644 (file)
 void
 rxvt_term::lookup_key (XKeyEvent *ev)
 {
-    int             ctrl, meta, shft, len;
-    unsigned int    newlen;
-    KeySym          keysym;
+  int             ctrl, meta, shft, len;
+  unsigned int    newlen;
+  KeySym          keysym;
 #ifdef DEBUG_CMD
-    static int      debug_key = 1;     /* accessible by a debugger only */
-#endif
-    int             valid_keysym;
-    unsigned char kbuf[KBUFSZ];
-
-/*
- * use Num_Lock to toggle Keypad on/off.  If Num_Lock is off, allow an
- * escape sequence to toggle the Keypad.
- *
- * Always permit `shift' to override the current setting
- */
-    shft = (ev->state & ShiftMask);
-    ctrl = (ev->state & ControlMask);
-    meta = (ev->state & ModMetaMask);
-
-    if (numlock_state || (ev->state & ModNumLockMask))
-      {
-       numlock_state = (ev->state & ModNumLockMask);
-       PrivMode((!numlock_state), PrivMode_aplKP);
-      }
+  static int      debug_key = 1;       /* accessible by a debugger only */
+#endif
+  int             valid_keysym;
+  unsigned char kbuf[KBUFSZ];
+
+  /*
  * use Num_Lock to toggle Keypad on/off.  If Num_Lock is off, allow an
  * escape sequence to toggle the Keypad.
  *
  * Always permit `shift' to override the current setting
  */
+  shft = (ev->state & ShiftMask);
+  ctrl = (ev->state & ControlMask);
+  meta = (ev->state & ModMetaMask);
+
+  if (numlock_state || (ev->state & ModNumLockMask))
+    {
+      numlock_state = (ev->state & ModNumLockMask);
+      PrivMode((!numlock_state), PrivMode_aplKP);
+    }
 
-    kbuf[0] = 0;
+  kbuf[0] = 0;
 
 #ifdef USE_XIM
-    if (Input_Context)
-      {
-       Status status_return;
+  if (Input_Context)
+    {
+      Status status_return;
 
 #ifdef X_HAVE_UTF8_STRING
-        if (enc_utf8 && 0)
-          len = Xutf8LookupString (Input_Context, ev, (char *)kbuf,
-                                   KBUFSZ, &keysym, &status_return);
-        else
+      if (enc_utf8 && 0)
+        len = Xutf8LookupString (Input_Context, ev, (char *)kbuf,
+                                 KBUFSZ, &keysym, &status_return);
+      else
 #endif
-          {
-            wchar_t wkbuf[KBUFSZ + 1];
-
-            // the XOpenIM manpage lies about hardcoding the locale
-            // at the point of XOpenIM, so temporarily switch locales
-            if (rs[Rs_imLocale])
-              SET_LOCALE (rs[Rs_imLocale]);
-            // assume wchar_t == unicode or better
-            len = XwcLookupString (Input_Context, ev, wkbuf,
-                                   KBUFSZ, &keysym, &status_return);
-            if (rs[Rs_imLocale])
-              SET_LOCALE (locale);
-
-            if (status_return == XLookupChars
-                || status_return == XLookupBoth)
-              {
-                wkbuf[len] = 0;
-                len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ);
-                if (len < 0)
-                  len = 0;
-              }
-            else
-              len = 0;
-          }
 
-       valid_keysym = status_return == XLookupKeySym
-                      || status_return == XLookupBoth;
-      }
-    else
+        {
+          wchar_t wkbuf[KBUFSZ + 1];
+
+          // the XOpenIM manpage lies about hardcoding the locale
+          // at the point of XOpenIM, so temporarily switch locales
+          if (rs[Rs_imLocale])
+            SET_LOCALE (rs[Rs_imLocale]);
+          // assume wchar_t == unicode or better
+          len = XwcLookupString (Input_Context, ev, wkbuf,
+                                 KBUFSZ, &keysym, &status_return);
+          if (rs[Rs_imLocale])
+            SET_LOCALE (locale);
+
+          if (status_return == XLookupChars
+                            || status_return == XLookupBoth)
+            {
+              wkbuf[len] = 0;
+              len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ);
+              if (len < 0)
+                len = 0;
+            }
+          else
+            len = 0;
+        }
+
+      valid_keysym = status_return == XLookupKeySym
+                                   || status_return == XLookupBoth;
+    }
+  else
 #endif
-      {
-       len = XLookupString (ev, (char *)kbuf, KBUFSZ, &keysym, &compose);
-       valid_keysym = !len;
-      }
 
-    if (valid_keysym)
-      {
-/* for some backwards compatibility */
+    {
+      len = XLookupString (ev, (char *)kbuf, KBUFSZ, &keysym, &compose);
+      valid_keysym = !len;
+    }
+
+  if (valid_keysym)
+    {
+      /* for some backwards compatibility */
 #if defined(HOTKEY_CTRL) || defined(HOTKEY_META)
 # ifdef HOTKEY_CTRL
-       if (ctrl)
+      if (ctrl)
 # else
-       if (meta)
+      if (meta)
 # endif
-          {
-           if (keysym == ks_bigfont)
-              {
-               change_font (0, FONT_UP);
-               return;
-             }
-            else if (keysym == ks_smallfont)
-              {
-               change_font (0, FONT_DN);
-               return;
-             }
-         }
+        {
+          if (keysym == ks_bigfont)
+            {
+              change_font (0, FONT_UP);
+              return;
+            }
+          else if (keysym == ks_smallfont)
+            {
+              change_font (0, FONT_DN);
+              return;
+            }
+        }
 #endif
 
-       if (TermWin.saveLines) {
+      if (TermWin.saveLines)
+        {
 #ifdef UNSHIFTED_SCROLLKEYS
-           if (!ctrl && !meta) {
+          if (!ctrl && !meta)
+            {
 #else
-           if (IS_SCROLL_MOD) {
+          if (IS_SCROLL_MOD)
+            {
 #endif
-               int             lnsppg;
+              int             lnsppg;
 
 #ifdef PAGING_CONTEXT_LINES
-               lnsppg = TermWin.nrow - PAGING_CONTEXT_LINES;
+              lnsppg = TermWin.nrow - PAGING_CONTEXT_LINES;
 #else
-               lnsppg = TermWin.nrow * 4 / 5;
-#endif
-               if (keysym == XK_Prior) {
-                   scr_page (UP, lnsppg);
-                   return;
-               } else if (keysym == XK_Next) {
-                   scr_page (DN, lnsppg);
-                   return;
-               }
-           }
+              lnsppg = TermWin.nrow * 4 / 5;
+#endif
+              if (keysym == XK_Prior)
+                {
+                  scr_page (UP, lnsppg);
+                  return;
+                }
+              else if (keysym == XK_Next)
+                {
+                  scr_page (DN, lnsppg);
+                  return;
+                }
+            }
 #ifdef SCROLL_ON_UPDOWN_KEYS
-           if (IS_SCROLL_MOD) {
-               if (keysym == XK_Up) {
-                   scr_page (UP, 1);
-                   return;
-               } else if (keysym == XK_Down) {
-                   scr_page (DN, 1);
-                   return;
-               }
-           }
+          if (IS_SCROLL_MOD)
+            {
+              if (keysym == XK_Up)
+                {
+                  scr_page (UP, 1);
+                  return;
+                }
+              else if (keysym == XK_Down)
+                {
+                  scr_page (DN, 1);
+                  return;
+                }
+            }
 #endif
 #ifdef SCROLL_ON_HOMEEND_KEYS
-           if (IS_SCROLL_MOD) {
-               if (keysym == XK_Home) {
-                   scr_move_to (0, 1);
-                   return;
-               } else if (keysym == XK_End) {
-                   scr_move_to (1, 0);
-                   return;
-               }
-           }
-#endif
-       }
-
-       if (shft) {
-       /* Shift + F1 - F10 generates F11 - F20 */
-           if (keysym >= XK_F1 && keysym <= XK_F10) {
-               keysym += (XK_F11 - XK_F1);
-               shft = 0;       /* turn off Shift */
-           } else if (!ctrl && !meta && (PrivateModes & PrivMode_ShiftKeys)) {
-               switch (keysym) {
-               /* normal XTerm key bindings */
-               case XK_Insert: /* Shift+Insert = paste mouse selection */
-                   selection_request (ev->time, 0, 0);
-                   return;
-               /* rxvt extras */
-               case XK_KP_Add: /* Shift+KP_Add = bigger font */
-                   change_font (0, FONT_UP);
-                   return;
-               case XK_KP_Subtract:    /* Shift+KP_Subtract = smaller font */
-                   change_font (0, FONT_DN);
-                   return;
-               }
-           }
-       }
+          if (IS_SCROLL_MOD)
+            {
+              if (keysym == XK_Home)
+                {
+                  scr_move_to (0, 1);
+                  return;
+                }
+              else if (keysym == XK_End)
+                {
+                  scr_move_to (1, 0);
+                  return;
+                }
+            }
+#endif
+
+        }
+
+      if (shft)
+        {
+          /* Shift + F1 - F10 generates F11 - F20 */
+          if (keysym >= XK_F1 && keysym <= XK_F10)
+            {
+              keysym += (XK_F11 - XK_F1);
+              shft = 0;        /* turn off Shift */
+            }
+          else if (!ctrl && !meta && (PrivateModes & PrivMode_ShiftKeys))
+            {
+              switch (keysym)
+                {
+                    /* normal XTerm key bindings */
+                  case XK_Insert:      /* Shift+Insert = paste mouse selection */
+                    selection_request (ev->time, 0, 0);
+                    return;
+                    /* rxvt extras */
+                  case XK_KP_Add:      /* Shift+KP_Add = bigger font */
+                    change_font (0, FONT_UP);
+                    return;
+                  case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */
+                    change_font (0, FONT_DN);
+                    return;
+                }
+            }
+        }
 #ifdef PRINTPIPE
-       if (keysym == XK_Print) {
-           scr_printscreen (ctrl | shft);
-           return;
-       }
+      if (keysym == XK_Print)
+        {
+          scr_printscreen (ctrl | shft);
+          return;
+        }
 #endif
 #ifdef GREEK_SUPPORT
-       if (keysym == ks_greekmodeswith) {
-           greek_mode = !greek_mode;
-           if (greek_mode) {
-               xterm_seq (XTerm_title,
-                              (greek_getmode() == GREEK_ELOT928
-                               ? "[Greek: iso]" : "[Greek: ibm]"), CHAR_ST);
-               greek_reset();
-           } else
-               xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST);
-           return;
-       }
-#endif
-
-       if (keysym >= 0xFF00 && keysym <= 0xFFFF) {
+      if (keysym == ks_greekmodeswith)
+        {
+          greek_mode = !greek_mode;
+          if (greek_mode)
+            {
+              xterm_seq (XTerm_title,
+                         (greek_getmode() == GREEK_ELOT928
+                          ? "[Greek: iso]" : "[Greek: ibm]"), CHAR_ST);
+              greek_reset();
+            }
+          else
+            xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST);
+          return;
+        }
+#endif
+
+      if (keysym >= 0xFF00 && keysym <= 0xFFFF)
+        {
 #ifdef KEYSYM_RESOURCE
-           if (!(shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) {
-               unsigned int    l;
-               const unsigned char *kbuf0;
-               const unsigned char ch = C0_ESC;
+          if (!(shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL)
+            {
+              unsigned int    l;
+              const unsigned char *kbuf0;
+              const unsigned char ch = C0_ESC;
 
-               kbuf0 = (Keysym_map[keysym & 0xFF]);
-               l = (unsigned int)*kbuf0++;
+              kbuf0 = (Keysym_map[keysym & 0xFF]);
+              l = (unsigned int)*kbuf0++;
 
-           /* escape prefix */
-               if (meta)
+              /* escape prefix */
+              if (meta)
 # ifdef META8_OPTION
-                   if (meta_char == C0_ESC)
+                if (meta_char == C0_ESC)
 # endif
-                       tt_write (&ch, 1);
-               tt_write (kbuf0, l);
-               return;
-           } else
-#endif
-           {
-               newlen = 1;
-               switch (keysym) {
+                  tt_write (&ch, 1);
+              tt_write (kbuf0, l);
+              return;
+            }
+          else
+#endif
+
+            {
+              newlen = 1;
+              switch (keysym)
+                {
 #ifndef NO_BACKSPACE_KEY
-               case XK_BackSpace:
-                   if (PrivateModes & PrivMode_HaveBackSpace) {
-                       kbuf[0] = (!!(PrivateModes & PrivMode_BackSpace)
-                                  ^ !!ctrl) ? '\b' : '\177';
-                       kbuf[1] = '\0';
-                   } else
-                       STRCPY(kbuf, key_backspace);
+                  case XK_BackSpace:
+                    if (PrivateModes & PrivMode_HaveBackSpace)
+                      {
+                        kbuf[0] = (!!(PrivateModes & PrivMode_BackSpace)
+                                   ^ !!ctrl) ? '\b' : '\177';
+                        kbuf[1] = '\0';
+                      }
+                    else
+                      STRCPY(kbuf, key_backspace);
 # ifdef MULTICHAR_SET
-                   if ((Options & Opt_mc_hack) && screen.cur.col > 0) {
-                       int             col, row;
-
-                       newlen = STRLEN(kbuf);
-                       col = screen.cur.col - 1;
-                       row = screen.cur.row + TermWin.saveLines;
-                       if (IS_MULTI2(screen.rend[row][col]))
-                           MEMMOVE(kbuf + newlen, kbuf, newlen + 1);
-                   }
+                    if ((Options & Opt_mc_hack) && screen.cur.col > 0)
+                      {
+                        int             col, row;
+
+                        newlen = STRLEN(kbuf);
+                        col = screen.cur.col - 1;
+                        row = screen.cur.row + TermWin.saveLines;
+                        if (IS_MULTI2(screen.rend[row][col]))
+                          MEMMOVE(kbuf + newlen, kbuf, newlen + 1);
+                      }
 # endif
-                   break;
+                    break;
 #endif
 #ifndef NO_DELETE_KEY
-               case XK_Delete:
-                   STRCPY(kbuf, key_delete);
+                  case XK_Delete:
+                    STRCPY(kbuf, key_delete);
 # ifdef MULTICHAR_SET
-                   if (Options & Opt_mc_hack) {
-                       int             col, row;
-                       newlen = STRLEN(kbuf);
-                       col = screen.cur.col;
-                       row = screen.cur.row + TermWin.saveLines;
-                       if (IS_MULTI1(screen.rend[row][col]))
-                           MEMMOVE(kbuf + newlen, kbuf, newlen + 1);
-                   }
+                    if (Options & Opt_mc_hack)
+                      {
+                        int             col, row;
+
+                        newlen = STRLEN(kbuf);
+                        col = screen.cur.col;
+                        row = screen.cur.row + TermWin.saveLines;
+                        if (IS_MULTI1(screen.rend[row][col]))
+                          MEMMOVE(kbuf + newlen, kbuf, newlen + 1);
+                      }
 # endif
-                   break;
+                    break;
 #endif
-               case XK_Tab:
-                   if (shft)
-                       STRCPY(kbuf, "\033[Z");
-                   else {
+                  case XK_Tab:
+                    if (shft)
+                      STRCPY(kbuf, "\033[Z");
+                    else
+                      {
 #ifdef CTRL_TAB_MAKES_META
-                       if (ctrl)
-                           meta = 1;
+                        if (ctrl)
+                          meta = 1;
 #endif
 #ifdef MOD4_TAB_MAKES_META
-                       if (ev->state & Mod4Mask)
-                           meta = 1;
+                        if (ev->state & Mod4Mask)
+                          meta = 1;
 #endif
-                       newlen = 0;
-                   }
-                   break;
+                        newlen = 0;
+                      }
+                    break;
 
 
 #ifdef XK_KP_Left
-               case XK_KP_Up:          /* \033Ox or standard */
-               case XK_KP_Down:        /* \033Or or standard */
-               case XK_KP_Right:       /* \033Ov or standard */
-               case XK_KP_Left:        /* \033Ot or standard */
-                   if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) {
-                       STRCPY(kbuf, "\033OZ");
-                       kbuf[2] = ("txvr"[keysym - XK_KP_Left]);
-                       break;
-                   } else
-                   /* translate to std. cursor key */
-                       keysym = XK_Left + (keysym - XK_KP_Left);
-               /* FALLTHROUGH */
-#endif
-               case XK_Up:     /* "\033[A" */
-               case XK_Down:   /* "\033[B" */
-               case XK_Right:  /* "\033[C" */
-               case XK_Left:   /* "\033[D" */
-                   STRCPY(kbuf, "\033[Z");
-                   kbuf[2] = ("DACB"[keysym - XK_Left]);
-               /* do Shift first */
-                   if (shft)
-                       kbuf[2] = ("dacb"[keysym - XK_Left]);
-                   else if (ctrl) {
-                       kbuf[1] = 'O';
-                       kbuf[2] = ("dacb"[keysym - XK_Left]);
-                   } else if (PrivateModes & PrivMode_aplCUR)
-                       kbuf[1] = 'O';
+                  case XK_KP_Up:               /* \033Ox or standard */
+                  case XK_KP_Down:     /* \033Or or standard */
+                  case XK_KP_Right:    /* \033Ov or standard */
+                  case XK_KP_Left:     /* \033Ot or standard */
+                    if ((PrivateModes & PrivMode_aplKP) ? !shft : shft)
+                      {
+                        STRCPY(kbuf, "\033OZ");
+                        kbuf[2] = ("txvr"[keysym - XK_KP_Left]);
+                        break;
+                      }
+                    else
+                      /* translate to std. cursor key */
+                      keysym = XK_Left + (keysym - XK_KP_Left);
+                    /* FALLTHROUGH */
+#endif
+                  case XK_Up:  /* "\033[A" */
+                  case XK_Down:        /* "\033[B" */
+                  case XK_Right:       /* "\033[C" */
+                  case XK_Left:        /* "\033[D" */
+                    STRCPY(kbuf, "\033[Z");
+                    kbuf[2] = ("DACB"[keysym - XK_Left]);
+                    /* do Shift first */
+                    if (shft)
+                      kbuf[2] = ("dacb"[keysym - XK_Left]);
+                    else if (ctrl)
+                      {
+                        kbuf[1] = 'O';
+                        kbuf[2] = ("dacb"[keysym - XK_Left]);
+                      }
+                    else if (PrivateModes & PrivMode_aplCUR)
+                      kbuf[1] = 'O';
 #ifdef MULTICHAR_SET
                     //TODO: ??
-                   if (Options & Opt_mc_hack) {
-                       int             col, row, m;
-
-                       col = screen.cur.col;
-                       row = screen.cur.row + TermWin.saveLines;
-                       m = 0;
-                       if (keysym == XK_Right
-                           && IS_MULTI1(screen.rend[row][col]))
-                           m = 1;
-                       else if (keysym == XK_Left) {
-                           if (col > 0) {
-                               if (IS_MULTI2(screen.rend[row][col - 1]))
-                                   m = 1;
-                           } else if (screen.cur.row > 0) {
-                               col = screen.tlen[--row];
-                               if (col == -1)
-                                   col = TermWin.ncol - 1;
-                               else
-                                   col--;
-                               if (col > 0
-                                   && IS_MULTI2(screen.rend[row][col]))
-                                   m = 1;
-                           }
-                       }
-                       if (m)
-                           MEMMOVE(kbuf + 3, kbuf, 3 + 1);
-                   }
-#endif
-                   break;
+                    if (Options & Opt_mc_hack)
+                      {
+                        int             col, row, m;
+
+                        col = screen.cur.col;
+                        row = screen.cur.row + TermWin.saveLines;
+                        m = 0;
+                        if (keysym == XK_Right
+                            && IS_MULTI1(screen.rend[row][col]))
+                          m = 1;
+                        else if (keysym == XK_Left)
+                          {
+                            if (col > 0)
+                              {
+                                if (IS_MULTI2(screen.rend[row][col - 1]))
+                                  m = 1;
+                              }
+                            else if (screen.cur.row > 0)
+                              {
+                                col = screen.tlen[--row];
+                                if (col == -1)
+                                  col = TermWin.ncol - 1;
+                                else
+                                  col--;
+                                if (col > 0
+                                    && IS_MULTI2(screen.rend[row][col]))
+                                  m = 1;
+                              }
+                          }
+                        if (m)
+                          MEMMOVE(kbuf + 3, kbuf, 3 + 1);
+                      }
+#endif
+                    break;
 
 #ifndef UNSHIFTED_SCROLLKEYS
 # ifdef XK_KP_Prior
-               case XK_KP_Prior:
-               /* allow shift to override */
-                   if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) {
-                       STRCPY(kbuf, "\033Oy");
-                       break;
-                   }
-               /* FALLTHROUGH */
+                  case XK_KP_Prior:
+                    /* allow shift to override */
+                    if ((PrivateModes & PrivMode_aplKP) ? !shft : shft)
+                      {
+                        STRCPY(kbuf, "\033Oy");
+                        break;
+                      }
+                    /* FALLTHROUGH */
 # endif
-               case XK_Prior:
-                   STRCPY(kbuf, "\033[5~");
-                   break;
+                  case XK_Prior:
+                    STRCPY(kbuf, "\033[5~");
+                    break;
 # ifdef XK_KP_Next
-               case XK_KP_Next:
-               /* allow shift to override */
-                   if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) {
-                       STRCPY(kbuf, "\033Os");
-                       break;
-                   }
-               /* FALLTHROUGH */
+                  case XK_KP_Next:
+                    /* allow shift to override */
+                    if ((PrivateModes & PrivMode_aplKP) ? !shft : shft)
+                      {
+                        STRCPY(kbuf, "\033Os");
+                        break;
+                      }
+                    /* FALLTHROUGH */
 # endif
-               case XK_Next:
-                   STRCPY(kbuf, "\033[6~");
-                   break;
-#endif
-               case XK_KP_Enter:
-               /* allow shift to override */
-                   if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) {
-                       STRCPY(kbuf, "\033OM");
-                   } else {
-                       kbuf[0] = '\r';
-                       kbuf[1] = '\0';
-                   }
-                   break;
+                  case XK_Next:
+                    STRCPY(kbuf, "\033[6~");
+                    break;
+#endif
+                  case XK_KP_Enter:
+                    /* allow shift to override */
+                    if ((PrivateModes & PrivMode_aplKP) ? !shft : shft)
+                      {
+                        STRCPY(kbuf, "\033OM");
+                      }
+                    else
+                      {
+                        kbuf[0] = '\r';
+                        kbuf[1] = '\0';
+                      }
+                    break;
 
 #ifdef XK_KP_Begin
-               case XK_KP_Begin:
-                   STRCPY(kbuf, "\033Ou");
-                   break;
-
-               case XK_KP_Insert:
-                   STRCPY(kbuf, "\033Op");
-                   break;
-
-               case XK_KP_Delete:
-                   STRCPY(kbuf, "\033On");
-                   break;
-#endif
-               case XK_KP_F1:  /* "\033OP" */
-               case XK_KP_F2:  /* "\033OQ" */
-               case XK_KP_F3:  /* "\033OR" */
-               case XK_KP_F4:  /* "\033OS" */
-                   STRCPY(kbuf, "\033OP");
-                   kbuf[2] += (keysym - XK_KP_F1);
-                   break;
-
-               case XK_KP_Multiply:    /* "\033Oj" : "*" */
-               case XK_KP_Add:         /* "\033Ok" : "+" */
-               case XK_KP_Separator:   /* "\033Ol" : "," */
-               case XK_KP_Subtract:    /* "\033Om" : "-" */
-               case XK_KP_Decimal:     /* "\033On" : "." */
-               case XK_KP_Divide:      /* "\033Oo" : "/" */
-               case XK_KP_0:           /* "\033Op" : "0" */
-               case XK_KP_1:           /* "\033Oq" : "1" */
-               case XK_KP_2:           /* "\033Or" : "2" */
-               case XK_KP_3:           /* "\033Os" : "3" */
-               case XK_KP_4:           /* "\033Ot" : "4" */
-               case XK_KP_5:           /* "\033Ou" : "5" */
-               case XK_KP_6:           /* "\033Ov" : "6" */
-               case XK_KP_7:           /* "\033Ow" : "7" */
-               case XK_KP_8:           /* "\033Ox" : "8" */
-               case XK_KP_9:           /* "\033Oy" : "9" */
-               /* allow shift to override */
-                   if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) {
-                       STRCPY(kbuf, "\033Oj");
-                       kbuf[2] += (keysym - XK_KP_Multiply);
-                   } else {
-                       kbuf[0] = ('*' + (keysym - XK_KP_Multiply));
-                       kbuf[1] = '\0';
-                   }
-                   break;
-
-               case XK_Find:
-                   STRCPY(kbuf, "\033[1~");
-                   break;
-               case XK_Insert:
-                   STRCPY(kbuf, "\033[2~");
-                   break;
+                  case XK_KP_Begin:
+                    STRCPY(kbuf, "\033Ou");
+                    break;
+
+                  case XK_KP_Insert:
+                    STRCPY(kbuf, "\033Op");
+                    break;
+
+                  case XK_KP_Delete:
+                    STRCPY(kbuf, "\033On");
+                    break;
+#endif
+                  case XK_KP_F1:       /* "\033OP" */
+                  case XK_KP_F2:       /* "\033OQ" */
+                  case XK_KP_F3:       /* "\033OR" */
+                  case XK_KP_F4:       /* "\033OS" */
+                    STRCPY(kbuf, "\033OP");
+                    kbuf[2] += (keysym - XK_KP_F1);
+                    break;
+
+                  case XK_KP_Multiply: /* "\033Oj" : "*" */
+                  case XK_KP_Add:              /* "\033Ok" : "+" */
+                  case XK_KP_Separator:        /* "\033Ol" : "," */
+                  case XK_KP_Subtract: /* "\033Om" : "-" */
+                  case XK_KP_Decimal:  /* "\033On" : "." */
+                  case XK_KP_Divide:   /* "\033Oo" : "/" */
+                  case XK_KP_0:                /* "\033Op" : "0" */
+                  case XK_KP_1:                /* "\033Oq" : "1" */
+                  case XK_KP_2:                /* "\033Or" : "2" */
+                  case XK_KP_3:                /* "\033Os" : "3" */
+                  case XK_KP_4:                /* "\033Ot" : "4" */
+                  case XK_KP_5:                /* "\033Ou" : "5" */
+                  case XK_KP_6:                /* "\033Ov" : "6" */
+                  case XK_KP_7:                /* "\033Ow" : "7" */
+                  case XK_KP_8:                /* "\033Ox" : "8" */
+                  case XK_KP_9:                /* "\033Oy" : "9" */
+                    /* allow shift to override */
+                    if ((PrivateModes & PrivMode_aplKP) ? !shft : shft)
+                      {
+                        STRCPY(kbuf, "\033Oj");
+                        kbuf[2] += (keysym - XK_KP_Multiply);
+                      }
+                    else
+                      {
+                        kbuf[0] = ('*' + (keysym - XK_KP_Multiply));
+                        kbuf[1] = '\0';
+                      }
+                    break;
+
+                  case XK_Find:
+                    STRCPY(kbuf, "\033[1~");
+                    break;
+                  case XK_Insert:
+                    STRCPY(kbuf, "\033[2~");
+                    break;
 #ifdef DXK_Remove              /* support for DEC remove like key */
-               case DXK_Remove:
-               /* FALLTHROUGH */
-#endif
-               case XK_Execute:
-                   STRCPY(kbuf, "\033[3~");
-                   break;
-               case XK_Select:
-                   STRCPY(kbuf, "\033[4~");
-                   break;
+                  case DXK_Remove:
+                    /* FALLTHROUGH */
+#endif
+                  case XK_Execute:
+                    STRCPY(kbuf, "\033[3~");
+                    break;
+                  case XK_Select:
+                    STRCPY(kbuf, "\033[4~");
+                    break;
 #ifdef XK_KP_End
-               case XK_KP_End:
-               /* allow shift to override */
-                   if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) {
-                       STRCPY(kbuf, "\033Oq");
-                       break;
-                   }
-               /* FALLTHROUGH */
-#endif
-               case XK_End:
-                   STRCPY(kbuf, KS_END);
-                   break;
+                  case XK_KP_End:
+                    /* allow shift to override */
+                    if ((PrivateModes & PrivMode_aplKP) ? !shft : shft)
+                      {
+                        STRCPY(kbuf, "\033Oq");
+                        break;
+                      }
+                    /* FALLTHROUGH */
+#endif
+                  case XK_End:
+                    STRCPY(kbuf, KS_END);
+                    break;
 #ifdef XK_KP_Home
-               case XK_KP_Home:
-               /* allow shift to override */
-                   if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) {
-                       STRCPY(kbuf, "\033Ow");
-                       break;
-                   }
-               /* FALLTHROUGH */
-#endif
-               case XK_Home:
-                   STRCPY(kbuf, KS_HOME);
-                   break;
+                  case XK_KP_Home:
+                    /* allow shift to override */
+                    if ((PrivateModes & PrivMode_aplKP) ? !shft : shft)
+                      {
+                        STRCPY(kbuf, "\033Ow");
+                        break;
+                      }
+                    /* FALLTHROUGH */
+#endif
+                  case XK_Home:
+                    STRCPY(kbuf, KS_HOME);
+                    break;
 
 #define FKEY(n, fkey)                                                  \
     sprintf((char *)kbuf,"\033[%2d~", (int)((n) + (keysym - fkey)))
 
-               case XK_F1:     /* "\033[11~" */
-               case XK_F2:     /* "\033[12~" */
-               case XK_F3:     /* "\033[13~" */
-               case XK_F4:     /* "\033[14~" */
-               case XK_F5:     /* "\033[15~" */
-                   FKEY(11, XK_F1);
-                   break;
-               case XK_F6:     /* "\033[17~" */
-               case XK_F7:     /* "\033[18~" */
-               case XK_F8:     /* "\033[19~" */
-               case XK_F9:     /* "\033[20~" */
-               case XK_F10:    /* "\033[21~" */
-                   FKEY(17, XK_F6);
-                   break;
-               case XK_F11:    /* "\033[23~" */
-               case XK_F12:    /* "\033[24~" */
-               case XK_F13:    /* "\033[25~" */
-               case XK_F14:    /* "\033[26~" */
-                   FKEY(23, XK_F11);
-                   break;
-               case XK_F15:    /* "\033[28~" */
-               case XK_F16:    /* "\033[29~" */
-                   FKEY(28, XK_F15);
-                   break;
-               case XK_Help:   /* "\033[28~" */
-                   FKEY(28, XK_Help);
-                   break;
-               case XK_Menu:   /* "\033[29~" */
-                   FKEY(29, XK_Menu);
-                   break;
-               case XK_F17:    /* "\033[31~" */
-               case XK_F18:    /* "\033[32~" */
-               case XK_F19:    /* "\033[33~" */
-               case XK_F20:    /* "\033[34~" */
-               case XK_F21:    /* "\033[35~" */
-               case XK_F22:    /* "\033[36~" */
-               case XK_F23:    /* "\033[37~" */
-               case XK_F24:    /* "\033[38~" */
-               case XK_F25:    /* "\033[39~" */
-               case XK_F26:    /* "\033[40~" */
-               case XK_F27:    /* "\033[41~" */
-               case XK_F28:    /* "\033[42~" */
-               case XK_F29:    /* "\033[43~" */
-               case XK_F30:    /* "\033[44~" */
-               case XK_F31:    /* "\033[45~" */
-               case XK_F32:    /* "\033[46~" */
-               case XK_F33:    /* "\033[47~" */
-               case XK_F34:    /* "\033[48~" */
-               case XK_F35:    /* "\033[49~" */
-                   FKEY(31, XK_F17);
-                   break;
+                  case XK_F1:  /* "\033[11~" */
+                  case XK_F2:  /* "\033[12~" */
+                  case XK_F3:  /* "\033[13~" */
+                  case XK_F4:  /* "\033[14~" */
+                  case XK_F5:  /* "\033[15~" */
+                    FKEY(11, XK_F1);
+                    break;
+                  case XK_F6:  /* "\033[17~" */
+                  case XK_F7:  /* "\033[18~" */
+                  case XK_F8:  /* "\033[19~" */
+                  case XK_F9:  /* "\033[20~" */
+                  case XK_F10: /* "\033[21~" */
+                    FKEY(17, XK_F6);
+                    break;
+                  case XK_F11: /* "\033[23~" */
+                  case XK_F12: /* "\033[24~" */
+                  case XK_F13: /* "\033[25~" */
+                  case XK_F14: /* "\033[26~" */
+                    FKEY(23, XK_F11);
+                    break;
+                  case XK_F15: /* "\033[28~" */
+                  case XK_F16: /* "\033[29~" */
+                    FKEY(28, XK_F15);
+                    break;
+                  case XK_Help:        /* "\033[28~" */
+                    FKEY(28, XK_Help);
+                    break;
+                  case XK_Menu:        /* "\033[29~" */
+                    FKEY(29, XK_Menu);
+                    break;
+                  case XK_F17: /* "\033[31~" */
+                  case XK_F18: /* "\033[32~" */
+                  case XK_F19: /* "\033[33~" */
+                  case XK_F20: /* "\033[34~" */
+                  case XK_F21: /* "\033[35~" */
+                  case XK_F22: /* "\033[36~" */
+                  case XK_F23: /* "\033[37~" */
+                  case XK_F24: /* "\033[38~" */
+                  case XK_F25: /* "\033[39~" */
+                  case XK_F26: /* "\033[40~" */
+                  case XK_F27: /* "\033[41~" */
+                  case XK_F28: /* "\033[42~" */
+                  case XK_F29: /* "\033[43~" */
+                  case XK_F30: /* "\033[44~" */
+                  case XK_F31: /* "\033[45~" */
+                  case XK_F32: /* "\033[46~" */
+                  case XK_F33: /* "\033[47~" */
+                  case XK_F34: /* "\033[48~" */
+                  case XK_F35: /* "\033[49~" */
+                    FKEY(31, XK_F17);
+                    break;
 #undef FKEY
-               default:
-                   newlen = 0;
-                   break;
-               }
-               if (newlen)
-                   len = STRLEN(kbuf);
-           }
-       /*
-        * Pass meta for all function keys, if 'meta' option set
-        */
+                  default:
+                    newlen = 0;
+                    break;
+                }
+              if (newlen)
+                len = STRLEN(kbuf);
+            }
+          /*
+           * Pass meta for all function keys, if 'meta' option set
+           */
 #ifdef META8_OPTION
-           if (meta && (meta_char == 0x80) && len > 0)
-               kbuf[len - 1] |= 0x80;
+          if (meta && (meta_char == 0x80) && len > 0)
+            kbuf[len - 1] |= 0x80;
 #endif
-       } else if (ctrl && keysym == XK_minus) {
-           len = 1;
-           kbuf[0] = '\037';   /* Ctrl-Minus generates ^_ (31) */
-       } else {
+
+        }
+      else if (ctrl && keysym == XK_minus)
+        {
+          len = 1;
+          kbuf[0] = '\037';    /* Ctrl-Minus generates ^_ (31) */
+        }
+      else
+        {
 #ifdef META8_OPTION
-       /* set 8-bit on */
-           if (meta && (meta_char == 0x80)) {
-               unsigned char  *ch;
+          /* set 8-bit on */
+          if (meta && (meta_char == 0x80))
+            {
+              unsigned char  *ch;
 
-               for (ch = kbuf; ch < kbuf + len; ch++)
-                   *ch |= 0x80;
-               meta = 0;
-           }
+              for (ch = kbuf; ch < kbuf + len; ch++)
+                *ch |= 0x80;
+              meta = 0;
+            }
 #endif
 #ifdef GREEK_SUPPORT
-           if (greek_mode)
-               len = greek_xlat(kbuf, len);
+          if (greek_mode)
+            len = greek_xlat(kbuf, len);
 #endif
-       /* nil */ ;
-       }
-      }
-
-    if (len <= 0)
-       return;                 /* not mapped */
+          /* nil */ ;
+        }
+    }
 
-    if (Options & Opt_scrollTtyKeypress)
-       if (TermWin.view_start) {
-           TermWin.view_start = 0;
-           want_refresh = 1;
-       }
+  if (len <= 0)
+    return;                    /* not mapped */
 
-/*
- * these modifications only affect the static keybuffer
- * pass Shift/Control indicators for function keys ending with `~'
- *
- * eg,
- *   Prior = "ESC[5~"
- *   Shift+Prior = "ESC[5$"
- *   Ctrl+Prior = "ESC[5^"
- *   Ctrl+Shift+Prior = "ESC[5@"
- * Meta adds an Escape prefix (with META8_OPTION, if meta == <escape>).
- */
-    if (kbuf[0] == C0_ESC && kbuf[1] == '[' && kbuf[len - 1] == '~')
-       kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~'));
+  if (Options & Opt_scrollTtyKeypress)
+    if (TermWin.view_start)
+      {
+        TermWin.view_start = 0;
+        want_refresh = 1;
+      }
 
-/* escape prefix */
-    if (meta
+  /*
+   * these modifications only affect the static keybuffer
+   * pass Shift/Control indicators for function keys ending with `~'
+   *
+   * eg,
+   *   Prior = "ESC[5~"
+   *   Shift+Prior = "ESC[5$"
+   *   Ctrl+Prior = "ESC[5^"
+   *   Ctrl+Shift+Prior = "ESC[5@"
+   * Meta adds an Escape prefix (with META8_OPTION, if meta == <escape>).
+   */
+  if (kbuf[0] == C0_ESC && kbuf[1] == '[' && kbuf[len - 1] == '~')
+    kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~'));
+
+  /* escape prefix */
+  if (meta
 #ifdef META8_OPTION
-       && (meta_char == C0_ESC)
+      && (meta_char == C0_ESC)
 #endif
-       ) {
-       const unsigned char ch = C0_ESC;
+     )
+    {
+      const unsigned char ch = C0_ESC;
 
-       tt_write(&ch, 1);
+      tt_write(&ch, 1);
     }
 #ifdef DEBUG_CMD
-    if (debug_key) {           /* Display keyboard buffer contents */
-       char           *p;
-       int             i;
-
-       fprintf(stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len);
-       for (i = 0, p = kbuf; i < len; i++, p++)
-           fprintf(stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p);
-       fprintf(stderr, "'\n");
+  if (debug_key)
+    {          /* Display keyboard buffer contents */
+      char           *p;
+      int             i;
+
+      fprintf(stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len);
+      for (i = 0, p = kbuf; i < len; i++, p++)
+        fprintf(stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p);
+      fprintf(stderr, "'\n");
     }
 #endif                         /* DEBUG_CMD */
-    tt_write (kbuf, (unsigned int)len);
+  tt_write (kbuf, (unsigned int)len);
 }
 /*}}} */
 
@@ -645,24 +709,26 @@ rxvt_term::lookup_key (XKeyEvent *ev)
 unsigned int
 rxvt_term::cmd_write (const unsigned char *str, unsigned int count)
 {
-    unsigned int    n, s;
-
-    n = cmdbuf_ptr - cmdbuf_base;
-    s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp;
-    if (n > 0 && s < count) {
-       MEMMOVE(cmdbuf_base, cmdbuf_ptr,
-               (unsigned int)(cmdbuf_endp - cmdbuf_ptr));
-       cmdbuf_ptr = cmdbuf_base;
-       cmdbuf_endp -= n;
-       s += n;
+  unsigned int    n, s;
+
+  n = cmdbuf_ptr - cmdbuf_base;
+  s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp;
+  if (n > 0 && s < count)
+    {
+      MEMMOVE(cmdbuf_base, cmdbuf_ptr,
+              (unsigned int)(cmdbuf_endp - cmdbuf_ptr));
+      cmdbuf_ptr = cmdbuf_base;
+      cmdbuf_endp -= n;
+      s += n;
     }
-    if (count > s) {
-       rxvt_print_error("data loss: cmd_write too large");
-       count = s;
+  if (count > s)
+    {
+      rxvt_print_error("data loss: cmd_write too large");
+      count = s;
     }
-    for (; count--;)
-       *cmdbuf_endp++ = *str++;
-    return 0;
+  for (; count--;)
+    *cmdbuf_endp++ = *str++;
+  return 0;
 }
 #endif                         /* MENUBAR_MAX */
 
@@ -686,6 +752,7 @@ rxvt_term::flush ()
 #ifdef USE_XIM
       IMSendSpot ();
 #endif
+
     }
 
   XFlush (Xdisplay);
@@ -785,7 +852,7 @@ rxvt_term::pty_fill ()
   memmove (cmdbuf_base, cmdbuf_ptr, n);
   cmdbuf_ptr = cmdbuf_base;
   cmdbuf_endp = cmdbuf_ptr + n;
+
   n = read (cmd_fd, cmdbuf_endp, BUFSIZ - n);
 
   if (n > 0)
@@ -905,8 +972,8 @@ rxvt_term::pty_cb (io_watcher &w, short revents)
                       case C0_ESC:     /* escape char */
                         process_escape_seq ();
                         break;
-                      /*case 0x9b: */  /* CSI */
-                      /*  process_csi_seq (); */
+                        /*case 0x9b: */        /* CSI */
+                        /*  process_csi_seq (); */
                     }
 
                   ch = NOCHAR;
@@ -963,65 +1030,6 @@ rxvt_term::cmd_getc ()
       pty_fill ();
       fcntl (cmd_fd, F_SETFL, O_NONBLOCK);
     }
-
-#if 0
-#define TIMEOUT_USEC   5000
-    fd_set          readfds;
-    int             quick_timeout, select_res;
-    int             want_motion_time, want_keypress_time;
-    struct timeval  value;
-#if defined(POINTER_BLANK) || defined(CURSOR_BLINK)
-    struct timeval  tp;
-#endif
-
-    for (;;) {
-    /* loop until we can return something */
-
-       if (v_bufstr < v_bufptr)        /* output any pending chars */
-           tt_write(NULL, 0);
-
-#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
-       if (mouse_slip_wheel_speed) {
-           quick_timeout = 1;
-           if (!mouse_slip_wheel_delay--
-               && scr_page (mouse_slip_wheel_speed > 0 ? UP : DN,
-                                abs(mouse_slip_wheel_speed))) {
-               mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY;
-               refresh_type |= SMOOTH_REFRESH;
-               want_refresh = 1;
-           }
-       }
-#endif /* MOUSE_WHEEL && MOUSE_SLIP_WHEELING */
-#ifdef SELECTION_SCROLLING
-       if (pending_scroll_selection) {
-           quick_timeout = 1;
-           if (!scroll_selection_delay--
-               && scr_page (scroll_selection_dir,
-                   scroll_selection_lines)) {
-               selection_extend (selection_save_x,
-                   selection_save_y, selection_save_state);
-               scroll_selection_delay = SCROLLBAR_CONTINUOUS_DELAY;
-               refresh_type |= SMOOTH_REFRESH;
-               want_refresh = 1;
-           }
-       }
-#endif
-#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
-       if (scrollbar_isUp() || scrollbar_isDn()) {
-           quick_timeout = 1;
-           if (!scroll_arrow_delay--
-               && scr_page (scrollbar_isUp() ? UP : DN, 1)) {
-               scroll_arrow_delay = SCROLLBAR_CONTINUOUS_DELAY;
-               refresh_type |= SMOOTH_REFRESH;
-               want_refresh = 1;
-           }
-       }
-#endif                         /* NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING */
-
-#ifdef TRANSPARENT
-           quick_timeout |= want_full_refresh;
-#endif
-#endif
 }
 
 #ifdef POINTER_BLANK
@@ -1062,65 +1070,72 @@ rxvt_term::pointer_cb (time_watcher &w)
 void
 rxvt_term::mouse_report (const XButtonEvent *ev)
 {
-    int             button_number, key_state = 0;
-    int             x, y;
-
-    x = ev->x;
-    y = ev->y;
-    pixel_position (&x, &y);
-
-    if (MEvent.button == AnyButton) {
-       button_number = 3;
-    } else {
-       button_number = MEvent.button - Button1;
-       /* add 0x3D for wheel events, like xterm does */
-       if (button_number >= 3)
-           button_number += (64 - 3);
+  int             button_number, key_state = 0;
+  int             x, y;
+
+  x = ev->x;
+  y = ev->y;
+  pixel_position (&x, &y);
+
+  if (MEvent.button == AnyButton)
+    {
+      button_number = 3;
+    }
+  else
+    {
+      button_number = MEvent.button - Button1;
+      /* add 0x3D for wheel events, like xterm does */
+      if (button_number >= 3)
+        button_number += (64 - 3);
     }
 
-    if (PrivateModes & PrivMode_MouseX10) {
-    /*
-     * do not report ButtonRelease
-     * no state info allowed
-     */
-       key_state = 0;
-       if (button_number == 3)
-           return;
-    } else {
-    /* XTerm mouse reporting needs these values:
-     *   4 = Shift
-     *   8 = Meta
-     *  16 = Control
-     * plus will add in our own Double-Click reporting
-     *  32 = Double Click
-     */
-       key_state = ((MEvent.state & ShiftMask) ? 4 : 0)
-                    + ((MEvent.state & ModMetaMask) ? 8 : 0)
-                    + ((MEvent.state & ControlMask) ? 16 : 0);
+  if (PrivateModes & PrivMode_MouseX10)
+    {
+      /*
+       * do not report ButtonRelease
+       * no state info allowed
+       */
+      key_state = 0;
+      if (button_number == 3)
+        return;
+    }
+  else
+    {
+      /* XTerm mouse reporting needs these values:
+       *   4 = Shift
+       *   8 = Meta
+       *  16 = Control
+       * plus will add in our own Double-Click reporting
+       *  32 = Double Click
+       */
+      key_state = ((MEvent.state & ShiftMask) ? 4 : 0)
+                  + ((MEvent.state & ModMetaMask) ? 8 : 0)
+                  + ((MEvent.state & ControlMask) ? 16 : 0);
 #ifdef MOUSE_REPORT_DOUBLECLICK
-       key_state += ((MEvent.clicks > 1) ? 32 : 0);
+      key_state += ((MEvent.clicks > 1) ? 32 : 0);
 #endif
+
     }
 
 #ifdef DEBUG_MOUSEREPORT
-    fprintf(stderr, "Mouse [");
-    if (key_state & 16)
-       fputc('C', stderr);
-    if (key_state & 4)
-       fputc('S', stderr);
-    if (key_state & 8)
-       fputc('A', stderr);
-    if (key_state & 32)
-       fputc('2', stderr);
-    fprintf(stderr, "]: <%d>, %d/%d\n",
-           button_number,
-           x + 1,
-           y + 1);
+  fprintf(stderr, "Mouse [");
+  if (key_state & 16)
+    fputc('C', stderr);
+  if (key_state & 4)
+    fputc('S', stderr);
+  if (key_state & 8)
+    fputc('A', stderr);
+  if (key_state & 32)
+    fputc('2', stderr);
+  fprintf(stderr, "]: <%d>, %d/%d\n",
+          button_number,
+          x + 1,
+          y + 1);
 #else
-    tt_printf("\033[M%c%c%c",
-             (32 + button_number + key_state),
-             (32 + x + 1),
-             (32 + y + 1));
+  tt_printf("\033[M%c%c%c",
+            (32 + button_number + key_state),
+            (32 + x + 1),
+            (32 + y + 1));
 #endif
 }
 
@@ -1128,9 +1143,9 @@ rxvt_term::mouse_report (const XButtonEvent *ev)
 void
 rxvt_W11_process_x_event(XEvent *ev)
 {
-    rxvt_t         *r = rxvt_get_r();
+  rxvt_t         *r = rxvt_get_r();
 
-    process_x_event (ev);
+  process_x_event (ev);
 }
 #endif
 
@@ -1138,137 +1153,140 @@ rxvt_W11_process_x_event(XEvent *ev)
 void
 rxvt_term::process_x_event (XEvent *ev)
 {
-    Window          unused_root, unused_child;
-    int             unused_root_x, unused_root_y;
-    unsigned int    unused_mask;
+  Window          unused_root, unused_child;
+  int             unused_root_x, unused_root_y;
+  unsigned int    unused_mask;
 
 #ifdef DEBUG_X
-    const char *const eventnames[] =
+  const char *const eventnames[] =
     {                          /* mason - this matches my system */
-       "",
-       "",
-       "KeyPress",
-       "KeyRelease",
-       "ButtonPress",
-       "ButtonRelease",
-       "MotionNotify",
-       "EnterNotify",
-       "LeaveNotify",
-       "FocusIn",
-       "FocusOut",
-       "KeymapNotify",
-       "Expose",
-       "GraphicsExpose",
-       "NoExpose",
-       "VisibilityNotify",
-       "CreateNotify",
-       "DestroyNotify",
-       "UnmapNotify",
-       "MapNotify",
-       "MapRequest",
-       "ReparentNotify",
-       "ConfigureNotify",
-       "ConfigureRequest",
-       "GravityNotify",
-       "ResizeRequest",
-       "CirculateNotify",
-       "CirculateRequest",
-       "PropertyNotify",
-       "SelectionClear",
-       "SelectionRequest",
-       "SelectionNotify",
-       "ColormapNotify",
-       "ClientMessage",
-       "MappingNotify"
+      "",
+      "",
+      "KeyPress",
+      "KeyRelease",
+      "ButtonPress",
+      "ButtonRelease",
+      "MotionNotify",
+      "EnterNotify",
+      "LeaveNotify",
+      "FocusIn",
+      "FocusOut",
+      "KeymapNotify",
+      "Expose",
+      "GraphicsExpose",
+      "NoExpose",
+      "VisibilityNotify",
+      "CreateNotify",
+      "DestroyNotify",
+      "UnmapNotify",
+      "MapNotify",
+      "MapRequest",
+      "ReparentNotify",
+      "ConfigureNotify",
+      "ConfigureRequest",
+      "GravityNotify",
+      "ResizeRequest",
+      "CirculateNotify",
+      "CirculateRequest",
+      "PropertyNotify",
+      "SelectionClear",
+      "SelectionRequest",
+      "SelectionNotify",
+      "ColormapNotify",
+      "ClientMessage",
+      "MappingNotify"
     };
 #endif
 
 #ifdef DEBUG_X
-    struct timeval  tp;
-    struct tm      *ltt;
-    (void)gettimeofday(&tp, NULL);
-    ltt = localtime(&(tp.tv_sec));
-    D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == TermWin.parent[0] ? "parent" : (ev->xany.window == TermWin.vt ? "vt" : (ev->xany.window == scrollBar.win ? "scroll" : (ev->xany.window == menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == TermWin.parent[0] ? TermWin.parent[0] : (ev->xany.window == TermWin.vt ? TermWin.vt : (ev->xany.window == scrollBar.win ? scrollBar.win : (ev->xany.window == menuBar.win ? menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial));
+  struct timeval  tp;
+  struct tm      *ltt;
+  (void)gettimeofday(&tp, NULL);
+  ltt = localtime(&(tp.tv_sec));
+  D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == TermWin.parent[0] ? "parent" : (ev->xany.window == TermWin.vt ? "vt" : (ev->xany.window == scrollBar.win ? "scroll" : (ev->xany.window == menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == TermWin.parent[0] ? TermWin.parent[0] : (ev->xany.window == TermWin.vt ? TermWin.vt : (ev->xany.window == scrollBar.win ? scrollBar.win : (ev->xany.window == menuBar.win ? menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial));
 #endif
 
-    switch (ev->type) {
-    case KeyPress:
-       lookup_key ((XKeyEvent *)ev);
-       break;
+  switch (ev->type)
+    {
+      case KeyPress:
+        lookup_key ((XKeyEvent *)ev);
+        break;
 
 #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
-    case KeyRelease:
-       {
-           if (!(ev->xkey.state & ControlMask))
-               mouse_slip_wheel_speed = 0;
-           else {
-               KeySym          ks;
-               
-               ks = XKeycodeToKeysym(Xdisplay, ev->xkey.keycode, 0);
-               if (ks == XK_Control_L || ks == XK_Control_R)
-                   mouse_slip_wheel_speed = 0;
-           }
-           break;
-       }
-#endif
-
-    case ButtonPress:
-       button_press ((XButtonEvent *)ev);
-       break;
-
-    case ButtonRelease:
-       button_release ((XButtonEvent *)ev);
-       break;
-
-    case ClientMessage:
-       if (ev->xclient.format == 32
-           && (Atom)ev->xclient.data.l[0] == xa[XA_WMDELETEWINDOW])
+      case KeyRelease:
+        {
+          if (!(ev->xkey.state & ControlMask))
+            mouse_slip_wheel_speed = 0;
+          else
+            {
+              KeySym          ks;
+
+              ks = XKeycodeToKeysym(Xdisplay, ev->xkey.keycode, 0);
+              if (ks == XK_Control_L || ks == XK_Control_R)
+                mouse_slip_wheel_speed = 0;
+            }
+          break;
+        }
+#endif
+
+      case ButtonPress:
+        button_press ((XButtonEvent *)ev);
+        break;
+
+      case ButtonRelease:
+        button_release ((XButtonEvent *)ev);
+        break;
+
+      case ClientMessage:
+        if (ev->xclient.format == 32
+            && (Atom)ev->xclient.data.l[0] == xa[XA_WMDELETEWINDOW])
           destroy ();
 #ifdef OFFIX_DND
-    /* OffiX Dnd (drag 'n' drop) protocol */
+        /* OffiX Dnd (drag 'n' drop) protocol */
         else if (ev->xclient.message_type == xa[XA_DNDPROTOCOL]
-           && (ev->xclient.data.l[0] == DndFile
-               || ev->xclient.data.l[0] == DndDir
-               || ev->xclient.data.l[0] == DndLink)) {
-       /* Get Dnd data */
-           Atom            ActualType;
-           int             ActualFormat;
-           unsigned char  *data;
-           unsigned long   Size, RemainingBytes;
-
-           XGetWindowProperty(Xdisplay, Xroot,
-                              xa[XA_DNDSELECTION],
-                              0L, 1000000L,
-                              False, AnyPropertyType,
-                              &ActualType, &ActualFormat,
-                              &Size, &RemainingBytes,
-                              &data);
-           XChangeProperty(Xdisplay, Xroot,
-                           XA_CUT_BUFFER0, XA_STRING,
-                           8, PropModeReplace,
-                           data, STRLEN(data));
-           selection_paste (Xroot, XA_CUT_BUFFER0, True);
-           XSetInputFocus(Xdisplay, Xroot, RevertToNone, CurrentTime);
-       }
+                 && (ev->xclient.data.l[0] == DndFile
+                     || ev->xclient.data.l[0] == DndDir
+                     || ev->xclient.data.l[0] == DndLink))
+          {
+            /* Get Dnd data */
+            Atom            ActualType;
+            int             ActualFormat;
+            unsigned char  *data;
+            unsigned long   Size, RemainingBytes;
+
+            XGetWindowProperty(Xdisplay, Xroot,
+                               xa[XA_DNDSELECTION],
+                               0L, 1000000L,
+                               False, AnyPropertyType,
+                               &ActualType, &ActualFormat,
+                               &Size, &RemainingBytes,
+                               &data);
+            XChangeProperty(Xdisplay, Xroot,
+                            XA_CUT_BUFFER0, XA_STRING,
+                            8, PropModeReplace,
+                            data, STRLEN(data));
+            selection_paste (Xroot, XA_CUT_BUFFER0, True);
+            XSetInputFocus(Xdisplay, Xroot, RevertToNone, CurrentTime);
+          }
 #endif                         /* OFFIX_DND */
-       break;
-
-    case MappingNotify:
-       XRefreshKeyboardMapping(&(ev->xmapping));
-       break;
-
-    /*
-     * XXX: this is not the _current_ arrangement
-     * Here's my conclusion:
-     * If the window is completely unobscured, use bitblt's
-     * to scroll. Even then, they're only used when doing partial
-     * screen scrolling. When partially obscured, we have to fill
-     * in the GraphicsExpose parts, which means that after each refresh,
-     * we need to wait for the graphics expose or Noexpose events,
-     * which ought to make things real slow!
-     */
-    case VisibilityNotify:
-       switch (ev->xvisibility.state)
+        break;
+
+      case MappingNotify:
+        XRefreshKeyboardMapping(&(ev->xmapping));
+        break;
+
+        /*
+         * XXX: this is not the _current_ arrangement
+         * Here's my conclusion:
+         * If the window is completely unobscured, use bitblt's
+         * to scroll. Even then, they're only used when doing partial
+         * screen scrolling. When partially obscured, we have to fill
+         * in the GraphicsExpose parts, which means that after each refresh,
+         * we need to wait for the graphics expose or Noexpose events,
+         * which ought to make things real slow!
+         */
+      case VisibilityNotify:
+        switch (ev->xvisibility.state)
           {
             case VisibilityUnobscured:
               refresh_type = FAST_REFRESH;
@@ -1280,592 +1298,644 @@ rxvt_term::process_x_event (XEvent *ev)
               refresh_type = NO_REFRESH;
               break;
           }
-       break;
+        break;
 
-    case FocusIn:
-       if (!TermWin.focus) {
-           TermWin.focus = 1;
-           want_refresh = 1;
+      case FocusIn:
+        if (!TermWin.focus)
+          {
+            TermWin.focus = 1;
+            want_refresh = 1;
 #ifdef USE_XIM
-           if (Input_Context != NULL)
-               XSetICFocus(Input_Context);
+            if (Input_Context != NULL)
+              XSetICFocus(Input_Context);
 #endif
 #ifdef CURSOR_BLINK
             if (Options & Opt_cursorBlink)
               cursor_blink_ev.start (NOW + BLINK_INTERVAL);
 #endif
-       }
-       break;
 
-    case FocusOut:
-       if (TermWin.focus) {
-           TermWin.focus = 0;
-           want_refresh = 1;
+          }
+        break;
+
+      case FocusOut:
+        if (TermWin.focus)
+          {
+            TermWin.focus = 0;
+            want_refresh = 1;
 #ifdef USE_XIM
-           if (Input_Context != NULL)
-               XUnsetICFocus(Input_Context);
+            if (Input_Context != NULL)
+              XUnsetICFocus(Input_Context);
 #endif
 #ifdef CURSOR_BLINK
             if (Options & Opt_cursorBlink)
               cursor_blink_ev.stop ();
             hidden_cursor = 0;
 #endif
-       }
-       break;
-
-    case ConfigureNotify:
-       if (ev->xconfigure.window == TermWin.parent[0]) {
-           int             height, width;
-
-           do {        /* Wrap lots of configures into one */
-               width = ev->xconfigure.width;
-               height = ev->xconfigure.height;
-               D_SIZE((stderr, "Size: ConfigureNotify: %4d x %4d", width, height));
-           } while (XCheckTypedWindowEvent(Xdisplay, ev->xconfigure.window,
-                                           ConfigureNotify, ev));
-           if (szHint.width != width || szHint.height != height) {
-               D_SIZE((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height));
-               resize_all_windows (width, height, 1);
-           }
+
+          }
+        break;
+
+      case ConfigureNotify:
+        if (ev->xconfigure.window == TermWin.parent[0])
+          {
+            int             height, width;
+
+            do
+              {        /* Wrap lots of configures into one */
+                width = ev->xconfigure.width;
+                height = ev->xconfigure.height;
+                D_SIZE((stderr, "Size: ConfigureNotify: %4d x %4d", width, height));
+              }
+            while (XCheckTypedWindowEvent(Xdisplay, ev->xconfigure.window,
+                                          ConfigureNotify, ev));
+            if (szHint.width != width || szHint.height != height)
+              {
+                D_SIZE((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height));
+                resize_all_windows (width, height, 1);
+              }
 #ifdef DEBUG_SIZE
-           else {
-               D_SIZE((stderr, "Size: Not resizing"));
-           }
+            else
+              {
+                D_SIZE((stderr, "Size: Not resizing"));
+              }
 #endif
 #ifdef TRANSPARENT             /* XXX: maybe not needed - leave in for now */
-           if (Options & Opt_transparent) {
-               check_our_parents ();
-               if (am_transparent)
-                   want_full_refresh = 1;
-           }
-#endif
-       }
-       break;
-
-    case SelectionClear:
-       selection_clear ();
-       break;
-
-    case SelectionNotify:
-       if (selection_wait == Sel_normal)
-           selection_paste (ev->xselection.requestor,
-                                ev->xselection.property, True);
-       break;
-
-    case SelectionRequest:
-       selection_send (&(ev->xselectionrequest));
-       break;
-
-    case UnmapNotify:
-       TermWin.mapped = 0;
+            if (Options & Opt_transparent)
+              {
+                check_our_parents ();
+                if (am_transparent)
+                  want_full_refresh = 1;
+              }
+#endif
+
+          }
+        break;
+
+      case SelectionClear:
+        selection_clear ();
+        break;
+
+      case SelectionNotify:
+        if (selection_wait == Sel_normal)
+          selection_paste (ev->xselection.requestor,
+                           ev->xselection.property, True);
+        break;
+
+      case SelectionRequest:
+        selection_send (&(ev->xselectionrequest));
+        break;
+
+      case UnmapNotify:
+        TermWin.mapped = 0;
 #ifdef TEXT_BLINK
         text_blink_ev.stop ();
 #endif
-       break;
+        break;
 
-    case MapNotify:
-       TermWin.mapped = 1;
+      case MapNotify:
+        TermWin.mapped = 1;
 #ifdef TEXT_BLINK
         text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
 #endif
-       break;
+        break;
 
-    case PropertyNotify:
-       if (ev->xproperty.atom == xa[XA_VT_SELECTION]) {
-           if (ev->xproperty.state == PropertyNewValue)
-               selection_property (ev->xproperty.window,
-                                       ev->xproperty.atom);
-           break;
-       }
+      case PropertyNotify:
+        if (ev->xproperty.atom == xa[XA_VT_SELECTION])
+          {
+            if (ev->xproperty.state == PropertyNewValue)
+              selection_property (ev->xproperty.window,
+                                  ev->xproperty.atom);
+            break;
+          }
 #ifdef TRANSPARENT
-    /*
-     * if user used some Esetroot compatible prog to set the root bg,
-     * use the property to determine the pixmap.  We use it later on.
-     */
-       if (xa[XA_XROOTPMAPID] == 0)
-           xa[XA_XROOTPMAPID] = XInternAtom(Xdisplay,
-                                              "_XROOTPMAP_ID", False);
-       if (ev->xproperty.atom != xa[XA_XROOTPMAPID])
-           break;
-    /* FALLTHROUGH */
-    case ReparentNotify:
-       if ((Options & Opt_transparent) && check_our_parents ()) {
-           if (am_transparent)
-               want_full_refresh = 1;
-       }
+        /*
+         * if user used some Esetroot compatible prog to set the root bg,
+         * use the property to determine the pixmap.  We use it later on.
+         */
+        if (xa[XA_XROOTPMAPID] == 0)
+          xa[XA_XROOTPMAPID] = XInternAtom(Xdisplay,
+                                           "_XROOTPMAP_ID", False);
+        if (ev->xproperty.atom != xa[XA_XROOTPMAPID])
+          break;
+        /* FALLTHROUGH */
+      case ReparentNotify:
+        if ((Options & Opt_transparent) && check_our_parents ())
+          {
+            if (am_transparent)
+              want_full_refresh = 1;
+          }
 #endif                         /* TRANSPARENT */
-       break;
+        break;
 
-    case GraphicsExpose:
-    case Expose:
-       if (ev->xany.window == TermWin.vt) {
+      case GraphicsExpose:
+      case Expose:
+        if (ev->xany.window == TermWin.vt)
+          {
 #ifdef NO_SLOW_LINK_SUPPORT
-           scr_expose (ev->xexpose.x, ev->xexpose.y,
-                          ev->xexpose.width, ev->xexpose.height, False);
+            scr_expose (ev->xexpose.x, ev->xexpose.y,
+                        ev->xexpose.width, ev->xexpose.height, False);
 #else
             // don't understand this, so commented it out
-           scr_expose (ev->xexpose.x, ev->xexpose.y,
-                          ev->xexpose.width, ev->xexpose.height, False);
-           //scr_expose (ev->xexpose.x, 0,
-           //              ev->xexpose.width, TermWin.height, False);
-#endif
-           want_refresh = 1;
-       } else {
-           XEvent          unused_xevent;
-
-           while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window,
-                                         Expose,
-                                         &unused_xevent)) ;
-           while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window,
-                                         GraphicsExpose,
-                                         &unused_xevent)) ;
-           if (isScrollbarWindow(ev->xany.window)) {
-               scrollBar.setIdle();
-               scrollbar_show (0);
-           }
+            scr_expose (ev->xexpose.x, ev->xexpose.y,
+                        ev->xexpose.width, ev->xexpose.height, False);
+            //scr_expose (ev->xexpose.x, 0,
+            //             ev->xexpose.width, TermWin.height, False);
+#endif
+            want_refresh = 1;
+          }
+        else
+          {
+            XEvent          unused_xevent;
+
+            while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window,
+                                          Expose,
+                                          &unused_xevent)) ;
+            while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window,
+                                          GraphicsExpose,
+                                          &unused_xevent)) ;
+            if (isScrollbarWindow(ev->xany.window))
+              {
+                scrollBar.setIdle();
+                scrollbar_show (0);
+              }
 #ifdef MENUBAR
-           if (menubar_visible () && isMenuBarWindow(ev->xany.window))
-               menubar_expose ();
+            if (menubar_visible () && isMenuBarWindow(ev->xany.window))
+              menubar_expose ();
 #endif
 #ifdef RXVT_GRAPHICS
-           Gr_expose (ev->xany.window);
+            Gr_expose (ev->xany.window);
 #endif
-       }
-       break;
 
-    case MotionNotify:
+          }
+        break;
+
+      case MotionNotify:
 #ifdef POINTER_BLANK
-       if (hidden_pointer)
-           pointer_unblank ();
+        if (hidden_pointer)
+          pointer_unblank ();
 #endif
 #if MENUBAR
-       if (isMenuBarWindow(ev->xany.window)) {
-           menubar_control (&(ev->xbutton));
-           break;
-       }
-#endif
-       if ((PrivateModes & PrivMode_mouse_report) && !(bypass_keystate))
-           break;
-
-       if (ev->xany.window == TermWin.vt) {
-           if ((ev->xbutton.state & (Button1Mask | Button3Mask))) {
-               while (XCheckTypedWindowEvent(Xdisplay, TermWin.vt,
-                                             MotionNotify, ev)) ;
-               XQueryPointer(Xdisplay, TermWin.vt,
-                             &unused_root, &unused_child,
-                             &unused_root_x, &unused_root_y,
-                             &(ev->xbutton.x), &(ev->xbutton.y),
-                             &unused_mask);
+        if (isMenuBarWindow(ev->xany.window))
+          {
+            menubar_control (&(ev->xbutton));
+            break;
+          }
+#endif
+        if ((PrivateModes & PrivMode_mouse_report) && !(bypass_keystate))
+          break;
+
+        if (ev->xany.window == TermWin.vt)
+          {
+            if ((ev->xbutton.state & (Button1Mask | Button3Mask)))
+              {
+                while (XCheckTypedWindowEvent(Xdisplay, TermWin.vt,
+                                              MotionNotify, ev)) ;
+                XQueryPointer(Xdisplay, TermWin.vt,
+                              &unused_root, &unused_child,
+                              &unused_root_x, &unused_root_y,
+                              &(ev->xbutton.x), &(ev->xbutton.y),
+                              &unused_mask);
 #ifdef MOUSE_THRESHOLD
-           /* deal with a `jumpy' mouse */
-               if ((ev->xmotion.time - MEvent.time) > MOUSE_THRESHOLD) {
+                /* deal with a `jumpy' mouse */
+                if ((ev->xmotion.time - MEvent.time) > MOUSE_THRESHOLD)
+                  {
 #endif
-                   selection_extend ((ev->xbutton.x), (ev->xbutton.y),
-                                 (ev->xbutton.state & Button3Mask) ? 2 : 0);
+                    selection_extend ((ev->xbutton.x), (ev->xbutton.y),
+                                      (ev->xbutton.state & Button3Mask) ? 2 : 0);
 #ifdef SELECTION_SCROLLING
-                   if (ev->xbutton.y < TermWin.int_bwidth
-                        || Pixel2Row(ev->xbutton.y) > (TermWin.nrow-1)) {
-                       int dist;
-                       
-                       pending_scroll_selection=1;
-                       
-                         /* don't clobber the current delay if we are
-                          * already in the middle of scrolling.
-                          */
-                       if (scroll_selection_delay<=0)
-                           scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY;
-
-                         /* save the event params so we can highlight
-                          * the selection in the pending-scroll loop
-                          */
-                       selection_save_x=ev->xbutton.x;
-                       selection_save_y=ev->xbutton.y;
-                       selection_save_state=
-                           (ev->xbutton.state & Button3Mask) ? 2 : 0;
-
-                         /* calc number of lines to scroll */
-                       if (ev->xbutton.y<TermWin.int_bwidth) {
-                           scroll_selection_dir = UP;
-                           dist = TermWin.int_bwidth - ev->xbutton.y;
-                       }
-                       else {
-                           scroll_selection_dir = DN;
-                           dist = ev->xbutton.y -
-                               (TermWin.int_bwidth + TermWin.height);
-                       }
-                       scroll_selection_lines=(Pixel2Height(dist)/
-                           SELECTION_SCROLL_LINE_SPEEDUP)+1;
-                       MIN_IT(scroll_selection_lines,
-                           SELECTION_SCROLL_MAX_LINES);
-                   }
-                   else {
-                         /* we are within the text window, so we
-                          * shouldn't be scrolling
-                          */
-                       pending_scroll_selection = 0;
-                   }
+                    if (ev->xbutton.y < TermWin.int_bwidth
+                        || Pixel2Row(ev->xbutton.y) > (TermWin.nrow-1))
+                      {
+                        int dist;
+
+                        pending_scroll_selection=1;
+
+                        /* don't clobber the current delay if we are
+                         * already in the middle of scrolling.
+                         */
+                        if (scroll_selection_delay<=0)
+                          scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY;
+
+                        /* save the event params so we can highlight
+                         * the selection in the pending-scroll loop
+                         */
+                        selection_save_x=ev->xbutton.x;
+                        selection_save_y=ev->xbutton.y;
+                        selection_save_state=
+                          (ev->xbutton.state & Button3Mask) ? 2 : 0;
+
+                        /* calc number of lines to scroll */
+                        if (ev->xbutton.y<TermWin.int_bwidth)
+                          {
+                            scroll_selection_dir = UP;
+                            dist = TermWin.int_bwidth - ev->xbutton.y;
+                          }
+                        else
+                          {
+                            scroll_selection_dir = DN;
+                            dist = ev->xbutton.y -
+                                   (TermWin.int_bwidth + TermWin.height);
+                          }
+                        scroll_selection_lines=(Pixel2Height(dist)/
+                                                SELECTION_SCROLL_LINE_SPEEDUP)+1;
+                        MIN_IT(scroll_selection_lines,
+                               SELECTION_SCROLL_MAX_LINES);
+                      }
+                    else
+                      {
+                        /* we are within the text window, so we
+                         * shouldn't be scrolling
+                         */
+                        pending_scroll_selection = 0;
+                      }
 #endif
 #ifdef MOUSE_THRESHOLD
-               }
-#endif
-           }
-       } else if (isScrollbarWindow(ev->xany.window) && scrollbar_isMotion()) {
-           while (XCheckTypedWindowEvent(Xdisplay, scrollBar.win,
-                                         MotionNotify, ev)) ;
-           XQueryPointer(Xdisplay, scrollBar.win,
-                         &unused_root, &unused_child,
-                         &unused_root_x, &unused_root_y,
-                         &(ev->xbutton.x), &(ev->xbutton.y),
-                         &unused_mask);
-           scr_move_to (scrollbar_position(ev->xbutton.y) - csrO,
-                            scrollbar_size());
-           scr_refresh (refresh_type);
-           refresh_limit = 0;
-           scrollbar_show (1);
-       }
-       break;
-    }
-}
+
+                  }
+#endif
+
+              }
+          }
+        else if (isScrollbarWindow(ev->xany.window) && scrollbar_isMotion())
+          {
+            while (XCheckTypedWindowEvent(Xdisplay, scrollBar.win,
+                                          MotionNotify, ev)) ;
+            XQueryPointer(Xdisplay, scrollBar.win,
+                          &unused_root, &unused_child,
+                          &unused_root_x, &unused_root_y,
+                          &(ev->xbutton.x), &(ev->xbutton.y),
+                          &unused_mask);
+            scr_move_to (scrollbar_position(ev->xbutton.y) - csrO,
+                         scrollbar_size());
+            scr_refresh (refresh_type);
+            refresh_limit = 0;
+            scrollbar_show (1);
+          }
+        break;
+    }
+}
 
 void
 rxvt_term::button_press (XButtonEvent *ev)
 {
-    int reportmode = 0, clickintime;
-
-    bypass_keystate = ev->state & (ModMetaMask | ShiftMask);
-    if (!bypass_keystate)
-       reportmode = !!(PrivateModes & PrivMode_mouse_report);
-/*
- * VT window processing of button press
- */
-    if (ev->window == TermWin.vt)
-      {
+  int reportmode = 0, clickintime;
+
+  bypass_keystate = ev->state & (ModMetaMask | ShiftMask);
+  if (!bypass_keystate)
+    reportmode = !!(PrivateModes & PrivMode_mouse_report);
+  /*
  * VT window processing of button press
  */
+  if (ev->window == TermWin.vt)
+    {
 #if RXVT_GRAPHICS
-       if (ev->subwindow != None)
-         rxvt_Gr_ButtonPress (ev->x, ev->y);
-       else
+      if (ev->subwindow != None)
+        rxvt_Gr_ButtonPress (ev->x, ev->y);
+      else
 #endif
-          {
-           clickintime = ev->time - MEvent.time < MULTICLICK_TIME;
-           if (reportmode)
-              {
-               /* mouse report from vt window */
-               /* save the xbutton state (for ButtonRelease) */
-               MEvent.state = ev->state;
+
+        {
+          clickintime = ev->time - MEvent.time < MULTICLICK_TIME;
+          if (reportmode)
+            {
+              /* mouse report from vt window */
+              /* save the xbutton state (for ButtonRelease) */
+              MEvent.state = ev->state;
 #ifdef MOUSE_REPORT_DOUBLECLICK
-               if (ev->button == MEvent.button && clickintime)
-                  {
-                   /* same button, within alloted time */
-                   MEvent.clicks++;
-                   if (MEvent.clicks > 1)
-                      {
-                       /* only report double clicks */
-                       MEvent.clicks = 2;
-                       mouse_report (ev);
-
-                       /* don't report the release */
-                       MEvent.clicks = 0;
-                       MEvent.button = AnyButton;
-                     }
-                 }
-                else
-                  {
-                   /* different button, or time expired */
-                   MEvent.clicks = 1;
-                   MEvent.button = ev->button;
-                   mouse_report (ev);
-                 }
+              if (ev->button == MEvent.button && clickintime)
+                {
+                  /* same button, within alloted time */
+                  MEvent.clicks++;
+                  if (MEvent.clicks > 1)
+                    {
+                      /* only report double clicks */
+                      MEvent.clicks = 2;
+                      mouse_report (ev);
+
+                      /* don't report the release */
+                      MEvent.clicks = 0;
+                      MEvent.button = AnyButton;
+                    }
+                }
+              else
+                {
+                  /* different button, or time expired */
+                  MEvent.clicks = 1;
+                  MEvent.button = ev->button;
+                  mouse_report (ev);
+                }
 #else
-               MEvent.button = ev->button;
-               mouse_report (ev);
+              MEvent.button = ev->button;
+              mouse_report (ev);
 #endif                         /* MOUSE_REPORT_DOUBLECLICK */
-             }
-            else
-              {
-               if (ev->button != MEvent.button)
-                   MEvent.clicks = 0;
-               switch (ev->button)
-                  {
-                    case Button1:
-                        /* allow shift+left click to extend selection */
-                        if (ev->state & ShiftMask && !(PrivateModes & PrivMode_mouse_report))
-                          {
-                            if (MEvent.button == Button1 && clickintime)
-                              selection_rotate (ev->x, ev->y);
-                            else
-                              selection_extend (ev->x, ev->y, 1);
-                          }
-                        else
-                          {
-                            if (MEvent.button == Button1 && clickintime)
-                              MEvent.clicks++;
-                            else
-                              MEvent.clicks = 1;
 
-                            selection_click (MEvent.clicks, ev->x, ev->y);
-                          }
-
-                        MEvent.button = Button1;
-                        break;
-
-                    case Button3:
-                        if (MEvent.button == Button3 && clickintime)
+            }
+          else
+            {
+              if (ev->button != MEvent.button)
+                MEvent.clicks = 0;
+              switch (ev->button)
+                {
+                  case Button1:
+                    /* allow shift+left click to extend selection */
+                    if (ev->state & ShiftMask && !(PrivateModes & PrivMode_mouse_report))
+                      {
+                        if (MEvent.button == Button1 && clickintime)
                           selection_rotate (ev->x, ev->y);
                         else
                           selection_extend (ev->x, ev->y, 1);
-                        MEvent.button = Button3;
-                        break;
-                 }
-             }
-           MEvent.time = ev->time;
-           return;
-         }
-      }
+                      }
+                    else
+                      {
+                        if (MEvent.button == Button1 && clickintime)
+                          MEvent.clicks++;
+                        else
+                          MEvent.clicks = 1;
 
-/*
- * Scrollbar window processing of button press
- */
-    if (isScrollbarWindow(ev->window))
-      {
-       scrollBar.setIdle ();
-       /*
-        * Rxvt-style scrollbar:
-        * move up if mouse is above slider
-        * move dn if mouse is below slider
-        *
-        * XTerm-style scrollbar:
-        * Move display proportional to pointer location
-        * pointer near top -> scroll one line
-        * pointer near bot -> scroll full page
-        */
+                        selection_click (MEvent.clicks, ev->x, ev->y);
+                      }
+
+                    MEvent.button = Button1;
+                    break;
+
+                  case Button3:
+                    if (MEvent.button == Button3 && clickintime)
+                      selection_rotate (ev->x, ev->y);
+                    else
+                      selection_extend (ev->x, ev->y, 1);
+                    MEvent.button = Button3;
+                    break;
+                }
+            }
+          MEvent.time = ev->time;
+          return;
+        }
+    }
+
+  /*
+   * Scrollbar window processing of button press
+   */
+  if (isScrollbarWindow(ev->window))
+    {
+      scrollBar.setIdle ();
+      /*
+       * Rxvt-style scrollbar:
+       * move up if mouse is above slider
+       * move dn if mouse is below slider
+       *
+       * XTerm-style scrollbar:
+       * Move display proportional to pointer location
+       * pointer near top -> scroll one line
+       * pointer near bot -> scroll full page
+       */
 #ifndef NO_SCROLLBAR_REPORT
-       if (reportmode) {
-           /*
-            * Mouse report disabled scrollbar:
-            * arrow buttons - send up/down
-            * click on scrollbar - send pageup/down
-            */
-           if ((scrollBar.style == R_SB_NEXT
-                && scrollbarnext_upButton(ev->y))
-               || (scrollBar.style == R_SB_RXVT
-                   && scrollbarrxvt_upButton(ev->y)))
-               tt_printf("\033[A");
-           else if ((scrollBar.style == R_SB_NEXT
-                     && scrollbarnext_dnButton(ev->y))
-                    || (scrollBar.style == R_SB_RXVT
-                        && scrollbarrxvt_dnButton(ev->y)))
-               tt_printf("\033[B");
-           else
-               switch (ev->button) {
-               case Button2:
-                   tt_printf("\014");
-                   break;
-               case Button1:
-                   tt_printf("\033[6~");
-                   break;
-               case Button3:
-                   tt_printf("\033[5~");
-                   break;
-               }
-         }
-        else
+      if (reportmode)
+        {
+          /*
+           * Mouse report disabled scrollbar:
+           * arrow buttons - send up/down
+           * click on scrollbar - send pageup/down
+           */
+          if ((scrollBar.style == R_SB_NEXT
+               && scrollbarnext_upButton(ev->y))
+              || (scrollBar.style == R_SB_RXVT
+                  && scrollbarrxvt_upButton(ev->y)))
+            tt_printf("\033[A");
+          else if ((scrollBar.style == R_SB_NEXT
+                    && scrollbarnext_dnButton(ev->y))
+                   || (scrollBar.style == R_SB_RXVT
+                       && scrollbarrxvt_dnButton(ev->y)))
+            tt_printf("\033[B");
+          else
+            switch (ev->button)
+              {
+                case Button2:
+                  tt_printf("\014");
+                  break;
+                case Button1:
+                  tt_printf("\033[6~");
+                  break;
+                case Button3:
+                  tt_printf("\033[5~");
+                  break;
+              }
+        }
+      else
 #endif                         /* NO_SCROLLBAR_REPORT */
-         {
-           char            upordown = 0;
-
-           if (scrollBar.style == R_SB_NEXT) {
-               if (scrollbarnext_upButton(ev->y))
-                   upordown = -1;      /* up */
-               else if (scrollbarnext_dnButton(ev->y))
-                   upordown = 1;       /* down */
-           } else if (scrollBar.style == R_SB_RXVT) {
-               if (scrollbarrxvt_upButton(ev->y))
-                   upordown = -1;      /* up */
-               else if (scrollbarrxvt_dnButton(ev->y))
-                   upordown = 1;       /* down */
-           }
-           if (upordown) { 
+
+        {
+          char            upordown = 0;
+
+          if (scrollBar.style == R_SB_NEXT)
+            {
+              if (scrollbarnext_upButton(ev->y))
+                upordown = -1; /* up */
+              else if (scrollbarnext_dnButton(ev->y))
+                upordown = 1;  /* down */
+            }
+          else if (scrollBar.style == R_SB_RXVT)
+            {
+              if (scrollbarrxvt_upButton(ev->y))
+                upordown = -1; /* up */
+              else if (scrollbarrxvt_dnButton(ev->y))
+                upordown = 1;  /* down */
+            }
+          if (upordown)
+            {
 #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
-               scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY;
-#endif
-               if (scr_page (upordown < 0 ? UP : DN, 1)) {
-                   if (upordown < 0)
-                       scrollBar.setUp ();
-                   else
-                       scrollBar.setDn ();
-               }
-           } else
-               switch (ev->button) {
-               case Button2:
-                   switch (scrollbar_align) {
-                   case R_SB_ALIGN_TOP:
-                       csrO = 0;
-                       break;
-                   case R_SB_ALIGN_CENTRE:
-                       csrO = (scrollBar.bot - scrollBar.top) / 2;
-                       break;
-                   case R_SB_ALIGN_BOTTOM:
-                       csrO = scrollBar.bot - scrollBar.top;
-                       break;
-                   }
-                   if (scrollBar.style == R_SB_XTERM
-                       || scrollbar_above_slider(ev->y)
-                       || scrollbar_below_slider(ev->y))
-                       scr_move_to (                                    scrollbar_position(ev->y) - csrO,
-                                        scrollbar_size());
-                   scrollBar.setMotion ();
-                   break;
-
-               case Button1:
-                   if (scrollbar_align == R_SB_ALIGN_CENTRE)
-                       csrO = ev->y - scrollBar.top;
-                   /* FALLTHROUGH */
-
-               case Button3:
-                   if (scrollBar.style != R_SB_XTERM) {
-                       if (scrollbar_above_slider(ev->y))
+              scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY;
+#endif
+              if (scr_page (upordown < 0 ? UP : DN, 1))
+                {
+                  if (upordown < 0)
+                    scrollBar.setUp ();
+                  else
+                    scrollBar.setDn ();
+                }
+            }
+          else
+            switch (ev->button)
+              {
+                case Button2:
+                  switch (scrollbar_align)
+                    {
+                      case R_SB_ALIGN_TOP:
+                        csrO = 0;
+                        break;
+                      case R_SB_ALIGN_CENTRE:
+                        csrO = (scrollBar.bot - scrollBar.top) / 2;
+                        break;
+                      case R_SB_ALIGN_BOTTOM:
+                        csrO = scrollBar.bot - scrollBar.top;
+                        break;
+                    }
+                  if (scrollBar.style == R_SB_XTERM
+                      || scrollbar_above_slider(ev->y)
+                      || scrollbar_below_slider(ev->y))
+                    scr_move_to (                                       scrollbar_position(ev->y) - csrO,
+                                       scrollbar_size());
+                  scrollBar.setMotion ();
+                  break;
+
+                case Button1:
+                  if (scrollbar_align == R_SB_ALIGN_CENTRE)
+                    csrO = ev->y - scrollBar.top;
+                  /* FALLTHROUGH */
+
+                case Button3:
+                  if (scrollBar.style != R_SB_XTERM)
+                    {
+                      if (scrollbar_above_slider(ev->y))
 # ifdef RXVT_SCROLL_FULL
-                           scr_page (UP, TermWin.nrow - 1);
+                        scr_page (UP, TermWin.nrow - 1);
 # else
-                           scr_page (UP, TermWin.nrow / 4);
+                        scr_page (UP, TermWin.nrow / 4);
 # endif
-                       else if (scrollbar_below_slider(ev->y))
+                      else if (scrollbar_below_slider(ev->y))
 # ifdef RXVT_SCROLL_FULL
-                           scr_page (DN, TermWin.nrow - 1);
+                        scr_page (DN, TermWin.nrow - 1);
 # else
-                           scr_page (DN, TermWin.nrow / 4);
+                        scr_page (DN, TermWin.nrow / 4);
 # endif
-                       else
-                           scrollBar.setMotion ();
-                   } else {
-                       scr_page ((ev->button == Button1 ? DN : UP),
-                                     (TermWin.nrow
-                                      * scrollbar_position(ev->y)
-                                      / scrollbar_size()));
-                   }
-                   break;
-               }
-         }
-       return;
+                      else
+                        scrollBar.setMotion ();
+                    }
+                  else
+                    {
+                      scr_page ((ev->button == Button1 ? DN : UP),
+                                (TermWin.nrow
+                                 * scrollbar_position(ev->y)
+                                 / scrollbar_size()));
+                    }
+                  break;
+              }
+        }
+      return;
     }
 #if MENUBAR
-    /*
-     * Menubar window processing of button press
-     */
-    if (isMenuBarWindow(ev->window))
-       menubar_control (ev);
+  /*
+   * Menubar window processing of button press
+   */
+  if (isMenuBarWindow(ev->window))
+    menubar_control (ev);
 #endif
 }
 
 void
 rxvt_term::button_release (XButtonEvent *ev)
 {
-    int             reportmode = 0;
+  int             reportmode = 0;
 
-    csrO = 0;          /* reset csr Offset */
-    if (!bypass_keystate)
-       reportmode = !!(PrivateModes & PrivMode_mouse_report);
+  csrO = 0;            /* reset csr Offset */
+  if (!bypass_keystate)
+    reportmode = !!(PrivateModes & PrivMode_mouse_report);
 
-    if (scrollbar_isUpDn()) {
-       scrollBar.setIdle ();
-       scrollbar_show (0);
+  if (scrollbar_isUpDn())
+    {
+      scrollBar.setIdle ();
+      scrollbar_show (0);
 #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
-       refresh_type &= ~SMOOTH_REFRESH;
+      refresh_type &= ~SMOOTH_REFRESH;
 #endif
+
     }
 #ifdef SELECTION_SCROLLING
-    pending_scroll_selection=0;
+  pending_scroll_selection=0;
 #endif
-    if (ev->window == TermWin.vt) 
-      {
+  if (ev->window == TermWin.vt)
+    {
 #ifdef RXVT_GRAPHICS
-       if (ev->subwindow != None)
-         rxvt_Gr_ButtonRelease(ev->x, ev->y);
-       else 
+      if (ev->subwindow != None)
+        rxvt_Gr_ButtonRelease(ev->x, ev->y);
+      else
 #endif
-          {
-           if (reportmode) 
-              {
-               /* mouse report from vt window */
-               /* don't report release of wheel "buttons" */
-               if (ev->button >= 4)
-                   return;
+
+        {
+          if (reportmode)
+            {
+              /* mouse report from vt window */
+              /* don't report release of wheel "buttons" */
+              if (ev->button >= 4)
+                return;
 #ifdef MOUSE_REPORT_DOUBLECLICK
-               /* only report the release of 'slow' single clicks */
-               if (MEvent.button != AnyButton
-                   && (ev->button != MEvent.button
-                       || (ev->time - MEvent.time
-                           > MULTICLICK_TIME / 2))) 
-                  {
-                   MEvent.clicks = 0;
-                   MEvent.button = AnyButton;
-                   mouse_report (ev);
-                 }
+              /* only report the release of 'slow' single clicks */
+              if (MEvent.button != AnyButton
+                  && (ev->button != MEvent.button
+                      || (ev->time - MEvent.time
+                          > MULTICLICK_TIME / 2)))
+                {
+                  MEvent.clicks = 0;
+                  MEvent.button = AnyButton;
+                  mouse_report (ev);
+                }
 #else                          /* MOUSE_REPORT_DOUBLECLICK */
-               MEvent.button = AnyButton;
-               mouse_report (ev);
+              MEvent.button = AnyButton;
+              mouse_report (ev);
 #endif                         /* MOUSE_REPORT_DOUBLECLICK */
-               return;
-           }
-           /*
-            * dumb hack to compensate for the failure of click-and-drag
-            * when overriding mouse reporting
-            */
-           if (PrivateModes & PrivMode_mouse_report
-               && bypass_keystate
-               && ev->button == Button1 && MEvent.clicks <= 1)
-               selection_extend (ev->x, ev->y, 0);
-
-           switch (ev->button) {
-           case Button1:
-           case Button3:
-               selection_make (ev->time);
-               break;
-           case Button2:
-               selection_request (ev->time, ev->x, ev->y);
-               break;
+              return;
+            }
+          /*
+           * dumb hack to compensate for the failure of click-and-drag
+           * when overriding mouse reporting
+           */
+          if (PrivateModes & PrivMode_mouse_report
+              && bypass_keystate
+              && ev->button == Button1 && MEvent.clicks <= 1)
+            selection_extend (ev->x, ev->y, 0);
+
+          switch (ev->button)
+            {
+              case Button1:
+              case Button3:
+                selection_make (ev->time);
+                break;
+              case Button2:
+                selection_request (ev->time, ev->x, ev->y);
+                break;
 #ifdef MOUSE_WHEEL
-           case Button4:
-           case Button5:
-                 {
-                   int i;
-                    page_dirn v;
-
-                   v = (ev->button == Button4) ? UP : DN;
-                   if (ev->state & ShiftMask)
-                       i = 1;
-                   else if ((Options & Opt_mouseWheelScrollPage))
-                       i = TermWin.nrow - 1;
-                   else
-                       i = 5;
+              case Button4:
+              case Button5:
+                {
+                  int i;
+                  page_dirn v;
+
+                  v = (ev->button == Button4) ? UP : DN;
+                  if (ev->state & ShiftMask)
+                    i = 1;
+                  else if ((Options & Opt_mouseWheelScrollPage))
+                    i = TermWin.nrow - 1;
+                  else
+                    i = 5;
 # ifdef MOUSE_SLIP_WHEELING
-                    if (ev->state & ControlMask) 
-                      {
-                       mouse_slip_wheel_speed += (v ? -1 : 1);
-                       mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY;
-                     }
+                  if (ev->state & ControlMask)
+                    {
+                      mouse_slip_wheel_speed += (v ? -1 : 1);
+                      mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY;
+                    }
 # endif
 # ifdef JUMP_MOUSE_WHEEL
-                   scr_page (v, i);
-                   scr_refresh (SMOOTH_REFRESH);
-                   scrollbar_show (1);
+                  scr_page (v, i);
+                  scr_refresh (SMOOTH_REFRESH);
+                  scrollbar_show (1);
 # else
-                   while (i--)
-                      {
-                       scr_page (v, 1);
-                       scr_refresh (SMOOTH_REFRESH);
-                       scrollbar_show (1);
-                     }
+                  while (i--)
+                    {
+                      scr_page (v, 1);
+                      scr_refresh (SMOOTH_REFRESH);
+                      scrollbar_show (1);
+                    }
 # endif
-                 }
-               break;
+
+                }
+                break;
 #endif
-             }
-         }
-      }
+
+            }
+        }
+    }
 #ifdef MENUBAR
-    else if (isMenuBarWindow(ev->window))
-       menubar_control (ev);
+  else if (isMenuBarWindow(ev->window))
+    menubar_control (ev);
 #endif
 }
 
@@ -1878,180 +1948,200 @@ rxvt_term::button_release (XButtonEvent *ev)
 int
 rxvt_term::check_our_parents ()
 {
-    int             i, pchanged, aformat, have_pixmap, rootdepth;
-    unsigned long   nitems, bytes_after;
-    Atom            atype;
-    unsigned char   *prop = NULL;
-    Window          root, oldp, *list;
-    Pixmap          rootpixmap = None;
-    XWindowAttributes wattr, wrootattr;
-
-    pchanged = 0;
-
-    if (!(Options & Opt_transparent))
-       return pchanged;        /* Don't try any more */
-
-    XGetWindowAttributes(Xdisplay, Xroot, &wrootattr);
-    rootdepth = wrootattr.depth;
-
-    XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
-    if (rootdepth != wattr.depth) {
-       if (am_transparent) {
-           pchanged = 1;
-           XSetWindowBackground(Xdisplay, TermWin.vt,
-                                PixColors[Color_bg]);
-           am_transparent = am_pixmap_trans = 0;
-       }
-       return pchanged;        /* Don't try any more */
-    }
+  int             i, pchanged, aformat, have_pixmap, rootdepth;
+  unsigned long   nitems, bytes_after;
+  Atom            atype;
+  unsigned char   *prop = NULL;
+  Window          root, oldp, *list;
+  Pixmap          rootpixmap = None;
+  XWindowAttributes wattr, wrootattr;
 
-/* Get all X ops out of the queue so that our information is up-to-date. */
-    XSync(Xdisplay, False);
+  pchanged = 0;
 
-/*
- * Make the frame window set by the window manager have
- * the root background. Some window managers put multiple nested frame
- * windows for each client, so we have to take care about that.
- */
-    i = (xa[XA_XROOTPMAPID] != 0
-        && (XGetWindowProperty(Xdisplay, Xroot, xa[XA_XROOTPMAPID],
-                               0L, 1L, False, XA_PIXMAP, &atype, &aformat,
-                               &nitems, &bytes_after, &prop) == Success));
-    if (!i || prop == NULL)
-       have_pixmap = 0;
-    else {
-       have_pixmap = 1;
-       rootpixmap = *((Pixmap *)prop);
-       XFree(prop);
+  if (!(Options & Opt_transparent))
+    return pchanged;   /* Don't try any more */
+
+  XGetWindowAttributes(Xdisplay, Xroot, &wrootattr);
+  rootdepth = wrootattr.depth;
+
+  XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
+  if (rootdepth != wattr.depth)
+    {
+      if (am_transparent)
+        {
+          pchanged = 1;
+          XSetWindowBackground(Xdisplay, TermWin.vt,
+                               PixColors[Color_bg]);
+          am_transparent = am_pixmap_trans = 0;
+        }
+      return pchanged; /* Don't try any more */
     }
-    if (have_pixmap) {
-/*
- * Copy Xroot pixmap transparency
- */
-       int             sx, sy, nx, ny;
-       unsigned int    nw, nh;
-       Window          cr;
-       XImage         *image;
-       GC              gc;
-       XGCValues       gcvalue;
-
-       XTranslateCoordinates(Xdisplay, TermWin.parent[0], Xroot,
-                             0, 0, &sx, &sy, &cr);
-       nw = (unsigned int)szHint.width;
-       nh = (unsigned int)szHint.height;
-       nx = ny = 0;
-       if (sx < 0) {
-           nw += sx;
-           nx = -sx;
-           sx = 0;
-       }
-       if (sy < 0) {
-           nh += sy;
-           ny = -sy;
-           sy = 0;
-       }
-       MIN_IT(nw, (unsigned int)(wrootattr.width - sx));
-       MIN_IT(nh, (unsigned int)(wrootattr.height - sy));
-       allowedxerror = -1;
-       image = XGetImage(Xdisplay, rootpixmap, sx, sy, nw, nh, AllPlanes,
-                         ZPixmap);
-       /* XXX: handle BadMatch - usually because we're outside the pixmap */
-       /* XXX: may need a delay here? */
-       allowedxerror = 0;
-       if (image == NULL) {
-           if (am_transparent && am_pixmap_trans) {
-               pchanged = 1;
-               if (TermWin.pixmap != None) {
-                   XFreePixmap(Xdisplay, TermWin.pixmap);
-                   TermWin.pixmap = None;
-               }
-           }
-           am_pixmap_trans = 0;
-       } else {
-           if (TermWin.pixmap != None)
-               XFreePixmap(Xdisplay, TermWin.pixmap);
-           TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt,
-                                             (unsigned int)szHint.width,
-                                             (unsigned int)szHint.height,
-                                             (unsigned int)image->depth);
-           gc = XCreateGC(Xdisplay, TermWin.vt, 0UL, &gcvalue);
-           XPutImage(Xdisplay, TermWin.pixmap, gc, image, 0, 0,
-                     nx, ny, (unsigned int)image->width,
-                     (unsigned int)image->height);
-           XFreeGC(Xdisplay, gc);
-           XDestroyImage(image);
-           XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt,
-                                      TermWin.pixmap);
-           if (!am_transparent || !am_pixmap_trans)
-               pchanged = 1;
-           am_transparent = am_pixmap_trans = 1;
-       }
+
+  /* Get all X ops out of the queue so that our information is up-to-date. */
+  XSync(Xdisplay, False);
+
+  /*
+   * Make the frame window set by the window manager have
+   * the root background. Some window managers put multiple nested frame
+   * windows for each client, so we have to take care about that.
+   */
+  i = (xa[XA_XROOTPMAPID] != 0
+       && (XGetWindowProperty(Xdisplay, Xroot, xa[XA_XROOTPMAPID],
+                              0L, 1L, False, XA_PIXMAP, &atype, &aformat,
+                              &nitems, &bytes_after, &prop) == Success));
+  if (!i || prop == NULL)
+    have_pixmap = 0;
+  else
+    {
+      have_pixmap = 1;
+      rootpixmap = *((Pixmap *)prop);
+      XFree(prop);
     }
-    if (!am_pixmap_trans) {
-       unsigned int    n;
-/*
- * InheritPixmap transparency
- */
-       D_X((stderr, "InheritPixmap Seeking to  %08lx", Xroot));
-       for (i = 1; i < (int)(sizeof(TermWin.parent) / sizeof(Window));
-            i++) {
-           oldp = TermWin.parent[i];
-           XQueryTree(Xdisplay, TermWin.parent[i - 1], &root,
-                      &TermWin.parent[i], &list, &n);
-           XFree(list);
-           D_X((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i]));
-           if (TermWin.parent[i] == Xroot) {
-               if (oldp != None)
-                   pchanged = 1;
-               break;
-           }
-           if (oldp != TermWin.parent[i])
-               pchanged = 1;
-       }
-       n = 0;
-       if (pchanged) {
-           for (; n < (unsigned int)i; n++) {
-               XGetWindowAttributes(Xdisplay, TermWin.parent[n], &wattr);
-               D_X((stderr, "InheritPixmap Checking Parent[%d]: %s", n, (wattr.depth == rootdepth && wattr.class != InputOnly) ? "OK" : "FAIL"));
-               if (wattr.depth != rootdepth || wattr.c_class == InputOnly) {
-                   n = (int)(sizeof(TermWin.parent) / sizeof(Window)) + 1;
-                   break;
-               }
-           }
-       }
-       if (n > (int)(sizeof(TermWin.parent)
-                     / sizeof(TermWin.parent[0]))) {
-           D_X((stderr, "InheritPixmap Turning off"));
-           XSetWindowBackground(Xdisplay, TermWin.parent[0],
-                                PixColors[Color_fg]);
-           XSetWindowBackground(Xdisplay, TermWin.vt,
-                                PixColors[Color_bg]);
-           am_transparent = 0;
-           /* XXX: also turn off Opt_transparent? */
-       } else {
-           /* wait (an arbitrary period) for the WM to do its thing
-            * needed for fvwm2.2.2 (and before?) */
+  if (have_pixmap)
+    {
+      /*
+       * Copy Xroot pixmap transparency
+       */
+      int             sx, sy, nx, ny;
+      unsigned int    nw, nh;
+      Window          cr;
+      XImage         *image;
+      GC              gc;
+      XGCValues       gcvalue;
+
+      XTranslateCoordinates(Xdisplay, TermWin.parent[0], Xroot,
+                            0, 0, &sx, &sy, &cr);
+      nw = (unsigned int)szHint.width;
+      nh = (unsigned int)szHint.height;
+      nx = ny = 0;
+      if (sx < 0)
+        {
+          nw += sx;
+          nx = -sx;
+          sx = 0;
+        }
+      if (sy < 0)
+        {
+          nh += sy;
+          ny = -sy;
+          sy = 0;
+        }
+      MIN_IT(nw, (unsigned int)(wrootattr.width - sx));
+      MIN_IT(nh, (unsigned int)(wrootattr.height - sy));
+      allowedxerror = -1;
+      image = XGetImage(Xdisplay, rootpixmap, sx, sy, nw, nh, AllPlanes,
+                        ZPixmap);
+      /* XXX: handle BadMatch - usually because we're outside the pixmap */
+      /* XXX: may need a delay here? */
+      allowedxerror = 0;
+      if (image == NULL)
+        {
+          if (am_transparent && am_pixmap_trans)
+            {
+              pchanged = 1;
+              if (TermWin.pixmap != None)
+                {
+                  XFreePixmap(Xdisplay, TermWin.pixmap);
+                  TermWin.pixmap = None;
+                }
+            }
+          am_pixmap_trans = 0;
+        }
+      else
+        {
+          if (TermWin.pixmap != None)
+            XFreePixmap(Xdisplay, TermWin.pixmap);
+          TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt,
+                                         (unsigned int)szHint.width,
+                                         (unsigned int)szHint.height,
+                                         (unsigned int)image->depth);
+          gc = XCreateGC(Xdisplay, TermWin.vt, 0UL, &gcvalue);
+          XPutImage(Xdisplay, TermWin.pixmap, gc, image, 0, 0,
+                    nx, ny, (unsigned int)image->width,
+                    (unsigned int)image->height);
+          XFreeGC(Xdisplay, gc);
+          XDestroyImage(image);
+          XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt,
+                                     TermWin.pixmap);
+          if (!am_transparent || !am_pixmap_trans)
+            pchanged = 1;
+          am_transparent = am_pixmap_trans = 1;
+        }
+    }
+  if (!am_pixmap_trans)
+    {
+      unsigned int    n;
+      /*
+       * InheritPixmap transparency
+       */
+      D_X((stderr, "InheritPixmap Seeking to  %08lx", Xroot));
+      for (i = 1; i < (int)(sizeof(TermWin.parent) / sizeof(Window));
+           i++)
+        {
+          oldp = TermWin.parent[i];
+          XQueryTree(Xdisplay, TermWin.parent[i - 1], &root,
+                     &TermWin.parent[i], &list, &n);
+          XFree(list);
+          D_X((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i]));
+          if (TermWin.parent[i] == Xroot)
+            {
+              if (oldp != None)
+                pchanged = 1;
+              break;
+            }
+          if (oldp != TermWin.parent[i])
+            pchanged = 1;
+        }
+      n = 0;
+      if (pchanged)
+        {
+          for (; n < (unsigned int)i; n++)
+            {
+              XGetWindowAttributes(Xdisplay, TermWin.parent[n], &wattr);
+              D_X((stderr, "InheritPixmap Checking Parent[%d]: %s", n, (wattr.depth == rootdepth && wattr.class != InputOnly) ? "OK" : "FAIL"));
+              if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
+                {
+                  n = (int)(sizeof(TermWin.parent) / sizeof(Window)) + 1;
+                  break;
+                }
+            }
+        }
+      if (n > (int)(sizeof(TermWin.parent)
+                    / sizeof(TermWin.parent[0])))
+        {
+          D_X((stderr, "InheritPixmap Turning off"));
+          XSetWindowBackground(Xdisplay, TermWin.parent[0],
+                               PixColors[Color_fg]);
+          XSetWindowBackground(Xdisplay, TermWin.vt,
+                               PixColors[Color_bg]);
+          am_transparent = 0;
+          /* XXX: also turn off Opt_transparent? */
+        }
+      else
+        {
+          /* wait (an arbitrary period) for the WM to do its thing
+           * needed for fvwm2.2.2 (and before?) */
 # ifdef HAVE_NANOSLEEP
-           struct timespec rqt;
+          struct timespec rqt;
 
-           rqt.tv_sec = 1;
-           rqt.tv_nsec = 0;
-           nanosleep(&rqt, NULL);
+          rqt.tv_sec = 1;
+          rqt.tv_nsec = 0;
+          nanosleep(&rqt, NULL);
 # else
-           sleep(1);   
+          sleep(1);
 # endif
-           D_X((stderr, "InheritPixmap Turning on (%d parents)", i - 1));
-           for (n = 0; n < (unsigned int)i; n++)
-               XSetWindowBackgroundPixmap(Xdisplay, TermWin.parent[n],
-                                          ParentRelative);
-           XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt,
-                                      ParentRelative);
-           am_transparent = 1;
-       }
-       for (; i < (int)(sizeof(TermWin.parent) / sizeof(Window)); i++)
-           TermWin.parent[i] = None;
+          D_X((stderr, "InheritPixmap Turning on (%d parents)", i - 1));
+          for (n = 0; n < (unsigned int)i; n++)
+            XSetWindowBackgroundPixmap(Xdisplay, TermWin.parent[n],
+                                       ParentRelative);
+          XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt,
+                                     ParentRelative);
+          am_transparent = 1;
+        }
+      for (; i < (int)(sizeof(TermWin.parent) / sizeof(Window)); i++)
+        TermWin.parent[i] = None;
     }
-    return pchanged;
+  return pchanged;
 }
 #endif
 
@@ -2063,20 +2153,20 @@ rxvt_term::check_our_parents ()
 FILE *
 rxvt_term::popen_printer ()
 {
-    FILE           *stream = popen(rs[Rs_print_pipe], "w");
+  FILE           *stream = popen(rs[Rs_print_pipe], "w");
 
-    if (stream == NULL)
-       rxvt_print_error("can't open printer pipe");
-    return stream;
+  if (stream == NULL)
+    rxvt_print_error("can't open printer pipe");
+  return stream;
 }
 
 int
 rxvt_term::pclose_printer (FILE *stream)
 {
   fflush (stream);
-/* pclose() reported not to work on SunOS 4.1.3 */
+  /* pclose() reported not to work on SunOS 4.1.3 */
 # if defined (__sun__)         /* TODO: RESOLVE THIS */
-/* pclose works provided SIGCHLD handler uses waitpid */
+  /* pclose works provided SIGCHLD handler uses waitpid */
   return pclose (stream);      /* return fclose (stream); */
 # else
   return pclose (stream);
@@ -2089,57 +2179,65 @@ rxvt_term::pclose_printer (FILE *stream)
 void
 rxvt_term::process_print_pipe ()
 {
-    int             done;
-    FILE           *fd;
+  int             done;
+  FILE           *fd;
 
-    if ((fd = popen_printer ()) == NULL)
-       return;
+  if ((fd = popen_printer ()) == NULL)
+    return;
 
-/*
- * Send all input to the printer until either ESC[4i or ESC[?4i
- * is received.
- */
-    for (done = 0; !done;) {
-       unsigned char   buf[8];
-       unsigned char   ch;
-       unsigned int    i, len;
-
-       if ((ch = cmd_getc ()) != C0_ESC) {
-           if (putc(ch, fd) == EOF)
-               break;          /* done = 1 */
-       } else {
-           len = 0;
-           buf[len++] = ch;
-
-           if ((buf[len++] = cmd_getc ()) == '[') {
-               if ((ch = cmd_getc ()) == '?') {
-                   buf[len++] = '?';
-                   ch = cmd_getc ();
-               }
-               if ((buf[len++] = ch) == '4') {
-                   if ((buf[len++] = cmd_getc ()) == 'i')
-                       break;  /* done = 1 */
-               }
-           }
-           for (i = 0; i < len; i++)
-               if (putc(buf[i], fd) == EOF) {
-                   done = 1;
-                   break;
-               }
-       }
+  /*
+   * Send all input to the printer until either ESC[4i or ESC[?4i
+   * is received.
+   */
+  for (done = 0; !done;)
+    {
+      unsigned char   buf[8];
+      unsigned char   ch;
+      unsigned int    i, len;
+
+      if ((ch = cmd_getc ()) != C0_ESC)
+        {
+          if (putc(ch, fd) == EOF)
+            break;             /* done = 1 */
+        }
+      else
+        {
+          len = 0;
+          buf[len++] = ch;
+
+          if ((buf[len++] = cmd_getc ()) == '[')
+            {
+              if ((ch = cmd_getc ()) == '?')
+                {
+                  buf[len++] = '?';
+                  ch = cmd_getc ();
+                }
+              if ((buf[len++] = ch) == '4')
+                {
+                  if ((buf[len++] = cmd_getc ()) == 'i')
+                    break;     /* done = 1 */
+                }
+            }
+          for (i = 0; i < len; i++)
+            if (putc(buf[i], fd) == EOF)
+              {
+                done = 1;
+                break;
+              }
+        }
     }
-    pclose_printer (fd);
+  pclose_printer (fd);
 }
 #endif                         /* PRINTPIPE */
 /*}}} */
 
 /* *INDENT-OFF* */
 enum {
-    C1_40 = 0x40,
-           C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA,
-    C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3,
-    C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA,
-    C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC
+  C1_40 = 0x40,
+  C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA,
+  C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3,
+  C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA,
+  C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC
 };
 /* *INDENT-ON* */
 
@@ -2147,39 +2245,40 @@ enum {
 void
 rxvt_term::process_nonprinting (unsigned char ch)
 {
-    switch (ch) {
-    case C0_ENQ:       /* terminal Status */
-       if (rs[Rs_answerbackstring])
-           tt_write(
-               (const unsigned char *)rs[Rs_answerbackstring],
-               (unsigned int)STRLEN(rs[Rs_answerbackstring]));
-       else
-           tt_write((unsigned char *)VT100_ANS,
-                         (unsigned int)STRLEN(VT100_ANS));
-       break;
-    case C0_BEL:       /* bell */
-       scr_bell ();
-       break;
-    case C0_BS:                /* backspace */
-       scr_backspace ();
-       break;
-    case C0_HT:                /* tab */
-       scr_tab (1);
-       break;
-    case C0_CR:                /* carriage return */
-       scr_gotorc (0, 0, R_RELATIVE);
-       break;
-    case C0_VT:                /* vertical tab, form feed */
-    case C0_FF:
-    case C0_LF:                /* line feed */
-       scr_index (UP);
-       break;
-    case C0_SO:                /* shift out - acs */
-       scr_charset_choose (1);
-       break;
-    case C0_SI:                /* shift in - acs */
-       scr_charset_choose (0);
-       break;
+  switch (ch)
+    {
+      case C0_ENQ:     /* terminal Status */
+        if (rs[Rs_answerbackstring])
+          tt_write(
+            (const unsigned char *)rs[Rs_answerbackstring],
+            (unsigned int)STRLEN(rs[Rs_answerbackstring]));
+        else
+          tt_write((unsigned char *)VT100_ANS,
+                   (unsigned int)STRLEN(VT100_ANS));
+        break;
+      case C0_BEL:     /* bell */
+        scr_bell ();
+        break;
+      case C0_BS:              /* backspace */
+        scr_backspace ();
+        break;
+      case C0_HT:              /* tab */
+        scr_tab (1);
+        break;
+      case C0_CR:              /* carriage return */
+        scr_gotorc (0, 0, R_RELATIVE);
+        break;
+      case C0_VT:              /* vertical tab, form feed */
+      case C0_FF:
+      case C0_LF:              /* line feed */
+        scr_index (UP);
+        break;
+      case C0_SO:              /* shift out - acs */
+        scr_charset_choose (1);
+        break;
+      case C0_SI:              /* shift in - acs */
+        scr_charset_choose (0);
+        break;
     }
 }
 /*}}} */
@@ -2189,56 +2288,57 @@ rxvt_term::process_nonprinting (unsigned char ch)
 void
 rxvt_term::process_escape_vt52 (unsigned char ch)
 {
-    int row, col;
-    
-    switch (ch) {
-    case 'A':          /* cursor up */
-       scr_gotorc (-1, 0, R_RELATIVE | C_RELATIVE);    
-       break;
-    case 'B':          /* cursor down */
-       scr_gotorc (1, 0, R_RELATIVE | C_RELATIVE);     
-       break;
-    case 'C':          /* cursor right */
-       scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);     
-       break;
-    case 'D':          /* cursor left */
-       scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);    
-       break;
-    case 'H':          /* cursor home */
-       scr_gotorc (0, 0, 0);   
-       break;
-    case 'I':          /* cursor up and scroll down if needed */
-       scr_index (DN);
-       break;
-    case 'J':          /* erase to end of screen */
-       scr_erase_screen (0);
-       break;
-    case 'K':          /* erase to end of line */
-       scr_erase_line (0);
-       break;
-    case 'Y':          /* move to specified row and col */
-         /* full command is 'ESC Y row col' where row and col
-          * are encoded by adding 32 and sending the ascii
-          * character.  eg. SPACE = 0, '+' = 13, '0' = 18,
-          * etc. */
-       row = cmd_getc () - ' ';
-       col = cmd_getc () - ' ';
-       scr_gotorc (row, col, 0);
-       break;
-    case 'Z':          /* identify the terminal type */
-       tt_printf("\033/Z");    /* I am a VT100 emulating a VT52 */
-        break;
-    case '<':          /* turn off VT52 mode */
+  int row, col;
+
+  switch (ch)
+    {
+      case 'A':                /* cursor up */
+        scr_gotorc (-1, 0, R_RELATIVE | C_RELATIVE);
+        break;
+      case 'B':                /* cursor down */
+        scr_gotorc (1, 0, R_RELATIVE | C_RELATIVE);
+        break;
+      case 'C':                /* cursor right */
+        scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
+        break;
+      case 'D':                /* cursor left */
+        scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);
+        break;
+      case 'H':                /* cursor home */
+        scr_gotorc (0, 0, 0);
+        break;
+      case 'I':                /* cursor up and scroll down if needed */
+        scr_index (DN);
+        break;
+      case 'J':                /* erase to end of screen */
+        scr_erase_screen (0);
+        break;
+      case 'K':                /* erase to end of line */
+        scr_erase_line (0);
+        break;
+      case 'Y':                /* move to specified row and col */
+        /* full command is 'ESC Y row col' where row and col
+         * are encoded by adding 32 and sending the ascii
+         * character.  eg. SPACE = 0, '+' = 13, '0' = 18,
+         * etc. */
+        row = cmd_getc () - ' ';
+        col = cmd_getc () - ' ';
+        scr_gotorc (row, col, 0);
+        break;
+      case 'Z':                /* identify the terminal type */
+        tt_printf("\033/Z");   /* I am a VT100 emulating a VT52 */
+        break;
+      case '<':                /* turn off VT52 mode */
         PrivMode(0, PrivMode_vt52);
-       break;
-    case 'F':          /* use special graphics character set */
-    case 'G':           /* use regular character set */
-         /* unimplemented */
-       break;
-    case '=':          /* use alternate keypad mode */
-    case '>':           /* use regular keypad mode */
-         /* unimplemented */
-       break;
+        break;
+      case 'F':        /* use special graphics character set */
+      case 'G':           /* use regular character set */
+        /* unimplemented */
+        break;
+      case '=':        /* use alternate keypad mode */
+      case '>':           /* use regular keypad mode */
+        /* unimplemented */
+        break;
     }
 }
 /*}}} */
@@ -2248,129 +2348,131 @@ rxvt_term::process_escape_vt52 (unsigned char ch)
 void
 rxvt_term::process_escape_seq ()
 {
-    unsigned char   ch = cmd_getc ();
+  unsigned char   ch = cmd_getc ();
 
-    if (PrivateModes & PrivMode_vt52) {
-       process_escape_vt52 (ch);
-       return;
+  if (PrivateModes & PrivMode_vt52)
+    {
+      process_escape_vt52 (ch);
+      return;
     }
-    
-    switch (ch) {
-    /* case 1:        do_tek_mode (); break; */
-    case '#':
-       if (cmd_getc () == '8')
-           scr_E ();
-       break;
-    case '(':
-       scr_charset_set (0, (unsigned int)cmd_getc ());
-       break;
-    case ')':
-       scr_charset_set (1, (unsigned int)cmd_getc ());
-       break;
-    case '*':
-       scr_charset_set (2, (unsigned int)cmd_getc ());
-       break;
-    case '+':
-       scr_charset_set (3, (unsigned int)cmd_getc ());
-       break;
+
+  switch (ch)
+    {
+        /* case 1:        do_tek_mode (); break; */
+      case '#':
+        if (cmd_getc () == '8')
+          scr_E ();
+        break;
+      case '(':
+        scr_charset_set (0, (unsigned int)cmd_getc ());
+        break;
+      case ')':
+        scr_charset_set (1, (unsigned int)cmd_getc ());
+        break;
+      case '*':
+        scr_charset_set (2, (unsigned int)cmd_getc ());
+        break;
+      case '+':
+        scr_charset_set (3, (unsigned int)cmd_getc ());
+        break;
 #ifdef MULTICHAR_SET
-    case '$':
-       scr_charset_set (-2, (unsigned int)cmd_getc ());
-       break;
+      case '$':
+        scr_charset_set (-2, (unsigned int)cmd_getc ());
+        break;
 #endif
 #ifndef NO_FRILLS
-    case '6':
-       scr_backindex ();
-       break;
-#endif
-    case '7':
-       scr_cursor (SAVE);
-       break;
-    case '8':
-       scr_cursor (RESTORE);
-       break;
+      case '6':
+        scr_backindex ();
+        break;
+#endif
+      case '7':
+        scr_cursor (SAVE);
+        break;
+      case '8':
+        scr_cursor (RESTORE);
+        break;
 #ifndef NO_FRILLS
-    case '9':
-       scr_forwardindex ();
-       break;
-#endif
-    case '=':
-    case '>':
-       PrivMode((ch == '='), PrivMode_aplKP);
-       break;
-
-    case C1_40:
-       cmd_getc ();
-       break;
-    case C1_44:
-       scr_index (UP);
-       break;
-
-    /* 8.3.87: NEXT LINE */
-    case C1_NEL:               /* ESC E */
+      case '9':
+        scr_forwardindex ();
+        break;
+#endif
+      case '=':
+      case '>':
+        PrivMode((ch == '='), PrivMode_aplKP);
+        break;
+
+      case C1_40:
+        cmd_getc ();
+        break;
+      case C1_44:
+        scr_index (UP);
+        break;
+
+        /* 8.3.87: NEXT LINE */
+      case C1_NEL:             /* ESC E */
         {
           uint32_t nlcr[] = { '\n', '\r' };
           scr_add_lines (nlcr, 1, 2);
         }
-       break;
-
-    /* kidnapped escape sequence: Should be 8.3.48 */
-    case C1_ESA:               /* ESC G */
-       process_graphics ();
-       break;
-
-    /* 8.3.63: CHARACTER TABULATION SET */
-    case C1_HTS:               /* ESC H */
-       scr_set_tab (1);
-       break;
-
-    /* 8.3.105: REVERSE LINE FEED */
-    case C1_RI:                        /* ESC M */
-       scr_index (DN);
-       break;
-
-    /* 8.3.142: SINGLE-SHIFT TWO */
-    /*case C1_SS2: scr_single_shift (2);   break; */
-
-    /* 8.3.143: SINGLE-SHIFT THREE */
-    /*case C1_SS3: scr_single_shift (3);   break; */
-
-    /* 8.3.27: DEVICE CONTROL STRING */
-    case C1_DCS:               /* ESC P */
-       process_dcs_seq ();
-       break;
-
-    /* 8.3.110: SINGLE CHARACTER INTRODUCER */
-    case C1_SCI:               /* ESC Z */
-       tt_write((const unsigned char *)ESCZ_ANSWER,
-                     (unsigned int)(sizeof(ESCZ_ANSWER) - 1));
-       break;                  /* steal obsolete ESC [ c */
-
-    /* 8.3.16: CONTROL SEQUENCE INTRODUCER */
-    case C1_CSI:               /* ESC [ */
-       process_csi_seq ();
-       break;
-
-    /* 8.3.90: OPERATING SYSTEM COMMAND */
-    case C1_OSC:               /* ESC ] */
-       process_osc_seq ();
-       break;
-
-    /* 8.3.106: RESET TO INITIAL STATE */
-    case 'c':
-       scr_poweron ();
-       scrollbar_show (1);
-       break;
-
-    /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */
-    case 'n':
-       scr_charset_choose (2);
-       break;
-
-    /* 8.3.81: LOCKING-SHIFT THREE (see ISO2022) */
-    case 'o':
-       scr_charset_choose (3);
-       break;
+        break;
+
+        /* kidnapped escape sequence: Should be 8.3.48 */
+      case C1_ESA:             /* ESC G */
+        process_graphics ();
+        break;
+
+        /* 8.3.63: CHARACTER TABULATION SET */
+      case C1_HTS:             /* ESC H */
+        scr_set_tab (1);
+        break;
+
+        /* 8.3.105: REVERSE LINE FEED */
+      case C1_RI:                      /* ESC M */
+        scr_index (DN);
+        break;
+
+        /* 8.3.142: SINGLE-SHIFT TWO */
+        /*case C1_SS2: scr_single_shift (2);   break; */
+
+        /* 8.3.143: SINGLE-SHIFT THREE */
+        /*case C1_SS3: scr_single_shift (3);   break; */
+
+        /* 8.3.27: DEVICE CONTROL STRING */
+      case C1_DCS:             /* ESC P */
+        process_dcs_seq ();
+        break;
+
+        /* 8.3.110: SINGLE CHARACTER INTRODUCER */
+      case C1_SCI:             /* ESC Z */
+        tt_write((const unsigned char *)ESCZ_ANSWER,
+                 (unsigned int)(sizeof(ESCZ_ANSWER) - 1));
+        break;                 /* steal obsolete ESC [ c */
+
+        /* 8.3.16: CONTROL SEQUENCE INTRODUCER */
+      case C1_CSI:             /* ESC [ */
+        process_csi_seq ();
+        break;
+
+        /* 8.3.90: OPERATING SYSTEM COMMAND */
+      case C1_OSC:             /* ESC ] */
+        process_osc_seq ();
+        break;
+
+        /* 8.3.106: RESET TO INITIAL STATE */
+      case 'c':
+        scr_poweron ();
+        scrollbar_show (1);
+        break;
+
+        /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */
+      case 'n':
+        scr_charset_choose (2);
+        break;
+
+        /* 8.3.81: LOCKING-SHIFT THREE (see ISO2022) */
+      case 'o':
+        scr_charset_choose (3);
+        break;
     }
 }
 /*}}} */
@@ -2378,15 +2480,15 @@ rxvt_term::process_escape_seq ()
 /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */
 /* *INDENT-OFF* */
 enum {
-    CSI_ICH = 0x40,
-            CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA,
-    CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA ,
-    CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC,
-    CSI_ECH, CSI_CVT, CSI_CBT, CSI_SRS, CSI_PTX, CSI_SDS, CSI_SIMD, CSI_5F,
-    CSI_HPA, CSI_HPR, CSI_REP, CSI_DA , CSI_VPA, CSI_VPR, CSI_HVP, CSI_TBC,
-    CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ,
-    CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 ,
-    CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F 
+  CSI_ICH = 0x40,
+  CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA,
+  CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA ,
+  CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC,
+  CSI_ECH, CSI_CVT, CSI_CBT, CSI_SRS, CSI_PTX, CSI_SDS, CSI_SIMD, CSI_5F,
+  CSI_HPA, CSI_HPR, CSI_REP, CSI_DA , CSI_VPA, CSI_VPR, CSI_HVP, CSI_TBC,
+  CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ,
+  CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 ,
+  CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F
 };
 
 #define make_byte(b7,b6,b5,b4,b3,b2,b1,b0)                     \
@@ -2395,7 +2497,8 @@ enum {
 #define get_byte_array_bit(array, bit)                         \
     (!!((array)[(bit) / 8] & (128 >> ((bit) & 7))))
 
-const unsigned char csi_defaults[] = {
+const unsigned char csi_defaults[] =
+  {
     make_byte(1,1,1,1,1,1,1,1),        /* @, A, B, C, D, E, F, G, */
     make_byte(1,1,0,0,1,1,0,0),        /* H, I, J, K, L, M, N, O, */
     make_byte(1,0,1,1,1,1,1,0),        /* P, Q, R, S, T, U, V, W, */
@@ -2404,293 +2507,311 @@ const unsigned char csi_defaults[] = {
     make_byte(0,0,1,1,0,0,0,0),        /* h, i, j, k, l, m, n, o, */
     make_byte(0,0,0,0,0,0,0,0),        /* p, q, r, s, t, u, v, w, */
     make_byte(0,0,0,0,0,0,0,0) /* x, y, z, {, |, }, ~,    */
-};
+  };
 /* *INDENT-ON* */
 
 void
 rxvt_term::process_csi_seq ()
 {
-    unsigned char   ch, priv, i;
-    unsigned int    nargs, p;
-    int             n, ndef;
-    int             arg[ESC_ARGS];
-
-    for (nargs = ESC_ARGS; nargs > 0;)
-       arg[--nargs] = 0;
-
-    priv = 0;
-    ch = cmd_getc ();
-    if (ch >= '<' && ch <= '?') {      /* '<' '=' '>' '?' */
-       priv = ch;
-       ch = cmd_getc ();
+  unsigned char   ch, priv, i;
+  unsigned int    nargs, p;
+  int             n, ndef;
+  int             arg[ESC_ARGS];
+
+  for (nargs = ESC_ARGS; nargs > 0;)
+    arg[--nargs] = 0;
+
+  priv = 0;
+  ch = cmd_getc ();
+  if (ch >= '<' && ch <= '?')
+    {  /* '<' '=' '>' '?' */
+      priv = ch;
+      ch = cmd_getc ();
     }
-/* read any numerical arguments */
-    for (n = -1; ch < CSI_ICH; ) {
-       if (isdigit(ch)) {
-           if (n < 0)
-               n = ch - '0';
-           else
-               n = n * 10 + ch - '0';
-       } else if (ch == ';') {
-           if (nargs < ESC_ARGS)
-               arg[nargs++] = n;
-           n = -1;
-       } else if (ch == '\b') {
-           scr_backspace ();
-       } else if (ch == C0_ESC) {
-           process_escape_seq ();
-           return;
-       } else if (ch < ' ') {
-           process_nonprinting (ch);
-       }
-       ch = cmd_getc ();
+  /* read any numerical arguments */
+  for (n = -1; ch < CSI_ICH; )
+    {
+      if (isdigit(ch))
+        {
+          if (n < 0)
+            n = ch - '0';
+          else
+            n = n * 10 + ch - '0';
+        }
+      else if (ch == ';')
+        {
+          if (nargs < ESC_ARGS)
+            arg[nargs++] = n;
+          n = -1;
+        }
+      else if (ch == '\b')
+        {
+          scr_backspace ();
+        }
+      else if (ch == C0_ESC)
+        {
+          process_escape_seq ();
+          return;
+        }
+      else if (ch < ' ')
+        {
+          process_nonprinting (ch);
+        }
+      ch = cmd_getc ();
     }
 
-    if (ch > CSI_7F)
-       return;
+  if (ch > CSI_7F)
+    return;
 
-    if (nargs < ESC_ARGS)
-       arg[nargs++] = n;
+  if (nargs < ESC_ARGS)
+    arg[nargs++] = n;
 
-    i = ch - CSI_ICH;
-    ndef = get_byte_array_bit(csi_defaults, i);
-    for (p = 0; p < nargs; p++)
-       if (arg[p] == -1)
-           arg[p] = ndef;
+  i = ch - CSI_ICH;
+  ndef = get_byte_array_bit(csi_defaults, i);
+  for (p = 0; p < nargs; p++)
+    if (arg[p] == -1)
+      arg[p] = ndef;
 
 #ifdef DEBUG_CMD
-    fprintf(stderr, "CSI ");
-    for (p = 0; p < nargs; p++)
-       fprintf(stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : "");
-    fprintf(stderr, "%c\n", ch);
+  fprintf(stderr, "CSI ");
+  for (p = 0; p < nargs; p++)
+    fprintf(stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : "");
+  fprintf(stderr, "%c\n", ch);
 #endif
 
-/*
- * private mode handling
- */
-    if (priv) {
-       switch (priv) {
-       case '>':
-           if (ch == CSI_DA)   /* secondary device attributes */
-               tt_printf("\033[>%d;%-.8s;0c", 'R', VSTRING);
-           break;
-       case '?':
-           if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
-               process_terminal_mode (ch, priv, nargs, arg);
-           break;
-       }
-       return;
+  /*
+   * private mode handling
+   */
+  if (priv)
+    {
+      switch (priv)
+        {
+          case '>':
+            if (ch == CSI_DA)  /* secondary device attributes */
+              tt_printf("\033[>%d;%-.8s;0c", 'R', VSTRING);
+            break;
+          case '?':
+            if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
+              process_terminal_mode (ch, priv, nargs, arg);
+            break;
+        }
+      return;
     }
 
-    switch (ch) {
-/*
- * ISO/IEC 6429:1992(E) CSI sequences (defaults in parentheses)
- */
+  switch (ch)
+    {
+        /*
+         * ISO/IEC 6429:1992(E) CSI sequences (defaults in parentheses)
+         */
 #ifdef PRINTPIPE
-    case CSI_MC:               /* 8.3.83: (0) MEDIA COPY */
-       switch (arg[0]) {
-       case 0:                 /* initiate transfer to primary aux device */
-           scr_printscreen (0);
-           break;
-       case 5:                 /* start relay to primary aux device */
-           process_print_pipe ();
-           break;
-       }
-       break;
-#endif
-
-    case CSI_CUU:              /* 8.3.22: (1) CURSOR UP */
-    case CSI_VPR:              /* 8.3.161: (1) LINE POSITION FORWARD */
-       arg[0] = -arg[0];
-    /* FALLTHROUGH */
-    case CSI_CUD:              /* 8.3.19: (1) CURSOR DOWN */
-    case CSI_VPB:              /* 8.3.160: (1) LINE POSITION BACKWARD */
-       scr_gotorc (arg[0], 0, RELATIVE);
-       break;
-
-    case CSI_CUB:              /* 8.3.18: (1) CURSOR LEFT */
-    case CSI_HPB:              /* 8.3.59: (1) CHARACTER POSITION BACKWARD */
+      case CSI_MC:             /* 8.3.83: (0) MEDIA COPY */
+        switch (arg[0])
+          {
+            case 0:                    /* initiate transfer to primary aux device */
+              scr_printscreen (0);
+              break;
+            case 5:                    /* start relay to primary aux device */
+              process_print_pipe ();
+              break;
+          }
+        break;
+#endif
+
+      case CSI_CUU:            /* 8.3.22: (1) CURSOR UP */
+      case CSI_VPR:            /* 8.3.161: (1) LINE POSITION FORWARD */
+        arg[0] = -arg[0];
+        /* FALLTHROUGH */
+      case CSI_CUD:            /* 8.3.19: (1) CURSOR DOWN */
+      case CSI_VPB:            /* 8.3.160: (1) LINE POSITION BACKWARD */
+        scr_gotorc (arg[0], 0, RELATIVE);
+        break;
+
+      case CSI_CUB:            /* 8.3.18: (1) CURSOR LEFT */
+      case CSI_HPB:            /* 8.3.59: (1) CHARACTER POSITION BACKWARD */
 #ifdef ISO6429
-       arg[0] = -arg[0];
+        arg[0] = -arg[0];
 #else                          /* emulate common DEC VTs */
-       arg[0] = arg[0] ? -arg[0] : -1;
+        arg[0] = arg[0] ? -arg[0] : -1;
 #endif
-    /* FALLTHROUGH */
-    case CSI_CUF:              /* 8.3.20: (1) CURSOR RIGHT */
-    case CSI_HPR:              /* 8.3.60: (1) CHARACTER POSITION FORWARD */
+        /* FALLTHROUGH */
+      case CSI_CUF:            /* 8.3.20: (1) CURSOR RIGHT */
+      case CSI_HPR:            /* 8.3.60: (1) CHARACTER POSITION FORWARD */
 #ifdef ISO6429
-       scr_gotorc (0, arg[0], RELATIVE);
+        scr_gotorc (0, arg[0], RELATIVE);
 #else                          /* emulate common DEC VTs */
-       scr_gotorc (0, arg[0] ? arg[0] : 1, RELATIVE);
-#endif
-       break;
-
-    case CSI_CPL:              /* 8.3.13: (1) CURSOR PRECEDING LINE */
-       arg[0] = -arg[0];
-    /* FALLTHROUGH */
-    case CSI_CNL:              /* 8.3.12: (1) CURSOR NEXT LINE */
-       scr_gotorc (arg[0], 0, R_RELATIVE);
-       break;
-
-    case CSI_CHA:              /* 8.3.9: (1) CURSOR CHARACTER ABSOLUTE */
-    case CSI_HPA:              /* 8.3.58: (1) CURSOR POSITION ABSOLUTE */
-       scr_gotorc (0, arg[0] - 1, R_RELATIVE);
-       break;
-
-    case CSI_VPA:              /* 8.3.159: (1) LINE POSITION ABSOLUTE */
-       scr_gotorc (arg[0] - 1, 0, C_RELATIVE);
-       break;
-
-    case CSI_CUP:              /* 8.3.21: (1,1) CURSOR POSITION */
-    case CSI_HVP:              /* 8.3.64: (1,1) CHARACTER AND LINE POSITION */
-       scr_gotorc (arg[0] - 1, nargs < 2 ? 0 : (arg[1] - 1), 0);
-       break;
-
-    case CSI_CBT:              /* 8.3.7: (1) CURSOR BACKWARD TABULATION */
-       arg[0] = -arg[0];
-    /* FALLTHROUGH */
-    case CSI_CHT:              /* 8.3.10: (1) CURSOR FORWARD TABULATION */
-       scr_tab (arg[0]);
-       break;
-
-    case CSI_ED:               /* 8.3.40: (0) ERASE IN PAGE */
-       scr_erase_screen (arg[0]);
-       break;
-
-    case CSI_EL:               /* 8.3.42: (0) ERASE IN LINE */
-       scr_erase_line (arg[0]);
-       break;
-
-    case CSI_ICH:              /* 8.3.65: (1) INSERT CHARACTER */
-       scr_insdel_chars (arg[0], INSERT);
-       break;
-
-    case CSI_IL:               /* 8.3.68: (1) INSERT LINE */
-       scr_insdel_lines (arg[0], INSERT);
-       break;
-
-    case CSI_DL:               /* 8.3.33: (1) DELETE LINE */
-       scr_insdel_lines (arg[0], DELETE);
-       break;
-
-    case CSI_ECH:              /* 8.3.39: (1) ERASE CHARACTER */
-       scr_insdel_chars (arg[0], ERASE);
-       break;
-
-    case CSI_DCH:              /* 8.3.26: (1) DELETE CHARACTER */
-       scr_insdel_chars (arg[0], DELETE);
-       break;
-
-    case CSI_SD:               /* 8.3.114: (1) SCROLL DOWN */
-       arg[0] = -arg[0];
-    /* FALLTHROUGH */
-    case CSI_SU:               /* 8.3.148: (1) SCROLL UP */
-       scr_scroll_text (screen.tscroll, screen.bscroll, arg[0], 0);
-       break;
-
-    case CSI_DA:               /* 8.3.24: (0) DEVICE ATTRIBUTES */
-       tt_write((const unsigned char *)VT100_ANS,
-                     (unsigned int)(sizeof(VT100_ANS) - 1));
-       break;
-
-    case CSI_SGR:              /* 8.3.118: (0) SELECT GRAPHIC RENDITION */
-       process_sgr_mode (nargs, arg);
-       break;
-
-    case CSI_DSR:              /* 8.3.36: (0) DEVICE STATUS REPORT */
-       switch (arg[0]) {
-       case 5:                 /* DSR requested */
-           tt_printf("\033[0n");
-           break;
-       case 6:                 /* CPR requested */
-           scr_report_position ();
-           break;
+        scr_gotorc (0, arg[0] ? arg[0] : 1, RELATIVE);
+#endif
+        break;
+
+      case CSI_CPL:            /* 8.3.13: (1) CURSOR PRECEDING LINE */
+        arg[0] = -arg[0];
+        /* FALLTHROUGH */
+      case CSI_CNL:            /* 8.3.12: (1) CURSOR NEXT LINE */
+        scr_gotorc (arg[0], 0, R_RELATIVE);
+        break;
+
+      case CSI_CHA:            /* 8.3.9: (1) CURSOR CHARACTER ABSOLUTE */
+      case CSI_HPA:            /* 8.3.58: (1) CURSOR POSITION ABSOLUTE */
+        scr_gotorc (0, arg[0] - 1, R_RELATIVE);
+        break;
+
+      case CSI_VPA:            /* 8.3.159: (1) LINE POSITION ABSOLUTE */
+        scr_gotorc (arg[0] - 1, 0, C_RELATIVE);
+        break;
+
+      case CSI_CUP:            /* 8.3.21: (1,1) CURSOR POSITION */
+      case CSI_HVP:            /* 8.3.64: (1,1) CHARACTER AND LINE POSITION */
+        scr_gotorc (arg[0] - 1, nargs < 2 ? 0 : (arg[1] - 1), 0);
+        break;
+
+      case CSI_CBT:            /* 8.3.7: (1) CURSOR BACKWARD TABULATION */
+        arg[0] = -arg[0];
+        /* FALLTHROUGH */
+      case CSI_CHT:            /* 8.3.10: (1) CURSOR FORWARD TABULATION */
+        scr_tab (arg[0]);
+        break;
+
+      case CSI_ED:             /* 8.3.40: (0) ERASE IN PAGE */
+        scr_erase_screen (arg[0]);
+        break;
+
+      case CSI_EL:             /* 8.3.42: (0) ERASE IN LINE */
+        scr_erase_line (arg[0]);
+        break;
+
+      case CSI_ICH:            /* 8.3.65: (1) INSERT CHARACTER */
+        scr_insdel_chars (arg[0], INSERT);
+        break;
+
+      case CSI_IL:             /* 8.3.68: (1) INSERT LINE */
+        scr_insdel_lines (arg[0], INSERT);
+        break;
+
+      case CSI_DL:             /* 8.3.33: (1) DELETE LINE */
+        scr_insdel_lines (arg[0], DELETE);
+        break;
+
+      case CSI_ECH:            /* 8.3.39: (1) ERASE CHARACTER */
+        scr_insdel_chars (arg[0], ERASE);
+        break;
+
+      case CSI_DCH:            /* 8.3.26: (1) DELETE CHARACTER */
+        scr_insdel_chars (arg[0], DELETE);
+        break;
+
+      case CSI_SD:             /* 8.3.114: (1) SCROLL DOWN */
+        arg[0] = -arg[0];
+        /* FALLTHROUGH */
+      case CSI_SU:             /* 8.3.148: (1) SCROLL UP */
+        scr_scroll_text (screen.tscroll, screen.bscroll, arg[0], 0);
+        break;
+
+      case CSI_DA:             /* 8.3.24: (0) DEVICE ATTRIBUTES */
+        tt_write((const unsigned char *)VT100_ANS,
+                 (unsigned int)(sizeof(VT100_ANS) - 1));
+        break;
+
+      case CSI_SGR:            /* 8.3.118: (0) SELECT GRAPHIC RENDITION */
+        process_sgr_mode (nargs, arg);
+        break;
+
+      case CSI_DSR:            /* 8.3.36: (0) DEVICE STATUS REPORT */
+        switch (arg[0])
+          {
+            case 5:                    /* DSR requested */
+              tt_printf("\033[0n");
+              break;
+            case 6:                    /* CPR requested */
+              scr_report_position ();
+              break;
 #if defined (ENABLE_DISPLAY_ANSWER)
-       case 7:                 /* unofficial extension */
-           tt_printf("%-.250s\n", rs[Rs_display_name]);
-           break;
-#endif
-       case 8:                 /* unofficial extension */
-           xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST);
-           break;
-       }
-       break;
-
-    case CSI_TBC:              /* 8.3.155: (0) TABULATION CLEAR */
-       switch (arg[0]) {
-       case 0:                 /* char tab stop cleared at active position */
-           scr_set_tab (0);
-           break;
-       /* case 1: */           /* line tab stop cleared in active line */
-       /* case 2: */           /* char tab stops cleared in active line */
-       case 3:                 /* all char tab stops are cleared */
-       /* case 4: */           /* all line tab stops are cleared */
-       case 5:                 /* all tab stops are cleared */
-           scr_set_tab (-1);
-           break;
-       }
-       break;
-
-    case CSI_CTC:              /* 8.3.17: (0) CURSOR TABULATION CONTROL */
-       switch (arg[0]) {
-       case 0:                 /* char tab stop set at active position */
-           scr_set_tab (1);
-           break;              /* = ESC H */
-       /* case 1: */           /* line tab stop set at active line */
-       case 2:                 /* char tab stop cleared at active position */
-           scr_set_tab (0);
-           break;              /* = ESC [ 0 g */
-       /* case 3: */           /* line tab stop cleared at active line */
-       /* case 4: */           /* char tab stops cleared at active line */
-       case 5:                 /* all char tab stops are cleared */
-           scr_set_tab (-1);
-           break;              /* = ESC [ 3 g */
-       /* case 6: */           /* all line tab stops are cleared */
-       }
-       break;
-
-    case CSI_RM:               /* 8.3.107: RESET MODE */
-       if (arg[0] == 4)
-           scr_insert_mode (0);
-       break;
-
-    case CSI_SM:               /* 8.3.126: SET MODE */
-       if (arg[0] == 4)
-           scr_insert_mode (1);
-       break;
+            case 7:                    /* unofficial extension */
+              tt_printf("%-.250s\n", rs[Rs_display_name]);
+              break;
+#endif
+            case 8:                    /* unofficial extension */
+              xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST);
+              break;
+          }
+        break;
 
-/*
- * PRIVATE USE beyond this point.  All CSI_7? sequences here
- */ 
-    case CSI_72:               /* DECSTBM: set top and bottom margins */
-       if (nargs == 1)
-           scr_scroll_region (arg[0] - 1, MAX_ROWS - 1);
-       else if (nargs == 0 || arg[0] >= arg[1])
-           scr_scroll_region (0, MAX_ROWS - 1);
-       else 
-           scr_scroll_region (arg[0] - 1, arg[1] - 1);
-       break;
-
-    case CSI_73:
-       scr_cursor (SAVE);
-       break;
-    case CSI_75:
-       scr_cursor (RESTORE);
-       break;
+      case CSI_TBC:            /* 8.3.155: (0) TABULATION CLEAR */
+        switch (arg[0])
+          {
+            case 0:                    /* char tab stop cleared at active position */
+              scr_set_tab (0);
+              break;
+              /* case 1: */            /* line tab stop cleared in active line */
+              /* case 2: */            /* char tab stops cleared in active line */
+            case 3:                    /* all char tab stops are cleared */
+              /* case 4: */            /* all line tab stops are cleared */
+            case 5:                    /* all tab stops are cleared */
+              scr_set_tab (-1);
+              break;
+          }
+        break;
+
+      case CSI_CTC:            /* 8.3.17: (0) CURSOR TABULATION CONTROL */
+        switch (arg[0])
+          {
+            case 0:                    /* char tab stop set at active position */
+              scr_set_tab (1);
+              break;           /* = ESC H */
+              /* case 1: */            /* line tab stop set at active line */
+            case 2:                    /* char tab stop cleared at active position */
+              scr_set_tab (0);
+              break;           /* = ESC [ 0 g */
+              /* case 3: */            /* line tab stop cleared at active line */
+              /* case 4: */            /* char tab stops cleared at active line */
+            case 5:                    /* all char tab stops are cleared */
+              scr_set_tab (-1);
+              break;           /* = ESC [ 3 g */
+              /* case 6: */            /* all line tab stops are cleared */
+          }
+        break;
+
+      case CSI_RM:             /* 8.3.107: RESET MODE */
+        if (arg[0] == 4)
+          scr_insert_mode (0);
+        break;
+
+      case CSI_SM:             /* 8.3.126: SET MODE */
+        if (arg[0] == 4)
+          scr_insert_mode (1);
+        break;
+
+        /*
+         * PRIVATE USE beyond this point.  All CSI_7? sequences here
+         */
+      case CSI_72:             /* DECSTBM: set top and bottom margins */
+        if (nargs == 1)
+          scr_scroll_region (arg[0] - 1, MAX_ROWS - 1);
+        else if (nargs == 0 || arg[0] >= arg[1])
+          scr_scroll_region (0, MAX_ROWS - 1);
+        else
+          scr_scroll_region (arg[0] - 1, arg[1] - 1);
+        break;
+
+      case CSI_73:
+        scr_cursor (SAVE);
+        break;
+      case CSI_75:
+        scr_cursor (RESTORE);
+        break;
 
 #ifndef NO_FRILLS
-    case CSI_74:
-       process_window_ops (arg, nargs);
-       break;
+      case CSI_74:
+        process_window_ops (arg, nargs);
+        break;
 #endif
 
-    case CSI_78:               /* DECREQTPARM */
-       if (arg[0] == 0 || arg[0] == 1)
-           tt_printf("\033[%d;1;1;128;128;1;0x", arg[0] + 2);
-    /* FALLTHROUGH */
+      case CSI_78:             /* DECREQTPARM */
+        if (arg[0] == 0 || arg[0] == 1)
+          tt_printf("\033[%d;1;1;128;128;1;0x", arg[0] + 2);
+        /* FALLTHROUGH */
 
-    default:
-       break;
+      default:
+        break;
     }
 }
 /*}}} */
@@ -2700,81 +2821,83 @@ rxvt_term::process_csi_seq ()
 void
 rxvt_term::process_window_ops (const int *args, unsigned int nargs)
 {
-    int             x, y;
+  int             x, y;
 #if 0
-    char           *s;
-#endif
-    XWindowAttributes wattr;
-    Window          wdummy;
-
-    if (nargs == 0)
-       return;
-    switch (args[0]) {
-    /*
-     * commands
-     */
-    case 1:                    /* deiconify window */
-       XMapWindow(Xdisplay, TermWin.parent[0]);
-       break;
-    case 2:                    /* iconify window */
-       XIconifyWindow(Xdisplay, TermWin.parent[0],
-                      DefaultScreen(Xdisplay));
-       break;
-    case 3:                    /* set position (pixels) */
-       XMoveWindow(Xdisplay, TermWin.parent[0], args[1], args[2]);
-       break;
-    case 4:                    /* set size (pixels) */
-       set_widthheight ((unsigned int)args[2], (unsigned int)args[1]);
-       break;
-    case 5:                    /* raise window */
-       XRaiseWindow(Xdisplay, TermWin.parent[0]);
-       break;
-    case 6:                    /* lower window */
-       XLowerWindow(Xdisplay, TermWin.parent[0]);
-       break;
-    case 7:                    /* refresh window */
-       scr_touch (true);
-       break;
-    case 8:                    /* set size (chars) */
-       set_widthheight ((unsigned int)(args[2] * TermWin.fwidth),
-                            (unsigned int)(args[1] * TermWin.fheight));
-       break;
-    default:
-       if (args[0] >= 24)      /* set height (chars) */
-           set_widthheight ((unsigned int)TermWin.width,
-                                (unsigned int)(args[1] * TermWin.fheight));
-       break;
-    /*
-     * reports - some output format copied from XTerm
-     */
-    case 11:                   /* report window state */
-       XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
-       tt_printf("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
-       break;
-    case 13:                   /* report window position */
-       XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
-       XTranslateCoordinates(Xdisplay, TermWin.parent[0], wattr.root,
-                             -wattr.border_width, -wattr.border_width,
-                             &x, &y, &wdummy);
-       tt_printf("\033[3;%d;%dt", x, y);
-       break;
-    case 14:                   /* report window size (pixels) */
-       XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
-       tt_printf("\033[4;%d;%dt", wattr.height, wattr.width);
-       break;
-    case 18:                   /* report window size (chars) */
-       tt_printf("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol);
-       break;
+  char           *s;
+#endif
+  XWindowAttributes wattr;
+  Window          wdummy;
+
+  if (nargs == 0)
+    return;
+  switch (args[0])
+    {
+        /*
+         * commands
+         */
+      case 1:                  /* deiconify window */
+        XMapWindow(Xdisplay, TermWin.parent[0]);
+        break;
+      case 2:                  /* iconify window */
+        XIconifyWindow(Xdisplay, TermWin.parent[0],
+                       DefaultScreen(Xdisplay));
+        break;
+      case 3:                  /* set position (pixels) */
+        XMoveWindow(Xdisplay, TermWin.parent[0], args[1], args[2]);
+        break;
+      case 4:                  /* set size (pixels) */
+        set_widthheight ((unsigned int)args[2], (unsigned int)args[1]);
+        break;
+      case 5:                  /* raise window */
+        XRaiseWindow(Xdisplay, TermWin.parent[0]);
+        break;
+      case 6:                  /* lower window */
+        XLowerWindow(Xdisplay, TermWin.parent[0]);
+        break;
+      case 7:                  /* refresh window */
+        scr_touch (true);
+        break;
+      case 8:                  /* set size (chars) */
+        set_widthheight ((unsigned int)(args[2] * TermWin.fwidth),
+                         (unsigned int)(args[1] * TermWin.fheight));
+        break;
+      default:
+        if (args[0] >= 24)     /* set height (chars) */
+          set_widthheight ((unsigned int)TermWin.width,
+                           (unsigned int)(args[1] * TermWin.fheight));
+        break;
+        /*
+         * reports - some output format copied from XTerm
+         */
+      case 11:                 /* report window state */
+        XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
+        tt_printf("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
+        break;
+      case 13:                 /* report window position */
+        XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
+        XTranslateCoordinates(Xdisplay, TermWin.parent[0], wattr.root,
+                              -wattr.border_width, -wattr.border_width,
+                              &x, &y, &wdummy);
+        tt_printf("\033[3;%d;%dt", x, y);
+        break;
+      case 14:                 /* report window size (pixels) */
+        XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
+        tt_printf("\033[4;%d;%dt", wattr.height, wattr.width);
+        break;
+      case 18:                 /* report window size (chars) */
+        tt_printf("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol);
+        break;
 #if 0 /* XXX: currently disabled due to security concerns */
-    case 20:                   /* report icon label */
-       XGetIconName(Xdisplay, TermWin.parent[0], &s);
-       tt_printf("\033]L%-.200s\234", s ? s : "");     /* 8bit ST */
-       break;
-    case 21:                   /* report window title */
-       XFetchName(Xdisplay, TermWin.parent[0], &s);
-       tt_printf("\033]l%-.200s\234", s ? s : "");     /* 8bit ST */
-       break;
+      case 20:                 /* report icon label */
+        XGetIconName(Xdisplay, TermWin.parent[0], &s);
+        tt_printf("\033]L%-.200s\234", s ? s : "");    /* 8bit ST */
+        break;
+      case 21:                 /* report window title */
+        XFetchName(Xdisplay, TermWin.parent[0], &s);
+        tt_printf("\033]l%-.200s\234", s ? s : "");    /* 8bit ST */
+        break;
 #endif
+
     }
 }
 #endif
@@ -2787,33 +2910,36 @@ rxvt_term::process_window_ops (const int *args, unsigned int nargs)
 unsigned char  *
 rxvt_term::get_to_st (unsigned char *ends_how)
 {
-    int             seen_esc = 0;      /* seen escape? */
-    unsigned int    n = 0;
-    unsigned char  *s;
-    unsigned char   ch, string[STRING_MAX];
-
-    for (; (ch = cmd_getc ());) {
-       if (ch == C0_BEL
-           || ch == CHAR_ST
-           || (ch == 0x5c && seen_esc))        /* 7bit ST */
-           break;
-       if (ch == C0_ESC) {
-           seen_esc = 1;
-           continue;
-       } else if (ch == '\t')
-           ch = ' ';   /* translate '\t' to space */
-       else if (ch < 0x08 || (ch > 0x0d && ch < 0x20))
-           return NULL;        /* other control character - exit */
-       if (n < sizeof(string) - 1)
-           string[n++] = ch;
-       seen_esc = 0;
+  int             seen_esc = 0;        /* seen escape? */
+  unsigned int    n = 0;
+  unsigned char  *s;
+  unsigned char   ch, string[STRING_MAX];
+
+  for (; (ch = cmd_getc ());)
+    {
+      if (ch == C0_BEL
+          || ch == CHAR_ST
+          || (ch == 0x5c && seen_esc)) /* 7bit ST */
+        break;
+      if (ch == C0_ESC)
+        {
+          seen_esc = 1;
+          continue;
+        }
+      else if (ch == '\t')
+        ch = ' ';      /* translate '\t' to space */
+      else if (ch < 0x08 || (ch > 0x0d && ch < 0x20))
+        return NULL;   /* other control character - exit */
+      if (n < sizeof(string) - 1)
+        string[n++] = ch;
+      seen_esc = 0;
     }
-    string[n++] = '\0';
-    if ((s = (unsigned char *)rxvt_malloc(n)) == NULL)
-       return NULL;
-    *ends_how = (ch == 0x5c ? C0_ESC : ch);
-    STRNCPY(s, string, n);
-    return s;
+  string[n++] = '\0';
+  if ((s = (unsigned char *)rxvt_malloc(n)) == NULL)
+    return NULL;
+  *ends_how = (ch == 0x5c ? C0_ESC : ch);
+  STRNCPY(s, string, n);
+  return s;
 }
 
 /*----------------------------------------------------------------------*/
@@ -2823,14 +2949,14 @@ rxvt_term::get_to_st (unsigned char *ends_how)
 void
 rxvt_term::process_dcs_seq ()
 {
-    unsigned char    eh, *s;
-/*
- * Not handled yet
- */
-    s = get_to_st (&eh);
-    if (s)
-       free(s);
-    return;
+  unsigned char    eh, *s;
+  /*
  * Not handled yet
  */
+  s = get_to_st (&eh);
+  if (s)
+    free(s);
+  return;
 }
 
 /*----------------------------------------------------------------------*/
@@ -2840,30 +2966,32 @@ rxvt_term::process_dcs_seq ()
 void
 rxvt_term::process_osc_seq ()
 {
-    unsigned char   ch, eh, *s;
-    int             arg;
+  unsigned char   ch, eh, *s;
+  int             arg;
 
-    ch = cmd_getc ();
-    for (arg = 0; isdigit(ch); ch = cmd_getc ())
-       arg = arg * 10 + (ch - '0');
-
-    if (ch == ';') {
-       s = get_to_st (&eh);
-       if (s) {
-    /*
-     * rxvt_menubar_dispatch() violates the constness of the string,
-     * so do it here
-     */
-           if (arg == XTerm_Menu)
+  ch = cmd_getc ();
+  for (arg = 0; isdigit(ch); ch = cmd_getc ())
+    arg = arg * 10 + (ch - '0');
+
+  if (ch == ';')
+    {
+      s = get_to_st (&eh);
+      if (s)
+        {
+          /*
+           * rxvt_menubar_dispatch() violates the constness of the string,
+           * so do it here
+           */
+          if (arg == XTerm_Menu)
 #if 0 /* XXX: currently disabled due to security concerns */
-               menubar_dispatch ((char *)s);
+            menubar_dispatch ((char *)s);
 #else
-               (void)0;
+            (void)0;
 #endif
-           else
-               xterm_seq (arg, (char *)s, eh);
-           free(s);
-       }
+          else
+            xterm_seq (arg, (char *)s, eh);
+          free(s);
+        }
     }
 }
 /*
@@ -2890,104 +3018,112 @@ rxvt_term::process_osc_seq ()
 void
 rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__((unused)))
 {
-    int             changed = 0;
-    int             color;
-    char           *buf, *name;
-
-    assert(str != NULL);
-    switch (op) {
-    case XTerm_name:
-       set_title (str);
-    /* FALLTHROUGH */
-    case XTerm_iconName:
-       set_iconName (str);
-       break;
-    case XTerm_title:
-       set_title (str);
-       break;
-    case XTerm_Color:
-       for (buf = (char *)str; buf && *buf;) {
-           if ((name = STRCHR(buf, ';')) == NULL)
-               break;
-           *name++ = '\0';
-           color = atoi(buf);
-           if (color < 0 || color >= TOTAL_COLORS)
-               break;
-           if ((buf = STRCHR(name, ';')) != NULL)
-               *buf++ = '\0';
-           set_window_color (color + minCOLOR, name);
-       }
-       break;
+  int             changed = 0;
+  int             color;
+  char           *buf, *name;
+
+  assert(str != NULL);
+  switch (op)
+    {
+      case XTerm_name:
+        set_title (str);
+        /* FALLTHROUGH */
+      case XTerm_iconName:
+        set_iconName (str);
+        break;
+      case XTerm_title:
+        set_title (str);
+        break;
+      case XTerm_Color:
+        for (buf = (char *)str; buf && *buf;)
+          {
+            if ((name = STRCHR(buf, ';')) == NULL)
+              break;
+            *name++ = '\0';
+            color = atoi(buf);
+            if (color < 0 || color >= TOTAL_COLORS)
+              break;
+            if ((buf = STRCHR(name, ';')) != NULL)
+              *buf++ = '\0';
+            set_window_color (color + minCOLOR, name);
+          }
+        break;
 #ifndef NO_CURSORCOLOR
-    case XTerm_Color_cursor:
-       set_window_color (Color_cursor, str);
-       break;
+      case XTerm_Color_cursor:
+        set_window_color (Color_cursor, str);
+        break;
 #endif
-    case XTerm_Color_pointer:
-       set_window_color (Color_pointer, str);
-       break;
+      case XTerm_Color_pointer:
+        set_window_color (Color_pointer, str);
+        break;
 #ifndef NO_BOLD_UNDERLINE_REVERSE
-    case XTerm_Color_BD:
-       set_window_color (Color_BD, str);
-       break;
-    case XTerm_Color_UL:
-       set_window_color (Color_UL, str);
-       break;
-    case XTerm_Color_RV:
-       set_window_color (Color_RV, str);
-       break;
-#endif
-
-    case XTerm_Menu:
+      case XTerm_Color_BD:
+        set_window_color (Color_BD, str);
+        break;
+      case XTerm_Color_UL:
+        set_window_color (Color_UL, str);
+        break;
+      case XTerm_Color_RV:
+        set_window_color (Color_RV, str);
+        break;
+#endif
+
+      case XTerm_Menu:
         /*
          * rxvt_menubar_dispatch() violates the constness of the string,
          * so DON'T do it here
          */
-       break;
-    case XTerm_Pixmap:
-       if (*str != ';') {
+        break;
+      case XTerm_Pixmap:
+        if (*str != ';')
+          {
 #if XPM_BACKGROUND
-           scale_pixmap ("");  /* reset to default scaling */
-           set_bgPixmap (str); /* change pixmap */
+            scale_pixmap (""); /* reset to default scaling */
+            set_bgPixmap (str);        /* change pixmap */
 #endif
-           scr_touch (true);
-       }
-       while ((str = STRCHR(str, ';')) != NULL) {
-           str++;
+            scr_touch (true);
+          }
+        while ((str = STRCHR(str, ';')) != NULL)
+          {
+            str++;
 #if XPM_BACKGROUND
-           changed += scale_pixmap (str);
+            changed += scale_pixmap (str);
 #endif
-       }
-       if (changed) {
+
+          }
+        if (changed)
+          {
 #ifdef XPM_BACKGROUND
-           resize_pixmap ();
-#endif
-           scr_touch (true);
-       }
-       break;
-
-    case XTerm_restoreFG:
-       set_window_color (Color_fg, str);
-       break;
-    case XTerm_restoreBG:
-       set_window_color (Color_bg, str);
-       break;
-    case XTerm_logfile:
-       break;
-    case XTerm_font:
-       change_font (0, str);
-       break;
+            resize_pixmap ();
+#endif
+            scr_touch (true);
+          }
+        break;
+
+      case XTerm_restoreFG:
+        set_window_color (Color_fg, str);
+        break;
+      case XTerm_restoreBG:
+        set_window_color (Color_bg, str);
+        break;
+      case XTerm_logfile:
+        break;
+      case XTerm_font:
+        change_font (0, str);
+        break;
 #if 0
-    case XTerm_dumpscreen:     /* no error notices */
-       {
-           int             fd;
-           if ((fd = open(str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) {
-               scr_dump (fd);
-               close(fd);
-           }
-       }
-       break;
+      case XTerm_dumpscreen:   /* no error notices */
+        {
+          int             fd;
+          if ((fd = open(str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
+            {
+              scr_dump (fd);
+              close(fd);
+            }
+        }
+        break;
 #endif
+
     }
 }
 /*----------------------------------------------------------------------*/
@@ -3005,181 +3141,191 @@ rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__(
 int
 rxvt_term::privcases (int mode, unsigned long bit)
 {
-    int             state;
-
-    if (mode == 's') {
-       SavedModes |= (PrivateModes & bit);
-       return -1;
-    } else {
-       if (mode == 'r')
-           state = (SavedModes & bit) ? 1 : 0; /* no overlapping */
-       else
-           state = (mode == 't') ? !(PrivateModes & bit) : mode;
-       PrivMode(state, bit);
+  int             state;
+
+  if (mode == 's')
+    {
+      SavedModes |= (PrivateModes & bit);
+      return -1;
     }
-    return state;
+  else
+    {
+      if (mode == 'r')
+        state = (SavedModes & bit) ? 1 : 0;    /* no overlapping */
+      else
+        state = (mode == 't') ? !(PrivateModes & bit) : mode;
+      PrivMode(state, bit);
+    }
+  return state;
 }
 
 /* we're not using priv _yet_ */
 void
 rxvt_term::process_terminal_mode (int mode, int priv __attribute__((unused)), unsigned int nargs, const int *arg)
 {
-    unsigned int    i, j;
-    int             state;
-    static const struct {
-       const int       argval;
-       const unsigned long bit;
-    } argtopriv[] = {
-       { 1, PrivMode_aplCUR },
-       { 2, PrivMode_vt52 },
-       { 3, PrivMode_132 },
-       { 4, PrivMode_smoothScroll },
-       { 5, PrivMode_rVideo },
-       { 6, PrivMode_relOrigin },
-       { 7, PrivMode_Autowrap },
-       { 9, PrivMode_MouseX10 },
+  unsigned int    i, j;
+  int             state;
+  static const struct
+    {
+      const int       argval;
+      const unsigned long bit;
+    }
+  argtopriv[] = {
+                  { 1, PrivMode_aplCUR },
+                  { 2, PrivMode_vt52 },
+                  { 3, PrivMode_132 },
+                  { 4, PrivMode_smoothScroll },
+                  { 5, PrivMode_rVideo },
+                  { 6, PrivMode_relOrigin },
+                  { 7, PrivMode_Autowrap },
+                  { 9, PrivMode_MouseX10 },
 #ifdef menuBar_esc
-       { menuBar_esc, PrivMode_menuBar },
+                  { menuBar_esc, PrivMode_menuBar },
 #endif
 #ifdef scrollBar_esc
-       { scrollBar_esc, PrivMode_scrollBar },
+                  { scrollBar_esc, PrivMode_scrollBar },
 #endif
-       { 25, PrivMode_VisibleCursor },
-       { 35, PrivMode_ShiftKeys },
-       { 40, PrivMode_132OK },
-       { 47, PrivMode_Screen },
-       { 66, PrivMode_aplKP },
+                  { 25, PrivMode_VisibleCursor },
+                  { 35, PrivMode_ShiftKeys },
+                  { 40, PrivMode_132OK },
+                  { 47, PrivMode_Screen },
+                  { 66, PrivMode_aplKP },
 #ifndef NO_BACKSPACE_KEY
-       { 67, PrivMode_BackSpace },
+                  { 67, PrivMode_BackSpace },
 #endif
-       { 1000, PrivMode_MouseX11 },
-       { 1010, PrivMode_TtyOutputInh },
-       { 1011, PrivMode_Keypress },
-       { 1047, PrivMode_Screen },
-       { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */
-    };
+                  { 1000, PrivMode_MouseX11 },
+                  { 1010, PrivMode_TtyOutputInh },
+                  { 1011, PrivMode_Keypress },
+                  { 1047, PrivMode_Screen },
+                  { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */
+                };
+
+  if (nargs == 0)
+    return;
 
-    if (nargs == 0)
-       return;
-
-/* make lo/hi boolean */
-    if (mode == 'l')
-       mode = 0;               /* reset */
-    else if (mode == 'h')
-       mode = 1;               /* set */
-
-    for (i = 0; i < nargs; i++) {
-       state = -1;
-
-       /* basic handling */
-       for (j = 0; j < (sizeof(argtopriv)/sizeof(argtopriv[0])); j++)
-           if (argtopriv[j].argval == arg[i]) {
-               state = privcases (mode, argtopriv[j].bit);
-               break;
-           }
-       
-       /* extra handling for values with state unkept  */
-       if (state == -1)
-           switch (arg[i]) {
-           case 1048:          /* alternative cursor save */
-               if (mode == 0)
-                   scr_cursor (RESTORE);
-               else if (mode == 1)
-                   scr_cursor (SAVE);
-           /* FALLTHROUGH */
-           default:
-               continue;       /* for(;i;) */
-           }
-
-       /* extra handling for values with valid 0 or 1 state */
-       switch (arg[i]) {
-       /* case 1:      - application cursor keys */
-       case 2:                 /* VT52 mode */
-             /* oddball mode.  should be set regardless of set/reset
-              * parameter.  Return from VT52 mode with an ESC < from
-              * within VT52 mode
-              */
-           PrivMode(1, PrivMode_vt52);
-           break;
-       case 3:                 /* 80/132 */
-           if (PrivateModes & PrivMode_132OK)
-               set_widthheight (                   (unsigned int)((state ? 132 : 80) * TermWin.fwidth),
-                   (unsigned int)TermWin.height);
-           break;
-       case 4:                 /* smooth scrolling */
-           if (state)
-               Options &= ~Opt_jumpScroll;
-           else
-               Options |= Opt_jumpScroll;
-           break;
-       case 5:                 /* reverse video */
-           scr_rvideo_mode (state);
-           break;
-       case 6:                 /* relative/absolute origins  */
-           scr_relative_origin (state);
-           break;
-       case 7:                 /* autowrap */
-           scr_autowrap (state);
-           break;
-       /* case 8:      - auto repeat, can't do on a per window basis */
-       case 9:                 /* X10 mouse reporting */
-           if (state)          /* orthogonal */
-               PrivateModes &= ~(PrivMode_MouseX11);
-           break;
+  /* make lo/hi boolean */
+  if (mode == 'l')
+    mode = 0;          /* reset */
+  else if (mode == 'h')
+    mode = 1;          /* set */
+
+  for (i = 0; i < nargs; i++)
+    {
+      state = -1;
+
+      /* basic handling */
+      for (j = 0; j < (sizeof(argtopriv)/sizeof(argtopriv[0])); j++)
+        if (argtopriv[j].argval == arg[i])
+          {
+            state = privcases (mode, argtopriv[j].bit);
+            break;
+          }
+
+      /* extra handling for values with state unkept  */
+      if (state == -1)
+        switch (arg[i])
+          {
+            case 1048:         /* alternative cursor save */
+              if (mode == 0)
+                scr_cursor (RESTORE);
+              else if (mode == 1)
+                scr_cursor (SAVE);
+              /* FALLTHROUGH */
+            default:
+              continue;        /* for(;i;) */
+          }
+
+      /* extra handling for values with valid 0 or 1 state */
+      switch (arg[i])
+        {
+            /* case 1: - application cursor keys */
+          case 2:                      /* VT52 mode */
+            /* oddball mode.  should be set regardless of set/reset
+             * parameter.  Return from VT52 mode with an ESC < from
+             * within VT52 mode
+             */
+            PrivMode(1, PrivMode_vt52);
+            break;
+          case 3:                      /* 80/132 */
+            if (PrivateModes & PrivMode_132OK)
+              set_widthheight (                    (unsigned int)((state ? 132 : 80) * TermWin.fwidth),
+                                     (unsigned int)TermWin.height);
+            break;
+          case 4:                      /* smooth scrolling */
+            if (state)
+              Options &= ~Opt_jumpScroll;
+            else
+              Options |= Opt_jumpScroll;
+            break;
+          case 5:                      /* reverse video */
+            scr_rvideo_mode (state);
+            break;
+          case 6:                      /* relative/absolute origins  */
+            scr_relative_origin (state);
+            break;
+          case 7:                      /* autowrap */
+            scr_autowrap (state);
+            break;
+            /* case 8: - auto repeat, can't do on a per window basis */
+          case 9:                      /* X10 mouse reporting */
+            if (state)         /* orthogonal */
+              PrivateModes &= ~(PrivMode_MouseX11);
+            break;
 #ifdef menuBar_esc
-       case menuBar_esc:
+          case menuBar_esc:
 #ifdef MENUBAR
-           map_menuBar (state);
+            map_menuBar (state);
 #endif
-           break;
+            break;
 #endif
 #ifdef scrollBar_esc
-       case scrollBar_esc:
-           if (scrollbar_mapping (state)) {
-               resize_all_windows (0, 0, 0);
+          case scrollBar_esc:
+            if (scrollbar_mapping (state))
+              {
+                resize_all_windows (0, 0, 0);
                 scr_touch (true);
-           }
-           break;
-#endif
-       case 25:                /* visible/invisible cursor */
-           scr_cursor_visible (state);
-           break;
-       /* case 35:     - shift keys */
-       /* case 40:     - 80 <--> 132 mode */
-       case 47:                /* secondary screen */
-           scr_change_screen (state);
-           break;
-       /* case 66:     - application key pad */
-       /* case 67:     - backspace key */
-       case 1000:              /* X11 mouse reporting */
-           if (state)          /* orthogonal */
-               PrivateModes &= ~(PrivMode_MouseX10);
-           break;
+              }
+            break;
+#endif
+          case 25:             /* visible/invisible cursor */
+            scr_cursor_visible (state);
+            break;
+            /* case 35:        - shift keys */
+            /* case 40:        - 80 <--> 132 mode */
+          case 47:             /* secondary screen */
+            scr_change_screen (state);
+            break;
+            /* case 66:        - application key pad */
+            /* case 67:        - backspace key */
+          case 1000:           /* X11 mouse reporting */
+            if (state)         /* orthogonal */
+              PrivateModes &= ~(PrivMode_MouseX10);
+            break;
 #if 0
-       case 1001:
-           break;              /* X11 mouse highlighting */
-#endif
-       case 1010:              /* scroll to bottom on TTY output inhibit */
-           if (state)
-               Options &= ~Opt_scrollTtyOutput;
-           else
-               Options |= Opt_scrollTtyOutput;
-           break;
-       case 1011:              /* scroll to bottom on key press */
-           if (state)
-               Options |= Opt_scrollTtyKeypress;
-           else
-               Options &= ~Opt_scrollTtyKeypress;
-           break;
-       case 1047:              /* secondary screen w/ clearing */
-       case 1049:              /* better secondary screen w/ clearing, but not fully implemented */
-           if (current_screen != PRIMARY)
-               scr_erase_screen (2);
-           scr_change_screen (state);
-       /* FALLTHROUGH */
-       default:
-           break;
-       }
+          case 1001:
+            break;             /* X11 mouse highlighting */
+#endif
+          case 1010:           /* scroll to bottom on TTY output inhibit */
+            if (state)
+              Options &= ~Opt_scrollTtyOutput;
+            else
+              Options |= Opt_scrollTtyOutput;
+            break;
+          case 1011:           /* scroll to bottom on key press */
+            if (state)
+              Options |= Opt_scrollTtyKeypress;
+            else
+              Options &= ~Opt_scrollTtyKeypress;
+            break;
+          case 1047:           /* secondary screen w/ clearing */
+          case 1049:           /* better secondary screen w/ clearing, but not fully implemented */
+            if (current_screen != PRIMARY)
+              scr_erase_screen (2);
+            scr_change_screen (state);
+            /* FALLTHROUGH */
+          default:
+            break;
+        }
     }
 }
 /*}}} */
@@ -3188,124 +3334,132 @@ rxvt_term::process_terminal_mode (int mode, int priv __attribute__((unused)), un
 void
 rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg)
 {
-    unsigned int    i;
-    short           rendset;
-    int             rendstyle;
+  unsigned int    i;
+  short           rendset;
+  int             rendstyle;
 
-    if (nargs == 0) {
-       scr_rendition (0, ~RS_None);
-       return;
+  if (nargs == 0)
+    {
+      scr_rendition (0, ~RS_None);
+      return;
     }
-    for (i = 0; i < nargs; i++) {
-       rendset = -1;
-       switch (arg[i]) {
-       case 0:
-           rendset = 0, rendstyle = ~RS_None;
-           break;
-       case 1:
-           rendset = 1, rendstyle = RS_Bold;
-           break;
-       case 4:
-           rendset = 1, rendstyle = RS_Uline;
-           break;
-       case 5:
-           rendset = 1, rendstyle = RS_Blink;
-           break;
-       case 7:
-           rendset = 1, rendstyle = RS_RVid;
-           break;
-       case 22:
-           rendset = 0, rendstyle = RS_Bold;
-           break;
-       case 24:
-           rendset = 0, rendstyle = RS_Uline;
-           break;
-       case 25:
-           rendset = 0, rendstyle = RS_Blink;
-           break;
-       case 27:
-           rendset = 0, rendstyle = RS_RVid;
-           break;
-       }
-       if (rendset != -1) {
-           scr_rendition (rendset, rendstyle);
-           continue;           /* for(;i;) */
-       }
-
-       switch (arg[i]) {
-       case 30:
-       case 31:                /* set fg color */
-       case 32:
-       case 33:
-       case 34:
-       case 35:
-       case 36:
-       case 37:
-           scr_color ((unsigned int)(minCOLOR + (arg[i] - 30)),
-                          Color_fg);
-           break;
+  for (i = 0; i < nargs; i++)
+    {
+      rendset = -1;
+      switch (arg[i])
+        {
+          case 0:
+            rendset = 0, rendstyle = ~RS_None;
+            break;
+          case 1:
+            rendset = 1, rendstyle = RS_Bold;
+            break;
+          case 4:
+            rendset = 1, rendstyle = RS_Uline;
+            break;
+          case 5:
+            rendset = 1, rendstyle = RS_Blink;
+            break;
+          case 7:
+            rendset = 1, rendstyle = RS_RVid;
+            break;
+          case 22:
+            rendset = 0, rendstyle = RS_Bold;
+            break;
+          case 24:
+            rendset = 0, rendstyle = RS_Uline;
+            break;
+          case 25:
+            rendset = 0, rendstyle = RS_Blink;
+            break;
+          case 27:
+            rendset = 0, rendstyle = RS_RVid;
+            break;
+        }
+      if (rendset != -1)
+        {
+          scr_rendition (rendset, rendstyle);
+          continue;            /* for(;i;) */
+        }
+
+      switch (arg[i])
+        {
+          case 30:
+          case 31:             /* set fg color */
+          case 32:
+          case 33:
+          case 34:
+          case 35:
+          case 36:
+          case 37:
+            scr_color ((unsigned int)(minCOLOR + (arg[i] - 30)),
+                       Color_fg);
+            break;
 #ifdef TTY_256COLOR
-       case 38:
-           if (nargs > i + 2 && arg[i + 1] == 5) {
-               scr_color ((unsigned int)(minCOLOR + arg[i + 2]),
-                              Color_fg);
-               i += 2;
-           }
-           break;
-#endif
-       case 39:                /* default fg */
-           scr_color (Color_fg, Color_fg);
-           break;
-
-       case 40:
-       case 41:                /* set bg color */
-       case 42:
-       case 43:
-       case 44:
-       case 45:
-       case 46:
-       case 47:
-           scr_color ((unsigned int)(minCOLOR + (arg[i] - 40)),
-                          Color_bg);
-           break;
+          case 38:
+            if (nargs > i + 2 && arg[i + 1] == 5)
+              {
+                scr_color ((unsigned int)(minCOLOR + arg[i + 2]),
+                           Color_fg);
+                i += 2;
+              }
+            break;
+#endif
+          case 39:             /* default fg */
+            scr_color (Color_fg, Color_fg);
+            break;
+
+          case 40:
+          case 41:             /* set bg color */
+          case 42:
+          case 43:
+          case 44:
+          case 45:
+          case 46:
+          case 47:
+            scr_color ((unsigned int)(minCOLOR + (arg[i] - 40)),
+                       Color_bg);
+            break;
 #ifdef TTY_256COLOR
-       case 48:
-           if (nargs > i + 2 && arg[i + 1] == 5) {
-               scr_color ((unsigned int)(minCOLOR + arg[i + 2]),
-                              Color_bg);
-               i += 2;
-           }
-           break;
-#endif
-       case 49:                /* default bg */
-           scr_color (Color_bg, Color_bg);
-           break;
+          case 48:
+            if (nargs > i + 2 && arg[i + 1] == 5)
+              {
+                scr_color ((unsigned int)(minCOLOR + arg[i + 2]),
+                           Color_bg);
+                i += 2;
+              }
+            break;
+#endif
+          case 49:             /* default bg */
+            scr_color (Color_bg, Color_bg);
+            break;
 
 #ifndef NO_BRIGHTCOLOR
-       case 90:
-       case 91:                /* set bright fg color */
-       case 92:
-       case 93:
-       case 94:
-       case 95:
-       case 96:
-       case 97:
-           scr_color ((unsigned int)(minBrightCOLOR + (arg[i] - 90)),
-                          Color_fg);
-           break;
-       case 100:
-       case 101:               /* set bright bg color */
-       case 102:
-       case 103:
-       case 104:
-       case 105:
-       case 106:
-       case 107:
-           scr_color ((unsigned int)(minBrightCOLOR + (arg[i] - 100)),
-                          Color_bg);
-           break;
-#endif
-       }
+          case 90:
+          case 91:             /* set bright fg color */
+          case 92:
+          case 93:
+          case 94:
+          case 95:
+          case 96:
+          case 97:
+            scr_color ((unsigned int)(minBrightCOLOR + (arg[i] - 90)),
+                       Color_fg);
+            break;
+          case 100:
+          case 101:            /* set bright bg color */
+          case 102:
+          case 103:
+          case 104:
+          case 105:
+          case 106:
+          case 107:
+            scr_color ((unsigned int)(minBrightCOLOR + (arg[i] - 100)),
+                       Color_bg);
+            break;
+#endif
+
+        }
     }
 }
 /*}}} */
@@ -3314,57 +3468,62 @@ rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg)
 void
 rxvt_term::process_graphics ()
 {
-    unsigned char   ch, cmd = cmd_getc ();
+  unsigned char   ch, cmd = cmd_getc ();
 
 #ifndef RXVT_GRAPHICS
-    if (cmd == 'Q') {          /* query graphics */
-       tt_printf("\033G0\n");  /* no graphics */
-       return;
+  if (cmd == 'Q')
+    {          /* query graphics */
+      tt_printf("\033G0\n");   /* no graphics */
+      return;
     }
-/* swallow other graphics sequences until terminating ':' */
-    do
-       ch = cmd_getc ();
-    while (ch != ':');
+  /* swallow other graphics sequences until terminating ':' */
+  do
+    ch = cmd_getc ();
+  while (ch != ':');
 #else
-    unsigned int    nargs;
-    int             args[NGRX_PTS];
-    unsigned char  *text = NULL;
-
-    if (cmd == 'Q') {          /* query graphics */
-       tt_printf("\033G1\n");  /* yes, graphics (color) */
-       return;
+  unsigned int    nargs;
+  int             args[NGRX_PTS];
+  unsigned char  *text = NULL;
+
+  if (cmd == 'Q')
+    {          /* query graphics */
+      tt_printf("\033G1\n");   /* yes, graphics (color) */
+      return;
     }
-    for (nargs = 0; nargs < (sizeof(args) / sizeof(args[0])) - 1;) {
-       int             neg;
-
-       ch = cmd_getc ();
-       neg = (ch == '-');
-       if (neg || ch == '+')
-           ch = cmd_getc ();
-
-       for (args[nargs] = 0; isdigit(ch); ch = cmd_getc ())
-           args[nargs] = args[nargs] * 10 + (ch - '0');
-       if (neg)
-           args[nargs] = -args[nargs];
-
-       nargs++;
-       args[nargs] = 0;
-       if (ch != ';')
-           break;
+  for (nargs = 0; nargs < (sizeof(args) / sizeof(args[0])) - 1;)
+    {
+      int             neg;
+
+      ch = cmd_getc ();
+      neg = (ch == '-');
+      if (neg || ch == '+')
+        ch = cmd_getc ();
+
+      for (args[nargs] = 0; isdigit(ch); ch = cmd_getc ())
+        args[nargs] = args[nargs] * 10 + (ch - '0');
+      if (neg)
+        args[nargs] = -args[nargs];
+
+      nargs++;
+      args[nargs] = 0;
+      if (ch != ';')
+        break;
     }
 
-    if ((cmd == 'T') && (nargs >= 5)) {
-       int             i, len = args[4];
+  if ((cmd == 'T') && (nargs >= 5))
+    {
+      int             i, len = args[4];
 
-       text = (unsigned char *)rxvt_malloc((len + 1) * sizeof(char));
+      text = (unsigned char *)rxvt_malloc((len + 1) * sizeof(char));
 
-       if (text != NULL) {
-           for (i = 0; i < len; i++)
-               text[i] = cmd_getc ();
-           text[len] = '\0';
-       }
+      if (text != NULL)
+        {
+          for (i = 0; i < len; i++)
+            text[i] = cmd_getc ();
+          text[len] = '\0';
+        }
     }
-    Gr_do_graphics (cmd, nargs, args, text);
+  Gr_do_graphics (cmd, nargs, args, text);
 #endif
 }
 /*}}} */
index 6e59ece..3422a84 100644 (file)
@@ -84,35 +84,43 @@ typedef unsigned char u_char;
 typedef unsigned int u_int;
 typedef unsigned long u_long;
 
-typedef struct s_xlat {
+typedef struct s_xlat
+  {
     u_int           first, last;
     u_int          *pval;      /* array of translated values */
-} K_XLAT;
+  }
+K_XLAT;
 
-typedef struct s_switch {
+typedef struct s_switch
+  {
     u_char          type;      /* Ascii, Virtual, Scan */
     u_int           code;
     u_char          nextstate;
     u_char          on;                /* current state of key: 0 = off */
-} K_SWITCH;
+  }
+K_SWITCH;
 
-typedef struct s_state {
+typedef struct s_state
+  {
     u_int           num_xlat;  /* number of translations */
     K_XLAT         *xlat;      /* State translations ((dynamic - realloc'ed) */
     u_int           num_switcher;      /* number of switcher keys */
     K_SWITCH        switcher[MAX_SWITCHER];    /* switcher keys to other states */
     u_char          life;      /* 0 = until switched by key */
     u_char          prev_state;        /* filled when jumped to a new state */
-} K_STATE;
+  }
+K_STATE;
 
 /* type for each one of the different greek standards (xlat types) */
-typedef struct s_xlat_type {
+typedef struct s_xlat_type
+  {
     char           *plain;
     char           *accent;
     char           *accent_xtra;
     char           *umlaut;
     char           *acc_uml;
-} XLAT_TYPE;
+  }
+XLAT_TYPE;
 
 /* --- Local Data ------------ */
 static K_STATE  State[MAX_STATES];
@@ -148,10 +156,10 @@ static char     i437_xlat_umacc[] = "65-122:128,129,150,131,132,148,130,134,136,
  * (not recommended: stick to just these 2 if not only the ELOT one)
  */
 static XLAT_TYPE xlat_type[] =
-{
+  {
     {elot_xlat_plain, elot_xlat_acc, elot_xlat_acc_xtra, elot_xlat_uml, elot_xlat_umacc},
     {i437_xlat_plain, i437_xlat_acc, i437_xlat_acc_xtra, i437_xlat_uml, i437_xlat_umacc},
-};
+  };
 
 /* the current trasnaltion type */
 static XLAT_TYPE *xlat_now = &xlat_type[GREEK_ELOT928];
@@ -166,34 +174,34 @@ static void     kstate_set_life(char *str);
 void
 kstate_setcurr(int stateno)
 {
-    u_char          prev_state;
-
-    if ((u_int) stateno > (u_int) MAX_STATES)
-       return;
-    if (pStateNow->life == 1)
-       prev_state = pStateNow->prev_state;
-    else
-       prev_state = nStateNow;
-    pStateNow = &State[nStateNow = stateno];
-    pStateNow->prev_state = prev_state;
+  u_char          prev_state;
+
+  if ((u_int) stateno > (u_int) MAX_STATES)
+    return;
+  if (pStateNow->life == 1)
+    prev_state = pStateNow->prev_state;
+  else
+    prev_state = nStateNow;
+  pStateNow = &State[nStateNow = stateno];
+  pStateNow->prev_state = prev_state;
 }
 
 void
 kstate_init(void)
 {
-    pStateNow->num_xlat = pStateNow->num_switcher = pStateNow->life = pStateNow->prev_state = 0;
-    pStateNow->xlat = NULL;
+  pStateNow->num_xlat = pStateNow->num_switcher = pStateNow->life = pStateNow->prev_state = 0;
+  pStateNow->xlat = NULL;
 }
 
 void
 kstate_end(void)
 {
-    int             i;
+  int             i;
 
-    for (i = 0; i < pStateNow->num_xlat; i++)
-       free(pStateNow->xlat[i].pval);
-    if (pStateNow->num_xlat > 0)
-       free(pStateNow->xlat);
+  for (i = 0; i < pStateNow->num_xlat; i++)
+    free(pStateNow->xlat[i].pval);
+  if (pStateNow->num_xlat > 0)
+    free(pStateNow->xlat);
 }
 
 /*
@@ -203,48 +211,50 @@ kstate_end(void)
 void
 kstate_init_all(int greek_mode)
 {
-/* the translation tables for the 4 FSM states for ELOT-928 mappings */
-    int             i;
+  /* the translation tables for the 4 FSM states for ELOT-928 mappings */
+  int             i;
 
-    for (i = 0; i < MAX_STATES; i++) {
-       kstate_setcurr(i);
-       kstate_init();
+  for (i = 0; i < MAX_STATES; i++)
+    {
+      kstate_setcurr(i);
+      kstate_init();
     }
-    if (greek_mode < 0 || greek_mode >= NUM_XLAT_TYPES)                /* avoid death */
-       greek_mode = GREEK_ELOT928;
-    xlat_now = &xlat_type[greek_mode];
-    kstate_setcurr(0);
-    kstate_add_xlat(xlat_now->plain);
-    kstate_add_switcher("A;:1");
-    kstate_add_switcher("A::2");
-    kstate_set_life("L0");
-
-    kstate_setcurr(1);
-    kstate_add_xlat(xlat_now->accent);
-    kstate_add_xlat(xlat_now->accent_xtra);
-    kstate_add_switcher("A::3");
-    kstate_set_life("L1");
-
-    kstate_setcurr(2);
-    kstate_add_xlat(xlat_now->umlaut);
-    kstate_add_switcher("A;:3");
-    kstate_set_life("L1");
-
-    kstate_setcurr(3);
-    kstate_add_xlat(xlat_now->acc_uml);
-    kstate_set_life("L1");
+  if (greek_mode < 0 || greek_mode >= NUM_XLAT_TYPES)          /* avoid death */
+    greek_mode = GREEK_ELOT928;
+  xlat_now = &xlat_type[greek_mode];
+  kstate_setcurr(0);
+  kstate_add_xlat(xlat_now->plain);
+  kstate_add_switcher("A;:1");
+  kstate_add_switcher("A::2");
+  kstate_set_life("L0");
+
+  kstate_setcurr(1);
+  kstate_add_xlat(xlat_now->accent);
+  kstate_add_xlat(xlat_now->accent_xtra);
+  kstate_add_switcher("A::3");
+  kstate_set_life("L1");
+
+  kstate_setcurr(2);
+  kstate_add_xlat(xlat_now->umlaut);
+  kstate_add_switcher("A;:3");
+  kstate_set_life("L1");
+
+  kstate_setcurr(3);
+  kstate_add_xlat(xlat_now->acc_uml);
+  kstate_set_life("L1");
 }
 
 void
 kstate_end_all(void)
 {
-    int             i;
+  int             i;
 
-    for (i = 0; i < MAX_STATES; i++) {
-       kstate_setcurr(i);
-       kstate_end();
+  for (i = 0; i < MAX_STATES; i++)
+    {
+      kstate_setcurr(i);
+      kstate_end();
     }
-    kstate_setcurr(0);
+  kstate_setcurr(0);
 }
 
 /*
@@ -253,37 +263,39 @@ kstate_end_all(void)
 void
 kstate_reset(void)
 {
-    kstate_setcurr(0);
+  kstate_setcurr(0);
 }
 
 void
 kstate_add_xlat(char *str)
 {
-    K_XLAT         *xlat;
-    u_int          *pval_tmp;
-    char           *sval;
-    int             i;
-
-    if (str == NULL)
-       return;
-/* add a new xlat table in state */
-    if (pStateNow->num_xlat == 0) {
-       pStateNow->xlat = malloc(sizeof(K_XLAT));
-    } else                     /* prefer contiguous data, realloc */
-       pStateNow->xlat = realloc(pStateNow->xlat, (pStateNow->num_xlat + 1) * sizeof(K_XLAT));
-    xlat = &pStateNow->xlat[pStateNow->num_xlat];
-/* parse str and derive first, last, values */
-    xlat->first = (u_int) atoi(strtok(str, "-"));
-    xlat->last = (u_int) atoi(strtok(NULL, ":"));
-    i = 0;
-    pval_tmp = calloc(MAX_VAL, sizeof(K_XLAT));
-    while ((sval = strtok(NULL, ",")) != NULL)
-       pval_tmp[i++] = (u_int) (atoi(sval));
-    xlat->pval = calloc(i, sizeof(K_XLAT));
-    if (xlat->pval != NULL)
-       memcpy(xlat->pval, pval_tmp, i * sizeof(u_int));
-    free(pval_tmp);
-    pStateNow->num_xlat++;
+  K_XLAT         *xlat;
+  u_int          *pval_tmp;
+  char           *sval;
+  int             i;
+
+  if (str == NULL)
+    return;
+  /* add a new xlat table in state */
+  if (pStateNow->num_xlat == 0)
+    {
+      pStateNow->xlat = malloc(sizeof(K_XLAT));
+    }
+  else                 /* prefer contiguous data, realloc */
+    pStateNow->xlat = realloc(pStateNow->xlat, (pStateNow->num_xlat + 1) * sizeof(K_XLAT));
+  xlat = &pStateNow->xlat[pStateNow->num_xlat];
+  /* parse str and derive first, last, values */
+  xlat->first = (u_int) atoi(strtok(str, "-"));
+  xlat->last = (u_int) atoi(strtok(NULL, ":"));
+  i = 0;
+  pval_tmp = calloc(MAX_VAL, sizeof(K_XLAT));
+  while ((sval = strtok(NULL, ",")) != NULL)
+    pval_tmp[i++] = (u_int) (atoi(sval));
+  xlat->pval = calloc(i, sizeof(K_XLAT));
+  if (xlat->pval != NULL)
+    memcpy(xlat->pval, pval_tmp, i * sizeof(u_int));
+  free(pval_tmp);
+  pStateNow->num_xlat++;
 }
 
 /*
@@ -292,84 +304,87 @@ kstate_add_xlat(char *str)
 void
 kstate_add_switcher(char *str)
 {
-    K_SWITCH       *switcher;
-
-    if (str == NULL)
-       return;
-    if (pStateNow->num_switcher >= MAX_SWITCHER)
-       return;
-    switcher = &pStateNow->switcher[pStateNow->num_switcher];
-    switch (switcher->type = str[0]) {
-    case 'A':                  /* ascii eg: A;:2 */
-       switcher->code = str[1];
-       switcher->nextstate = atoi(&str[3]);
-       break;
+  K_SWITCH       *switcher;
+
+  if (str == NULL)
+    return;
+  if (pStateNow->num_switcher >= MAX_SWITCHER)
+    return;
+  switcher = &pStateNow->switcher[pStateNow->num_switcher];
+  switch (switcher->type = str[0])
+    {
+      case 'A':                        /* ascii eg: A;:2 */
+        switcher->code = str[1];
+        switcher->nextstate = atoi(&str[3]);
+        break;
     }
-    switcher->on = 0;
-    pStateNow->num_switcher++;
+  switcher->on = 0;
+  pStateNow->num_switcher++;
 }
 
 /* L1 or L0 */
 void
 kstate_set_life(char *str)
 {
-    pStateNow->life = atoi(&str[1]);
+  pStateNow->life = atoi(&str[1]);
 }
 
 unsigned int
 kstate_cxlat(unsigned int c)
 {
-    int             i;
-
-/* check for ascii switcher */
-    for (i = 0; i < pStateNow->num_switcher; i++)
-       if (pStateNow->switcher[i].type == 'A' &&       /* only ascii here */
-           c == pStateNow->switcher[i].code) {
-           kstate_setcurr(pStateNow->switcher[i].nextstate);
-           pStateNow->switcher[i].on = 1;
-           return ((unsigned int)-1);
-       }
-/* do translation */
-    for (i = 0; i < pStateNow->num_xlat; i++)
-       if (c >= pStateNow->xlat[i].first && c <= pStateNow->xlat[i].last) {
-           c = pStateNow->xlat[i].pval[c - pStateNow->xlat[i].first];
-           break;
-       }
-/* switch back to previous state if life of current is 1 */
-    if (pStateNow->life == 1)
-       kstate_setcurr(pStateNow->prev_state);
-    return (c);
+  int             i;
+
+  /* check for ascii switcher */
+  for (i = 0; i < pStateNow->num_switcher; i++)
+    if (pStateNow->switcher[i].type == 'A' &&  /* only ascii here */
+        c == pStateNow->switcher[i].code)
+      {
+        kstate_setcurr(pStateNow->switcher[i].nextstate);
+        pStateNow->switcher[i].on = 1;
+        return ((unsigned int)-1);
+      }
+  /* do translation */
+  for (i = 0; i < pStateNow->num_xlat; i++)
+    if (c >= pStateNow->xlat[i].first && c <= pStateNow->xlat[i].last)
+      {
+        c = pStateNow->xlat[i].pval[c - pStateNow->xlat[i].first];
+        break;
+      }
+  /* switch back to previous state if life of current is 1 */
+  if (pStateNow->life == 1)
+    kstate_setcurr(pStateNow->prev_state);
+  return (c);
 }
 
 #ifdef RXVT
 void
 greek_init(void)
 {
-    kstate_init_all(GreekMode);
+  kstate_init_all(GreekMode);
 }
 
 void
 greek_end(void)
 {
-    kstate_end_all();
+  kstate_end_all();
 }
 
 void
 greek_reset(void)
 {
-    kstate_reset();
+  kstate_reset();
 }
 
 void
 greek_setmode(int greek_mode)
 {
-    GreekMode = greek_mode;
+  GreekMode = greek_mode;
 }
 
 int
 greek_getmode(void)
 {
-    return (GreekMode);
+  return (GreekMode);
 }
 
 /*
@@ -378,16 +393,17 @@ greek_getmode(void)
 int
 greek_xlat(char *s, int num_chars)
 {
-    int             i, count;
-    unsigned int    c;
-
-    for (i = 0, count = 0; i < num_chars; i++) {
-       c = kstate_cxlat((unsigned int)s[i]);
-       if (c != -1)
-           s[count++] = (char)c;
+  int             i, count;
+  unsigned int    c;
+
+  for (i = 0, count = 0; i < num_chars; i++)
+    {
+      c = kstate_cxlat((unsigned int)s[i]);
+      if (c != -1)
+        s[count++] = (char)c;
     }
-    s[count] = '\0';
-    return (count);
+  s[count] = '\0';
+  return (count);
 
 }
 
@@ -395,15 +411,15 @@ greek_xlat(char *s, int num_chars)
 int
 main(void)
 {
-/*char text[] = "abcdef;aGDZXC"; */
-    char            text[] = "abcdef;a:ibgdezhuiklmnjoprstyfxcv";
-
-    kstate_init_all(GREEK_ELOT928);
-    printf("text: %s\n", text);
-    greek_xlat(text, strlen(text));
-    printf("xlat'ed text: %s\n", text);
-    kstate_end_all();
-    return 0;
+  /*char text[] = "abcdef;aGDZXC"; */
+  char            text[] = "abcdef;a:ibgdezhuiklmnjoprstyfxcv";
+
+  kstate_init_all(GREEK_ELOT928);
+  printf("text: %s\n", text);
+  greek_xlat(text, strlen(text));
+  printf("xlat'ed text: %s\n", text);
+  kstate_end_all();
+  return 0;
 }
 #endif
 #endif                         /* RXVT */
index 153a9f8..7cdbb8d 100644 (file)
@@ -328,6 +328,7 @@ const char *const def_colorName[] =
     COLOR_SCROLLBAR,
     COLOR_SCROLLTROUGH,
 #endif                          /* KEEP_SCROLLCOLOR */
+
   };
 
 const char *const xa_names[NUM_XA] =
@@ -446,6 +447,7 @@ rxvt_term::init_secondary ()
     }
   else
 #endif                          /* TTY_GID_SUPPORT */
+
     {
       ttymode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH;
       ttygid = getgid ();
@@ -659,11 +661,12 @@ rxvt_term::init_resources (int argc, const char *const *argv)
       else if (STRNCASECMP(rs[Rs_selectstyle], "old", 3) == 0)
         selection_style = OLD_SELECT;
 #endif
+
     }
 
 #ifdef HAVE_SCROLLBARS
   setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle],
-                        rs[Rs_scrollBar_thickness]);
+                   rs[Rs_scrollBar_thickness]);
 #endif
 
   TermWin.fontset = new rxvt_fontset (this);
@@ -807,7 +810,7 @@ rxvt_term::set_locale (const char *locale)
   free (codeset);
   codeset = strdup (nl_langinfo (CODESET));
   enc_utf8 = !STRCASECMP (codeset, "UTF-8")
-          || !STRCASECMP (codeset, "UTF8");
+             || !STRCASECMP (codeset, "UTF8");
 #else
   enc_utf8 = 1;
 #endif
@@ -947,24 +950,24 @@ rxvt_term::Get_Colours ()
             {
               switch (i)
                 {
-                case Color_fg:
-                case Color_bg:
-                  /* fatal: need bg/fg color */
-                  rxvt_print_error ("aborting");
-                  exit (EXIT_FAILURE);
-                  /* NOTREACHED */
-                  break;
+                  case Color_fg:
+                  case Color_bg:
+                    /* fatal: need bg/fg color */
+                    rxvt_print_error ("aborting");
+                    exit (EXIT_FAILURE);
+                    /* NOTREACHED */
+                    break;
 #ifndef NO_CURSORCOLOR
-                case Color_cursor2:
-                  xcol = PixColors[Color_fg];
-                  break;
+                  case Color_cursor2:
+                    xcol = PixColors[Color_fg];
+                    break;
 #endif                          /* ! NO_CURSORCOLOR */
-                case Color_pointer:
-                  xcol = PixColors[Color_fg];
-                  break;
-                default:
-                  xcol = PixColors[Color_bg];      /* None */
-                  break;
+                  case Color_pointer:
+                    xcol = PixColors[Color_fg];
+                    break;
+                  default:
+                    xcol = PixColors[Color_bg];      /* None */
+                    break;
                 }
             }
         }
@@ -1046,6 +1049,7 @@ rxvt_term::color_aliases(int idx)
           rs[Rs_color + idx] = rs[Rs_color + minBrightCOLOR + i];
           return;
 #endif
+
         }
 
       if (i >= 0 && i <= 7)   /* normal colors */
@@ -1088,29 +1092,29 @@ rxvt_term::get_ourmods ()
             break;
           switch (XKeycodeToKeysym(Xdisplay, kc[k], 0))
             {
-            case XK_Num_Lock:
-              ModNumLockMask = modmasks[i - 1];
-              /* FALLTHROUGH */
-            default:
-              continue;       /* for(;;) */
-            case XK_Meta_L:
-            case XK_Meta_R:
-              cm = "meta";
-              realmeta = i;
-              break;
-            case XK_Alt_L:
-            case XK_Alt_R:
-              cm = "alt";
-              realalt = i;
-              break;
-            case XK_Super_L:
-            case XK_Super_R:
-              cm = "super";
-              break;
-            case XK_Hyper_L:
-            case XK_Hyper_R:
-              cm = "hyper";
-              break;
+              case XK_Num_Lock:
+                ModNumLockMask = modmasks[i - 1];
+                /* FALLTHROUGH */
+              default:
+                continue;       /* for(;;) */
+              case XK_Meta_L:
+              case XK_Meta_R:
+                cm = "meta";
+                realmeta = i;
+                break;
+              case XK_Alt_L:
+              case XK_Alt_R:
+                cm = "alt";
+                realalt = i;
+                break;
+              case XK_Super_L:
+              case XK_Super_R:
+                cm = "super";
+                break;
+              case XK_Hyper_L:
+              case XK_Hyper_R:
+                cm = "hyper";
+                break;
             }
           if (rsmod && STRNCASECMP(rsmod, cm, STRLEN(cm)) == 0)
             requestedmeta = i;
@@ -1166,6 +1170,7 @@ rxvt_term::create_windows (int argc, const char *const *argv)
             }
         }
 #endif
+
     }
 
   /* grab colors before netscape does */
@@ -1187,21 +1192,21 @@ rxvt_term::create_windows (int argc, const char *const *argv)
   attributes.border_pixel = PixColors[Color_border];
   attributes.colormap = Xcmap;
   TermWin.parent[0] = XCreateWindow (Xdisplay, DefaultRootWindow (Xdisplay),
-                                       szHint.x, szHint.y,
-                                       szHint.width, szHint.height,
-                                       TermWin.ext_bwidth,
-                                       Xdepth, InputOutput,
-                                       Xvisual,
-                                       CWBackPixel | CWBorderPixel
-                                       | CWColormap, &attributes);
+                                     szHint.x, szHint.y,
+                                     szHint.width, szHint.height,
+                                     TermWin.ext_bwidth,
+                                     Xdepth, InputOutput,
+                                     Xvisual,
+                                     CWBackPixel | CWBorderPixel
+                                     | CWColormap, &attributes);
 #else
   TermWin.parent[0] = XCreateSimpleWindow (Xdisplay, DefaultRootWindow (Xdisplay),
-                         szHint.x, szHint.y,
-                         szHint.width,
-                         szHint.height,
-                         TermWin.ext_bwidth,
-                         PixColors[Color_border],
-                         PixColors[Color_fg]);
+                      szHint.x, szHint.y,
+                      szHint.width,
+                      szHint.height,
+                      TermWin.ext_bwidth,
+                      PixColors[Color_border],
+                      PixColors[Color_fg]);
 #endif
 
   xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST);
@@ -1243,19 +1248,19 @@ rxvt_term::create_windows (int argc, const char *const *argv)
     blackcolour.blue  = 0;
     Font f = XLoadFont (Xdisplay, "fixed");
     blank_cursor = XCreateGlyphCursor (Xdisplay, f, f, ' ', ' ',
-                                          &blackcolour, &blackcolour);
+                                       &blackcolour, &blackcolour);
     XUnloadFont (Xdisplay, f);
   }
 #endif
 
   /* the vt window */
   TermWin.vt = XCreateSimpleWindow(Xdisplay, TermWin.parent[0],
-                                      window_vt_x, window_vt_y,
-                                      TermWin_TotalWidth(),
-                                      TermWin_TotalHeight(),
-                                      0,
-                                      PixColors[Color_fg],
-                                      PixColors[Color_bg]);
+                                   window_vt_x, window_vt_y,
+                                   TermWin_TotalWidth(),
+                                   TermWin_TotalHeight(),
+                                   0,
+                                   PixColors[Color_fg],
+                                   PixColors[Color_bg]);
 #ifdef DEBUG_X
   XStoreName(Xdisplay, TermWin.vt, "vt window");
 #endif
@@ -1279,12 +1284,12 @@ rxvt_term::create_windows (int argc, const char *const *argv)
   if (menuBar_height())
     {
       menuBar.win = XCreateSimpleWindow(Xdisplay, TermWin.parent[0],
-                                           window_vt_x, 0,
-                                           TermWin_TotalWidth(),
-                                           menuBar_TotalHeight(),
-                                           0,
-                                           PixColors[Color_fg],
-                                           PixColors[Color_scroll]);
+                                        window_vt_x, 0,
+                                        TermWin_TotalWidth(),
+                                        menuBar_TotalHeight(),
+                                        0,
+                                        PixColors[Color_fg],
+                                        PixColors[Color_scroll]);
 #ifdef DEBUG_X
 
       XStoreName(Xdisplay, menuBar.win, "menubar");
@@ -1317,21 +1322,21 @@ rxvt_term::create_windows (int argc, const char *const *argv)
   gcvalue.background = PixColors[Color_bg];
   gcvalue.graphics_exposures = 1;
   TermWin.gc = XCreateGC(Xdisplay, TermWin.vt,
-                            GCForeground | GCBackground
-                            | GCGraphicsExposures, &gcvalue);
+                         GCForeground | GCBackground
+                         | GCGraphicsExposures, &gcvalue);
 
 #if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
 
   gcvalue.foreground = PixColors[Color_topShadow];
   topShadowGC = XCreateGC(Xdisplay, TermWin.vt,
-                             GCForeground, &gcvalue);
+                          GCForeground, &gcvalue);
   gcvalue.foreground = PixColors[Color_bottomShadow];
   botShadowGC = XCreateGC(Xdisplay, TermWin.vt,
-                             GCForeground, &gcvalue);
+                          GCForeground, &gcvalue);
   gcvalue.foreground = PixColors[(XDEPTH <= 2 ? Color_fg
-                                     : Color_scroll)];
+                                  : Color_scroll)];
   scrollbarGC = XCreateGC(Xdisplay, TermWin.vt,
-                             GCForeground, &gcvalue);
+                          GCForeground, &gcvalue);
 #endif
 }
 
@@ -1394,50 +1399,50 @@ rxvt_term::run_command (const char *const *argv)
   /* spin off the command interpreter */
   switch (cmd_pid = fork ())
     {
-    case -1:
-      rxvt_print_error("can't fork");
-      return -1;
-    case 0:
-      close (cfd);             /* only keep tty_fd and STDERR open */
-      close (Xfd);
-      if (rxvt_control_tty (tty_fd, ttydev) < 0)
-        rxvt_print_error ("could not obtain control of tty");
-      else
+      case -1:
+        rxvt_print_error("can't fork");
+        return -1;
+      case 0:
+        close (cfd);             /* only keep tty_fd and STDERR open */
+        close (Xfd);
+        if (rxvt_control_tty (tty_fd, ttydev) < 0)
+          rxvt_print_error ("could not obtain control of tty");
+        else
+          {
+            /* Reopen stdin, stdout and stderr over the tty file descriptor */
+            dup2 (tty_fd, STDIN_FILENO);
+            dup2 (tty_fd, STDOUT_FILENO);
+            dup2 (tty_fd, STDERR_FILENO);
+
+            if (tty_fd > 2)
+              close (tty_fd);
+
+            run_child (argv);
+          }
+        exit (EXIT_FAILURE);
+        /* NOTREACHED */
+      default:
         {
-          /* Reopen stdin, stdout and stderr over the tty file descriptor */
-          dup2 (tty_fd, STDIN_FILENO);
-          dup2 (tty_fd, STDOUT_FILENO);
-          dup2 (tty_fd, STDERR_FILENO);
-
-          if (tty_fd > 2)
-            close (tty_fd);
-
-          run_child (argv);
-        }
-      exit (EXIT_FAILURE);
-      /* NOTREACHED */
-    default:
-      {
 #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
-        int fdstdin;
+          int fdstdin;
 
-        fdstdin = dup (STDIN_FILENO);
-        dup2 (tty_fd, STDIN_FILENO);
+          fdstdin = dup (STDIN_FILENO);
+          dup2 (tty_fd, STDIN_FILENO);
 #endif
 
 #ifdef UTMP_SUPPORT
-        privileged_utmp (SAVE);
+          privileged_utmp (SAVE);
 #endif
 
 #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
 
-        dup2 (fdstdin, STDIN_FILENO);
-        close (fdstdin);
+          dup2 (fdstdin, STDIN_FILENO);
+          close (fdstdin);
 #endif
 
-      }
-      close (tty_fd);       /* keep STDERR_FILENO, cmd_fd, Xfd open */
-      break;
+        }
+        close (tty_fd);       /* keep STDERR_FILENO, cmd_fd, Xfd open */
+        break;
     }
 #else                           /* __QNX__ uses qnxspawn() */
   fchmod (tty_fd, 0622);
@@ -1481,6 +1486,7 @@ rxvt_term::run_child (const char *const *argv)
             close (fd);
         }
 #endif                          /* SRIOCSREDIR */
+
     }
 
   /* reset signals and spin off the command interpreter */
@@ -1585,8 +1591,8 @@ rxvt_term::run_child (const char *const *argv)
     }
   iov_a[0] = iov_a[1] = iov_a[2] = tty_fd;
   cmd_pid = qnx_spawn(0, 0, 0, -1, -1,
-                         _SPAWN_SETSID | _SPAWN_TCSETPGRP,
-                         command, arg_v, environ, iov_a, 0);
+                      _SPAWN_SETSID | _SPAWN_TCSETPGRP,
+                      command, arg_v, environ, iov_a, 0);
   if (login)
     free(login);
 
index 2c74a8b..dd925c2 100644 (file)
--- a/src/iom.C
+++ b/src/iom.C
 // time watcher is _always_ valid, this gets rid of a lot
 // of null-pointer-checks
 // (must come _before_ iom is being defined)
-static struct tw0 : time_watcher {
-  void cb (time_watcher &w)
+static struct tw0 : time_watcher
   {
-    // should never get called
-    // reached end-of-time, or tstamp has a bogus definition,
-    // or compiler initilization order broken, or somethine else :)
-    abort ();
-  }
+    void cb (time_watcher &w)
+    {
+      // should never get called
+      // reached end-of-time, or tstamp has a bogus definition,
+      // or compiler initilization order broken, or somethine else :)
+      abort ();
+    }
 
-  tw0()
-  : time_watcher (this, &tw0::cb)
-  }
-tw0;
+    tw0()
+        : time_watcher (this, &tw0::cb)
+    { }}
+tw0;
 
 tstamp NOW;
 static bool iom_valid;
@@ -101,7 +102,7 @@ void io_manager::unreg (time_watcher *w) { unreg (w, tw); }
 #endif
 
 #if IOM_IO
-void io_manager::reg (io_watcher *w) { reg (w, iow); } 
+void io_manager::reg (io_watcher *w) { reg (w, iow); }
 void io_manager::unreg (io_watcher *w) { unreg (w, iow); }
 #endif
 
@@ -146,6 +147,7 @@ void io_manager::loop ()
         }
       else
 #endif
+
         {
 #if IOM_TIME
           time_watcher *next;
@@ -178,6 +180,7 @@ void io_manager::loop ()
                 }
             }
 #endif
+
         }
 
 #if IOM_CHECK
@@ -259,6 +262,7 @@ void io_manager::loop ()
 #else
       break;
 #endif
+
     }
 }
 
index 7bfc8a7..3f4277c 100644 (file)
@@ -59,155 +59,162 @@ void
 rxvt_term::makeutent (const char *pty, const char *hostname)
 {
 #ifdef HAVE_STRUCT_UTMP
-    struct utmp    *ut = &(this->ut);
+  struct utmp    *ut = &(this->ut);
 #endif
 #ifdef HAVE_STRUCT_UTMPX
-    struct utmpx   *utx = &(this->utx);
+  struct utmpx   *utx = &(this->utx);
 #endif
 #ifdef HAVE_UTMP_PID
-    int             i;
+  int             i;
 #endif
-    char            ut_id[5];
-    struct passwd  *pwent = getpwuid(getuid());
+  char            ut_id[5];
+  struct passwd  *pwent = getpwuid(getuid());
 
-    if (!STRNCMP(pty, "/dev/", 5))
-       pty += 5;               /* skip /dev/ prefix */
+  if (!STRNCMP(pty, "/dev/", 5))
+    pty += 5;          /* skip /dev/ prefix */
 
-    if (!STRNCMP(pty, "pty", 3) || !STRNCMP(pty, "tty", 3)) {
-       STRNCPY(ut_id, (pty + 3), sizeof(ut_id));
+  if (!STRNCMP(pty, "pty", 3) || !STRNCMP(pty, "tty", 3))
+    {
+      STRNCPY(ut_id, (pty + 3), sizeof(ut_id));
     }
 #ifdef HAVE_UTMP_PID
-    else if (sscanf(pty, "pts/%d", &i) == 1)
-       sprintf(ut_id, "vt%02x", (i & 0xff));   /* sysv naming */
+  else if (sscanf(pty, "pts/%d", &i) == 1)
+    sprintf(ut_id, "vt%02x", (i & 0xff));      /* sysv naming */
 #endif
-    else if (STRNCMP(pty, "pty", 3) && STRNCMP(pty, "tty", 3)) {
-       rxvt_print_error("can't parse tty name \"%s\"", pty);
-       return;
+  else if (STRNCMP(pty, "pty", 3) && STRNCMP(pty, "tty", 3))
+    {
+      rxvt_print_error("can't parse tty name \"%s\"", pty);
+      return;
     }
 
 #ifdef HAVE_STRUCT_UTMP
-    MEMSET(ut, 0, sizeof(struct utmp));
+  MEMSET(ut, 0, sizeof(struct utmp));
 # ifdef HAVE_UTMP_PID
-    setutent();
-    STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
-    ut->ut_type = DEAD_PROCESS;
-    getutid(ut);               /* position to entry in utmp file */
-    STRNCPY(ut_id, ut_id, sizeof(ut_id));
+  setutent();
+  STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
+  ut->ut_type = DEAD_PROCESS;
+  getutid(ut);         /* position to entry in utmp file */
+  STRNCPY(ut_id, ut_id, sizeof(ut_id));
 # endif
 #endif
 
 #ifdef HAVE_STRUCT_UTMPX
-    MEMSET(utx, 0, sizeof(struct utmpx));
-    setutxent();
-    STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
-    utx->ut_type = DEAD_PROCESS;
-    getutxid(utx);             /* position to entry in utmp file */
-    STRNCPY(ut_id, ut_id, sizeof(ut_id));
+  MEMSET(utx, 0, sizeof(struct utmpx));
+  setutxent();
+  STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
+  utx->ut_type = DEAD_PROCESS;
+  getutxid(utx);               /* position to entry in utmp file */
+  STRNCPY(ut_id, ut_id, sizeof(ut_id));
 #endif
 
 #ifdef HAVE_STRUCT_UTMP
-    STRNCPY(ut->ut_line, pty, sizeof(ut->ut_line));
-    ut->ut_time = time(NULL);
+  STRNCPY(ut->ut_line, pty, sizeof(ut->ut_line));
+  ut->ut_time = time(NULL);
 # ifdef HAVE_UTMP_PID
-    STRNCPY(ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
-           sizeof(ut->ut_user));
-    STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
-    ut->ut_time = time(NULL);
-    ut->ut_pid = cmd_pid;
+  STRNCPY(ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
+          sizeof(ut->ut_user));
+  STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
+  ut->ut_time = time(NULL);
+  ut->ut_pid = cmd_pid;
 #  ifdef HAVE_UTMP_HOST
-    STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
+  STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
 #  endif
-    ut->ut_type = USER_PROCESS;
-    pututline(ut);
-    endutent();                        /* close the file */
-    utmp_pos = 0;
+  ut->ut_type = USER_PROCESS;
+  pututline(ut);
+  endutent();                  /* close the file */
+  utmp_pos = 0;
 # else
-    STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
-           sizeof(ut->ut_name));
+  STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
+          sizeof(ut->ut_name));
 #  ifdef HAVE_UTMP_HOST
-    STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
+  STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
 #  endif
 # endif
 #endif
 
 #ifdef HAVE_STRUCT_UTMPX
-    STRNCPY(utx->ut_line, pty, sizeof(utx->ut_line));
-    STRNCPY(utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
-           sizeof(utx->ut_user));
-    STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
-    utx->ut_session = getsid(0);
-    utx->ut_tv.tv_sec = time(NULL);
-    utx->ut_tv.tv_usec = 0;
-    utx->ut_pid = cmd_pid;
+  STRNCPY(utx->ut_line, pty, sizeof(utx->ut_line));
+  STRNCPY(utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
+          sizeof(utx->ut_user));
+  STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
+  utx->ut_session = getsid(0);
+  utx->ut_tv.tv_sec = time(NULL);
+  utx->ut_tv.tv_usec = 0;
+  utx->ut_pid = cmd_pid;
 # ifdef HAVE_UTMPX_HOST
-    STRNCPY(utx->ut_host, hostname, sizeof(utx->ut_host));
+  STRNCPY(utx->ut_host, hostname, sizeof(utx->ut_host));
 #  if 0
-    {
-       char           *colon;
+  {
+    char           *colon;
 
-       if ((colon = STRRCHR(ut->ut_host, ':')) != NULL)
-           *colon = '\0';
-    }
+    if ((colon = STRRCHR(ut->ut_host, ':')) != NULL)
+      *colon = '\0';
+  }
 #  endif
 # endif
-    utx->ut_type = USER_PROCESS;
-    pututxline(utx);
-    endutxent();               /* close the file */
-    utmp_pos = 0;
+  utx->ut_type = USER_PROCESS;
+  pututxline(utx);
+  endutxent();         /* close the file */
+  utmp_pos = 0;
 #endif
 
 #if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID)
-    {
-       int             i;
+
+  {
+    int             i;
 # ifdef HAVE_TTYSLOT
-       i = ttyslot();
-       if (rxvt_write_bsd_utmp(i, ut))
-           utmp_pos = i;
+    i = ttyslot();
+    if (rxvt_write_bsd_utmp(i, ut))
+      utmp_pos = i;
 # else
-       FILE           *fd0;
-
-       if ((fd0 = fopen(TTYTAB_FILENAME, "r")) != NULL) {
-           char            buf[256], name[256];
-
-           buf[sizeof(buf) - 1] = '\0';
-           for (i = 1; (fgets(buf, sizeof(buf) - 1, fd0) != NULL);) {
-               if (*buf == '#' || sscanf(buf, "%s", name) != 1)
-                   continue;
-               if (!STRCMP(ut->ut_line, name)) {
-                   if (!rxvt_write_bsd_utmp(i, ut))
-                       i = 0;
-                   utmp_pos = i;
-                   fclose(fd0);
-                   break;
-               }
-               i++;
-           }
-           fclose(fd0);
-       }
+    FILE           *fd0;
+
+    if ((fd0 = fopen(TTYTAB_FILENAME, "r")) != NULL)
+      {
+        char            buf[256], name[256];
+
+        buf[sizeof(buf) - 1] = '\0';
+        for (i = 1; (fgets(buf, sizeof(buf) - 1, fd0) != NULL);)
+          {
+            if (*buf == '#' || sscanf(buf, "%s", name) != 1)
+              continue;
+            if (!STRCMP(ut->ut_line, name))
+              {
+                if (!rxvt_write_bsd_utmp(i, ut))
+                  i = 0;
+                utmp_pos = i;
+                fclose(fd0);
+                break;
+              }
+            i++;
+          }
+        fclose(fd0);
+      }
 # endif
-    }
+
+  }
 #endif
 
 #ifdef WTMP_SUPPORT
 # ifdef WTMP_ONLY_ON_LOGIN
-    if (Options & Opt_loginShell)
+  if (Options & Opt_loginShell)
 # endif
     {
 # ifdef HAVE_STRUCT_UTMP
 #  ifdef HAVE_UPDWTMP
-       updwtmp(RXVT_WTMP_FILE, ut);
+      updwtmp(RXVT_WTMP_FILE, ut);
 #  else
-       rxvt_update_wtmp(RXVT_WTMP_FILE, ut);
+      rxvt_update_wtmp(RXVT_WTMP_FILE, ut);
 #  endif
 # endif
 # ifdef HAVE_STRUCT_UTMPX
-       updwtmpx(RXVT_WTMPX_FILE, utx);
+      updwtmpx(RXVT_WTMPX_FILE, utx);
 # endif
     }
 #endif
 #if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
-    if (Options & Opt_loginShell)
-       rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname);
+  if (Options & Opt_loginShell)
+    rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname);
 #endif
 }
 
@@ -219,85 +226,85 @@ void
 rxvt_term::cleanutent ()
 {
 #ifdef HAVE_STRUCT_UTMP
-    struct utmp    *ut = &(this->ut);
+  struct utmp    *ut = &(this->ut);
 #endif
 #ifdef HAVE_STRUCT_UTMPX
-    struct utmpx   *tmputx, *utx = &(this->utx);
+  struct utmpx   *tmputx, *utx = &(this->utx);
 #endif
 
 #ifdef HAVE_STRUCT_UTMP
 # ifdef HAVE_UTMP_PID
-    MEMSET(ut, 0, sizeof(struct utmp));
-    setutent();
-    STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
-    ut->ut_type = USER_PROCESS;
-    {
-       struct utmp    *tmput = getutid(ut);
-
-       if (tmput)              /* position to entry in utmp file */
-           ut = tmput;
-    }
-    ut->ut_type = DEAD_PROCESS;
-# else 
-    MEMSET(ut->ut_name, 0, sizeof(ut->ut_name));
+  MEMSET(ut, 0, sizeof(struct utmp));
+  setutent();
+  STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
+  ut->ut_type = USER_PROCESS;
+  {
+    struct utmp    *tmput = getutid(ut);
+
+    if (tmput)         /* position to entry in utmp file */
+      ut = tmput;
+  }
+  ut->ut_type = DEAD_PROCESS;
+# else
+  MEMSET(ut->ut_name, 0, sizeof(ut->ut_name));
 #  ifdef HAVE_UTMP_HOST
-    MEMSET(ut->ut_host, 0, sizeof(ut->ut_host));
+  MEMSET(ut->ut_host, 0, sizeof(ut->ut_host));
 #  endif
 # endif
-    ut->ut_time = time(NULL);
+  ut->ut_time = time(NULL);
 #endif
 
 #ifdef HAVE_STRUCT_UTMPX
-    MEMSET(utx, 0, sizeof(struct utmpx));
-    setutxent();
-    STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
-    utx->ut_type = USER_PROCESS;
-    if ((tmputx = getutxid(utx)))      /* position to entry in utmp file */
-       utx = tmputx;
-    utx->ut_type = DEAD_PROCESS;
-    utx->ut_session = getsid(0);
-    utx->ut_tv.tv_sec = time(NULL);
-    utx->ut_tv.tv_usec = 0;
+  MEMSET(utx, 0, sizeof(struct utmpx));
+  setutxent();
+  STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
+  utx->ut_type = USER_PROCESS;
+  if ((tmputx = getutxid(utx)))        /* position to entry in utmp file */
+    utx = tmputx;
+  utx->ut_type = DEAD_PROCESS;
+  utx->ut_session = getsid(0);
+  utx->ut_tv.tv_sec = time(NULL);
+  utx->ut_tv.tv_usec = 0;
 #endif
 
-    /*
-     * Write ending wtmp entry
-     */
+  /*
+   * Write ending wtmp entry
+   */
 #ifdef WTMP_SUPPORT
 # ifdef WTMP_ONLY_ON_LOGIN
-    if (Options & Opt_loginShell)
+  if (Options & Opt_loginShell)
 # endif
     {
 # ifdef HAVE_STRUCT_UTMP
 #  ifdef HAVE_UPDWTMP
-       updwtmp(RXVT_WTMP_FILE, ut);
+      updwtmp(RXVT_WTMP_FILE, ut);
 #  else
-       rxvt_update_wtmp(RXVT_WTMP_FILE, ut);
+      rxvt_update_wtmp(RXVT_WTMP_FILE, ut);
 #  endif
 # endif
 # ifdef HAVE_STRUCT_UTMPX
-       updwtmpx(RXVT_WTMPX_FILE, utx);
+      updwtmpx(RXVT_WTMPX_FILE, utx);
 # endif
     }
 #endif
 
-    /*
-     * Write utmp entry
-     */
+  /*
+   * Write utmp entry
+   */
 #ifdef HAVE_STRUCT_UTMP
 # ifdef HAVE_UTMP_PID
-    if (ut->ut_pid == cmd_pid)
-       pututline(ut);
-    endutent();
+  if (ut->ut_pid == cmd_pid)
+    pututline(ut);
+  endutent();
 # else
-    MEMSET(ut, 0, sizeof(struct utmp));
-    rxvt_write_bsd_utmp(utmp_pos, ut);
+  MEMSET(ut, 0, sizeof(struct utmp));
+  rxvt_write_bsd_utmp(utmp_pos, ut);
 # endif
 #endif
 #ifdef HAVE_STRUCT_UTMPX
-    if (utx->ut_pid == cmd_pid)
-       pututxline(utx);
-    endutxent();
+  if (utx->ut_pid == cmd_pid)
+    pututxline(utx);
+  endutxent();
 #endif
 }
 
@@ -310,15 +317,15 @@ rxvt_term::cleanutent ()
 int
 rxvt_write_bsd_utmp(int utmp_pos, struct utmp *wu)
 {
-    int             fd;
+  int             fd;
 
-    if (utmp_pos <= 0 || (fd = open(RXVT_UTMP_FILE, O_WRONLY)) == -1)
-       return 0;
+  if (utmp_pos <= 0 || (fd = open(RXVT_UTMP_FILE, O_WRONLY)) == -1)
+    return 0;
 
-    if (lseek(fd, (off_t) (utmp_pos * sizeof(struct utmp)), SEEK_SET) != -1)
-       write(fd, wu, sizeof(struct utmp));
-    close(fd);
-    return 1;
+  if (lseek(fd, (off_t) (utmp_pos * sizeof(struct utmp)), SEEK_SET) != -1)
+    write(fd, wu, sizeof(struct utmp));
+  close(fd);
+  return 1;
 }
 #endif
 
@@ -331,36 +338,39 @@ rxvt_write_bsd_utmp(int utmp_pos, struct utmp *wu)
 void
 rxvt_update_wtmp(const char *fname, const struct utmp *putmp)
 {
-    int             fd, gotlock, retry;
-    struct flock    lck;       /* fcntl locking scheme */
-    struct stat     sbuf;
-
-    if ((fd = open(fname, O_WRONLY | O_APPEND, 0)) < 0)
-       return;
-
-    lck.l_whence = SEEK_END;   /* start lock at current eof */
-    lck.l_len = 0;             /* end at ``largest possible eof'' */
-    lck.l_start = 0;
-    lck.l_type = F_WRLCK;      /* we want a write lock */
-
-    /* attempt lock with F_SETLK; F_SETLKW would cause a deadlock! */
-    for (retry = 10, gotlock = 0; retry--;)
-       if (fcntl(fd, F_SETLK, &lck) != -1) {
-           gotlock = 1;
-           break;
-       } else if (errno != EAGAIN && errno != EACCES)
-           break;
-    if (!gotlock) {            /* give it up */
-       close(fd);
-       return;
+  int             fd, gotlock, retry;
+  struct flock    lck; /* fcntl locking scheme */
+  struct stat     sbuf;
+
+  if ((fd = open(fname, O_WRONLY | O_APPEND, 0)) < 0)
+    return;
+
+  lck.l_whence = SEEK_END;     /* start lock at current eof */
+  lck.l_len = 0;               /* end at ``largest possible eof'' */
+  lck.l_start = 0;
+  lck.l_type = F_WRLCK;        /* we want a write lock */
+
+  /* attempt lock with F_SETLK; F_SETLKW would cause a deadlock! */
+  for (retry = 10, gotlock = 0; retry--;)
+    if (fcntl(fd, F_SETLK, &lck) != -1)
+      {
+        gotlock = 1;
+        break;
+      }
+    else if (errno != EAGAIN && errno != EACCES)
+      break;
+  if (!gotlock)
+    {          /* give it up */
+      close(fd);
+      return;
     }
-    if (fstat(fd, &sbuf) == 0)
-       if (write(fd, putmp, sizeof(struct utmp)) != sizeof(struct utmp))
-           ftruncate(fd, sbuf.st_size);        /* remove bad writes */
+  if (fstat(fd, &sbuf) == 0)
+    if (write(fd, putmp, sizeof(struct utmp)) != sizeof(struct utmp))
+      ftruncate(fd, sbuf.st_size);     /* remove bad writes */
 
-    lck.l_type = F_UNLCK;      /* unlocking the file */
-    fcntl(fd, F_SETLK, &lck);
-    close(fd);
+  lck.l_type = F_UNLCK;        /* unlocking the file */
+  fcntl(fd, F_SETLK, &lck);
+  close(fd);
 }
 #endif
 
@@ -371,52 +381,55 @@ void
 rxvt_update_lastlog(const char *fname, const char *pty, const char *host)
 {
 # ifdef HAVE_STRUCT_LASTLOGX
-    struct lastlogx llx;
+  struct lastlogx llx;
 # endif
 # ifdef HAVE_STRUCT_LASTLOG
-    int             fd;
-    struct lastlog  ll;
+  int             fd;
+  struct lastlog  ll;
 #  ifdef LASTLOG_IS_DIR
-    char            lastlogfile[256];
+  char            lastlogfile[256];
 #  endif
-    struct passwd  *pwent;
+  struct passwd  *pwent;
 # endif
 
 # ifdef HAVE_STRUCT_LASTLOGX
-    MEMSET(&llx, 0, sizeof(llx));
-    llx.ll_tv.tv_sec = time(NULL);
-    llx.ll_tv.tv_usec = 0;
-    STRNCPY(llx.ll_line, pty, sizeof(llx.ll_line));
-    STRNCPY(llx.ll_host, host, sizeof(llx.ll_host));
-    updlastlogx(RXVT_LASTLOGX_FILE, getuid(), &llx);
+  MEMSET(&llx, 0, sizeof(llx));
+  llx.ll_tv.tv_sec = time(NULL);
+  llx.ll_tv.tv_usec = 0;
+  STRNCPY(llx.ll_line, pty, sizeof(llx.ll_line));
+  STRNCPY(llx.ll_host, host, sizeof(llx.ll_host));
+  updlastlogx(RXVT_LASTLOGX_FILE, getuid(), &llx);
 # endif
 
 # ifdef HAVE_STRUCT_LASTLOG
-    pwent = getpwuid(getuid());
-    if (!pwent) {
-       rxvt_print_error("no entry in password file");
-       return;
+  pwent = getpwuid(getuid());
+  if (!pwent)
+    {
+      rxvt_print_error("no entry in password file");
+      return;
     }
-    MEMSET(&ll, 0, sizeof(ll));
-    ll.ll_time = time(NULL);
-    STRNCPY(ll.ll_line, pty, sizeof(ll.ll_line));
-    STRNCPY(ll.ll_host, host, sizeof(ll.ll_host));
+  MEMSET(&ll, 0, sizeof(ll));
+  ll.ll_time = time(NULL);
+  STRNCPY(ll.ll_line, pty, sizeof(ll.ll_line));
+  STRNCPY(ll.ll_host, host, sizeof(ll.ll_host));
 #  ifdef LASTLOG_IS_DIR
-    sprintf(lastlogfile, "%.*s/%.*s",
-           sizeof(lastlogfile) - sizeof(pwent->pw_name) - 2, fname,
-           sizeof(pwent->pw_name),
-           (!pwent->pw_name || pwent->pw_name[0] == '\0') ? "unknown"
-                                                          : pwent->pw_name);
-    if ((fd = open(lastlogfile, O_WRONLY | O_CREAT, 0644)) >= 0) {
-       write(fd, &ll, sizeof(ll));
-       close(fd);
+  sprintf(lastlogfile, "%.*s/%.*s",
+          sizeof(lastlogfile) - sizeof(pwent->pw_name) - 2, fname,
+          sizeof(pwent->pw_name),
+          (!pwent->pw_name || pwent->pw_name[0] == '\0') ? "unknown"
+          : pwent->pw_name);
+  if ((fd = open(lastlogfile, O_WRONLY | O_CREAT, 0644)) >= 0)
+    {
+      write(fd, &ll, sizeof(ll));
+      close(fd);
     }
 #  else
-    if ((fd = open(fname, O_RDWR)) != -1) {
-       if (lseek(fd, (off_t) ((long)pwent->pw_uid * sizeof(ll)),
-                 SEEK_SET) != -1)
-           write(fd, &ll, sizeof(ll));
-       close(fd);
+  if ((fd = open(fname, O_RDWR)) != -1)
+    {
+      if (lseek(fd, (off_t) ((long)pwent->pw_uid * sizeof(ll)),
+                SEEK_SET) != -1)
+        write(fd, &ll, sizeof(ll));
+      close(fd);
     }
 #  endif                       /* LASTLOG_IS_DIR */
 # endif                                /* HAVE_STRUCT_LASTLOG */
index 4f33659..7a5899e 100644 (file)
@@ -73,21 +73,21 @@ rxvt_term::operator delete (void *p, size_t s)
 }
 
 rxvt_term::rxvt_term ()
-:
+    :
 #ifdef CURSOR_BLINK
-  cursor_blink_ev (this, &rxvt_term::cursor_blink_cb),
+    cursor_blink_ev (this, &rxvt_term::cursor_blink_cb),
 #endif
 #ifdef TEXT_BLINK
-  text_blink_ev (this, &rxvt_term::text_blink_cb),
+    text_blink_ev (this, &rxvt_term::text_blink_cb),
 #endif
 #ifdef POINTER_BLANK
-  pointer_ev (this, &rxvt_term::pointer_cb),
+    pointer_ev (this, &rxvt_term::pointer_cb),
 #endif
-  check_ev (this, &rxvt_term::check_cb),
-  destroy_ev (this, &rxvt_term::destroy_cb),
-  pty_ev (this, &rxvt_term::pty_cb),
-  x_ev (this, &rxvt_term::x_cb),
-  incr_ev (this, &rxvt_term::incr_cb)
+    check_ev (this, &rxvt_term::check_cb),
+    destroy_ev (this, &rxvt_term::destroy_cb),
+    pty_ev (this, &rxvt_term::pty_cb),
+    x_ev (this, &rxvt_term::x_cb),
+    incr_ev (this, &rxvt_term::incr_cb)
 {
   cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
 }
@@ -169,7 +169,7 @@ rxvt_init (int argc, const char *const *argv)
 void
 rxvt_init_signals ()
 {
-/* install exit handler for cleanup */
+  /* install exit handler for cleanup */
 #if 0
 #ifdef HAVE_ATEXIT
   atexit(rxvt_clean_exit);
@@ -188,8 +188,8 @@ rxvt_init_signals ()
   sa.sa_handler = rxvt_Exit_signal;  sigaction (SIGTERM, &sa, 0);
   sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0);
 
-/* need to trap SIGURG for SVR4 (Unixware) rlogin */
-/* signal (SIGURG, SIG_DFL); */
+  /* need to trap SIGURG for SVR4 (Unixware) rlogin */
+  /* signal (SIGURG, SIG_DFL); */
 
   XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
   //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler);
@@ -279,14 +279,14 @@ rxvt_term::init (int argc, const char *const *argv)
 RETSIGTYPE
 rxvt_Child_signal(int sig __attribute__ ((unused)))
 {
-    int pid, save_errno = errno;
-    while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR)
-      ;
-    errno = save_errno;
+  int pid, save_errno = errno;
+  while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR)
+    ;
+  errno = save_errno;
 
 #if 0
-    if (pid == cmd_pid)
-        exit (EXIT_SUCCESS);
+  if (pid == cmd_pid)
+    exit (EXIT_SUCCESS);
 #endif
 }
 
@@ -297,12 +297,12 @@ rxvt_Child_signal(int sig __attribute__ ((unused)))
 RETSIGTYPE
 rxvt_Exit_signal(int sig)
 {
-    signal(sig, SIG_DFL);
+  signal(sig, SIG_DFL);
 #ifdef DEBUG_CMD
-    rxvt_print_error("signal %d", sig);
+  rxvt_print_error("signal %d", sig);
 #endif
-    rxvt_clean_exit();
-    kill(getpid(), sig);
+  rxvt_clean_exit();
+  kill(getpid(), sig);
 }
 
 /* ARGSUSED */
@@ -344,51 +344,51 @@ rxvt_clean_exit ()
 void           *
 rxvt_malloc(size_t size)
 {
-    void           *p;
+  void           *p;
 
-    p = malloc(size);
-    if (p)
-        return p;
+  p = malloc(size);
+  if (p)
+    return p;
 
-    fprintf(stderr, APL_NAME ": memory allocation failure.  Aborting");
-    rxvt_clean_exit();
-    exit(EXIT_FAILURE);
-/* NOTREACHED */
+  fprintf(stderr, APL_NAME ": memory allocation failure.  Aborting");
+  rxvt_clean_exit();
+  exit(EXIT_FAILURE);
+  /* NOTREACHED */
 }
 
 /* EXTPROTO */
 void           *
 rxvt_calloc(size_t number, size_t size)
 {
-    void           *p;
+  void           *p;
 
-    p = calloc(number, size);
-    if (p)
-        return p;
+  p = calloc(number, size);
+  if (p)
+    return p;
 
-    fprintf(stderr, APL_NAME ": memory allocation failure.  Aborting");
-    rxvt_clean_exit();
-    exit(EXIT_FAILURE);
-/* NOTREACHED */
+  fprintf(stderr, APL_NAME ": memory allocation failure.  Aborting");
+  rxvt_clean_exit();
+  exit(EXIT_FAILURE);
+  /* NOTREACHED */
 }
 
 /* EXTPROTO */
 void           *
 rxvt_realloc(void *ptr, size_t size)
 {
-    void           *p;
-
-    if (ptr)
-        p = realloc(ptr, size);
-    else
-        p = malloc(size);
-    if (p)
-        return p;
-
-    fprintf(stderr, APL_NAME ": memory allocation failure.  Aborting");
-    rxvt_clean_exit();
-    exit(EXIT_FAILURE);
-/* NOTREACHED */
+  void           *p;
+
+  if (ptr)
+    p = realloc(ptr, size);
+  else
+    p = malloc(size);
+  if (p)
+    return p;
+
+  fprintf(stderr, APL_NAME ": memory allocation failure.  Aborting");
+  rxvt_clean_exit();
+  exit(EXIT_FAILURE);
+  /* NOTREACHED */
 }
 
 /* ------------------------------------------------------------------------- *
@@ -400,39 +400,41 @@ rxvt_term::privileges (int mode)
 {
 #if ! defined(__CYGWIN32__)
 # if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
-/* setreuid() is the poor man's setuid(), seteuid() */
+  /* setreuid() is the poor man's setuid(), seteuid() */
 #  define seteuid(a)    setreuid(-1, (a))
 #  define setegid(a)    setregid(-1, (a))
 #  define HAVE_SETEUID
 # endif
 # ifdef HAVE_SETEUID
-    switch (mode) {
-    case IGNORE:
-    /*
-     * change effective uid/gid - not real uid/gid - so we can switch
-     * back to root later, as required
-     */
+  switch (mode)
+    {
+      case IGNORE:
+        /*
+         * change effective uid/gid - not real uid/gid - so we can switch
+         * back to root later, as required
+         */
         seteuid(getuid());
         setegid(getgid());
         break;
-    case SAVE:
+      case SAVE:
         euid = geteuid();
         egid = getegid();
         break;
-    case RESTORE:
+      case RESTORE:
         seteuid(euid);
         setegid(egid);
         break;
     }
 # else
-    switch (mode) {
-    case IGNORE:
+  switch (mode)
+    {
+      case IGNORE:
         setuid(getuid());
         setgid(getgid());
-    /* FALLTHROUGH */
-    case SAVE:
-    /* FALLTHROUGH */
-    case RESTORE:
+        /* FALLTHROUGH */
+      case SAVE:
+        /* FALLTHROUGH */
+      case RESTORE:
         break;
     }
 # endif
@@ -443,22 +445,25 @@ rxvt_term::privileges (int mode)
 void
 rxvt_term::privileged_utmp (char action)
 {
-    D_MAIN((stderr, "rxvt_privileged_utmp(%c); waiting for: %c (pid: %d)",
-            action, next_utmp_action, getpid()));
-    if (next_utmp_action != action || (action != SAVE && action != RESTORE)
-        || (Options & Opt_utmpInhibit)
-        || ttydev == NULL || *ttydev == '\0')
-        return;
-
-    privileges (RESTORE);
-    if (action == SAVE) {
-        next_utmp_action = RESTORE;
-        makeutent (ttydev, rs[Rs_display_name]);
-    } else {                    /* action == RESTORE */
-        next_utmp_action = IGNORE;
-        cleanutent ();
+  D_MAIN((stderr, "rxvt_privileged_utmp(%c); waiting for: %c (pid: %d)",
+          action, next_utmp_action, getpid()));
+  if (next_utmp_action != action || (action != SAVE && action != RESTORE)
+      || (Options & Opt_utmpInhibit)
+      || ttydev == NULL || *ttydev == '\0')
+    return;
+
+  privileges (RESTORE);
+  if (action == SAVE)
+    {
+      next_utmp_action = RESTORE;
+      makeutent (ttydev, rs[Rs_display_name]);
+    }
+  else
+    {                    /* action == RESTORE */
+      next_utmp_action = IGNORE;
+      cleanutent ();
     }
-    privileges (IGNORE);
+  privileges (IGNORE);
 }
 #endif
 
@@ -466,51 +471,57 @@ rxvt_term::privileged_utmp (char action)
 void
 rxvt_term::privileged_ttydev (char action)
 {
-    D_MAIN((stderr,
-            "privileged_ttydev (%c); waiting for: %c (pid: %d)",
-            action, next_tty_action, getpid()));
-    if (next_tty_action != action || (action != SAVE && action != RESTORE)
-        || ttydev == NULL || *ttydev == '\0')
-        return;
+  D_MAIN((stderr,
+          "privileged_ttydev (%c); waiting for: %c (pid: %d)",
+          action, next_tty_action, getpid()));
+  if (next_tty_action != action || (action != SAVE && action != RESTORE)
+      || ttydev == NULL || *ttydev == '\0')
+    return;
 
-    privileges (RESTORE);
+  privileges (RESTORE);
 
-    if (action == SAVE) {
-        next_tty_action = RESTORE;
+  if (action == SAVE)
+    {
+      next_tty_action = RESTORE;
 # ifndef RESET_TTY_TO_COMMON_DEFAULTS
-/* store original tty status for restoration rxvt_clean_exit() -- rgg 04/12/95 */
-        if (lstat(ttydev, &ttyfd_stat) < 0)       /* you lose out */
-            next_tty_action = IGNORE;
-        else
+      /* store original tty status for restoration rxvt_clean_exit() -- rgg 04/12/95 */
+      if (lstat(ttydev, &ttyfd_stat) < 0)       /* you lose out */
+        next_tty_action = IGNORE;
+      else
 # endif
+
         {
-            chown(ttydev, getuid(), ttygid);      /* fail silently */
-            chmod(ttydev, ttymode);
+          chown(ttydev, getuid(), ttygid);      /* fail silently */
+          chmod(ttydev, ttymode);
 # ifdef HAVE_REVOKE
-            revoke(ttydev);
+          revoke(ttydev);
 # endif
+
         }
-    } else {                    /* action == RESTORE */
-        next_tty_action = IGNORE;
+    }
+  else
+    {                    /* action == RESTORE */
+      next_tty_action = IGNORE;
 # ifndef RESET_TTY_TO_COMMON_DEFAULTS
-        chmod(ttydev, ttyfd_stat.st_mode);
-        chown(ttydev, ttyfd_stat.st_uid, ttyfd_stat.st_gid);
+      chmod(ttydev, ttyfd_stat.st_mode);
+      chown(ttydev, ttyfd_stat.st_uid, ttyfd_stat.st_gid);
 # else
-        chmod(ttydev,
-              (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
-        chown(ttydev, 0, 0);
+      chmod(ttydev,
+            (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
+      chown(ttydev, 0, 0);
 # endif
+
     }
 
-    privileges (IGNORE);
+  privileges (IGNORE);
 
 # ifndef RESET_TTY_TO_COMMON_DEFAULTS
-    D_MAIN((stderr, "%s \"%s\": mode %03o, uid %d, gid %d",
-            action == RESTORE ? "Restoring" : (action ==
-                                               SAVE ? "Saving" :
-                                               "UNKNOWN ERROR for"), ttydev,
-            ttyfd_stat.st_mode, ttyfd_stat.st_uid,
-            ttyfd_stat.st_gid));
+  D_MAIN((stderr, "%s \"%s\": mode %03o, uid %d, gid %d",
+          action == RESTORE ? "Restoring" : (action ==
+                                             SAVE ? "Saving" :
+                                             "UNKNOWN ERROR for"), ttydev,
+          ttyfd_stat.st_mode, ttyfd_stat.st_uid,
+          ttyfd_stat.st_gid));
 # endif
 }
 #endif
@@ -523,108 +534,123 @@ rxvt_term::privileged_ttydev (char action)
 void
 rxvt_term::window_calc (unsigned int width, unsigned int height)
 {
-    short           recalc_x, recalc_y;
-    int             x, y, sb_w, mb_h, flags;
-    unsigned int    w, h;
-    unsigned int    max_width, max_height;
-
-    D_SIZE((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
-            TermWin.ncol, TermWin.nrow, szHint.width,
-            szHint.height));
-    szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
-    szHint.win_gravity = NorthWestGravity;
-/* szHint.min_aspect.x = szHint.min_aspect.y = 1; */
-
-    recalc_x = recalc_y = 0;
-    flags = 0;
-    if (!parsed_geometry) {
-        parsed_geometry = 1;
-        if (rs[Rs_geometry])
-            flags = XParseGeometry(rs[Rs_geometry], &x, &y, &w, &h);
-        if (flags & WidthValue) {
-            TermWin.ncol = BOUND_POSITIVE_INT16(w);
-            szHint.flags |= USSize;
+  short           recalc_x, recalc_y;
+  int             x, y, sb_w, mb_h, flags;
+  unsigned int    w, h;
+  unsigned int    max_width, max_height;
+
+  D_SIZE((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
+          TermWin.ncol, TermWin.nrow, szHint.width,
+          szHint.height));
+  szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
+  szHint.win_gravity = NorthWestGravity;
+  /* szHint.min_aspect.x = szHint.min_aspect.y = 1; */
+
+  recalc_x = recalc_y = 0;
+  flags = 0;
+  if (!parsed_geometry)
+    {
+      parsed_geometry = 1;
+      if (rs[Rs_geometry])
+        flags = XParseGeometry(rs[Rs_geometry], &x, &y, &w, &h);
+      if (flags & WidthValue)
+        {
+          TermWin.ncol = BOUND_POSITIVE_INT16(w);
+          szHint.flags |= USSize;
         }
-        if (flags & HeightValue) {
-            TermWin.nrow = BOUND_POSITIVE_INT16(h);
-            szHint.flags |= USSize;
+      if (flags & HeightValue)
+        {
+          TermWin.nrow = BOUND_POSITIVE_INT16(h);
+          szHint.flags |= USSize;
         }
-        if (flags & XValue) {
-            szHint.x = x;
-            szHint.flags |= USPosition;
-            if (flags & XNegative) {
-                recalc_x = 1;
-                szHint.win_gravity = NorthEastGravity;
+      if (flags & XValue)
+        {
+          szHint.x = x;
+          szHint.flags |= USPosition;
+          if (flags & XNegative)
+            {
+              recalc_x = 1;
+              szHint.win_gravity = NorthEastGravity;
             }
         }
-        if (flags & YValue) {
-            szHint.y = y;
-            szHint.flags |= USPosition;
-            if (flags & YNegative) {
-                recalc_y = 1;
-                if (szHint.win_gravity == NorthEastGravity)
-                    szHint.win_gravity = SouthEastGravity;
-                else
-                    szHint.win_gravity = SouthWestGravity;
+      if (flags & YValue)
+        {
+          szHint.y = y;
+          szHint.flags |= USPosition;
+          if (flags & YNegative)
+            {
+              recalc_y = 1;
+              if (szHint.win_gravity == NorthEastGravity)
+                szHint.win_gravity = SouthEastGravity;
+              else
+                szHint.win_gravity = SouthWestGravity;
             }
         }
     }
-/* TODO: BOUNDS */
-    TermWin.width = TermWin.ncol * TermWin.fwidth;
-    TermWin.height = TermWin.nrow * TermWin.fheight;
-    max_width = MAX_COLS * TermWin.fwidth;
-    max_height = MAX_ROWS * TermWin.fheight;
-
-    szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth;
-
-    sb_w = mb_h = 0;
-    window_vt_x = window_vt_y = 0;
-    if (scrollbar_visible ()) {
-        sb_w = scrollbar_TotalWidth();
-        szHint.base_width += sb_w;
-        if (!(Options & Opt_scrollBar_right))
-            window_vt_x = sb_w;
+  /* TODO: BOUNDS */
+  TermWin.width = TermWin.ncol * TermWin.fwidth;
+  TermWin.height = TermWin.nrow * TermWin.fheight;
+  max_width = MAX_COLS * TermWin.fwidth;
+  max_height = MAX_ROWS * TermWin.fheight;
+
+  szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth;
+
+  sb_w = mb_h = 0;
+  window_vt_x = window_vt_y = 0;
+  if (scrollbar_visible ())
+    {
+      sb_w = scrollbar_TotalWidth();
+      szHint.base_width += sb_w;
+      if (!(Options & Opt_scrollBar_right))
+        window_vt_x = sb_w;
     }
-    if (menubar_visible ()) {
-        mb_h = menuBar_TotalHeight();
-        szHint.base_height += mb_h;
-        window_vt_y = mb_h;
+  if (menubar_visible ())
+    {
+      mb_h = menuBar_TotalHeight();
+      szHint.base_height += mb_h;
+      window_vt_y = mb_h;
     }
-    szHint.width_inc = TermWin.fwidth;
-    szHint.height_inc = TermWin.fheight;
-    szHint.min_width = szHint.base_width + szHint.width_inc;
-    szHint.min_height = szHint.base_height + szHint.height_inc;
-
-    if (width && width - szHint.base_width < max_width) {
-        szHint.width = width;
-        TermWin.width = width - szHint.base_width;
-    } else {
-        MIN_IT(TermWin.width, max_width);
-        szHint.width = szHint.base_width + TermWin.width;
+  szHint.width_inc = TermWin.fwidth;
+  szHint.height_inc = TermWin.fheight;
+  szHint.min_width = szHint.base_width + szHint.width_inc;
+  szHint.min_height = szHint.base_height + szHint.height_inc;
+
+  if (width && width - szHint.base_width < max_width)
+    {
+      szHint.width = width;
+      TermWin.width = width - szHint.base_width;
     }
-    if (height && height - szHint.base_height < max_height) {
-        szHint.height = height;
-        TermWin.height = height - szHint.base_height;
-    } else {
-        MIN_IT(TermWin.height, max_height);
-        szHint.height = szHint.base_height + TermWin.height;
+  else
+    {
+      MIN_IT(TermWin.width, max_width);
+      szHint.width = szHint.base_width + TermWin.width;
     }
-    if (scrollbar_visible () && (Options & Opt_scrollBar_right))
-        window_sb_x = szHint.width - sb_w;
-
-    if (recalc_x)
-        szHint.x += (DisplayWidth (Xdisplay, DefaultScreen (Xdisplay))
-                        - szHint.width - 2 * TermWin.ext_bwidth);
-    if (recalc_y)
-        szHint.y += (DisplayHeight (Xdisplay, DefaultScreen (Xdisplay))
-                        - szHint.height - 2 * TermWin.ext_bwidth);
-
-    TermWin.ncol = TermWin.width / TermWin.fwidth;
-    TermWin.nrow = TermWin.height / TermWin.fheight;
-    D_SIZE((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
-            TermWin.ncol, TermWin.nrow, szHint.width,
-            szHint.height));
-    return;
+  if (height && height - szHint.base_height < max_height)
+    {
+      szHint.height = height;
+      TermWin.height = height - szHint.base_height;
+    }
+  else
+    {
+      MIN_IT(TermWin.height, max_height);
+      szHint.height = szHint.base_height + TermWin.height;
+    }
+  if (scrollbar_visible () && (Options & Opt_scrollBar_right))
+    window_sb_x = szHint.width - sb_w;
+
+  if (recalc_x)
+    szHint.x += (DisplayWidth (Xdisplay, DefaultScreen (Xdisplay))
+                 - szHint.width - 2 * TermWin.ext_bwidth);
+  if (recalc_y)
+    szHint.y += (DisplayHeight (Xdisplay, DefaultScreen (Xdisplay))
+                 - szHint.height - 2 * TermWin.ext_bwidth);
+
+  TermWin.ncol = TermWin.width / TermWin.fwidth;
+  TermWin.nrow = TermWin.height / TermWin.fheight;
+  D_SIZE((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
+          TermWin.ncol, TermWin.nrow, szHint.width,
+          szHint.height));
+  return;
 }
 
 /*----------------------------------------------------------------------*/
@@ -665,13 +691,11 @@ rxvt_term::tt_winch ()
  */
 void
 rxvt_term::change_font (int init, const char *fontname)
-{
-}
+{}
 
 void
 rxvt_term::font_up_down (int n, int direction)
-{
-}
+{}
 
 /*----------------------------------------------------------------------*/
 /*----------------------------------------------------------------------*/
@@ -680,16 +704,16 @@ void
 rxvt_term::set_title (const char *str)
 {
 #ifndef SMART_WINDOW_TITLE
-    XStoreName(Xdisplay, TermWin.parent[0], str);
+  XStoreName(Xdisplay, TermWin.parent[0], str);
 #else
-    char           *name;
-
-    if (XFetchName(Xdisplay, TermWin.parent[0], &name) == 0)
-        name = NULL;
-    if (name == NULL || STRCMP(name, str))
-        XStoreName(Xdisplay, TermWin.parent[0], str);
-    if (name)
-        XFree(name);
+  char           *name;
+
+  if (XFetchName(Xdisplay, TermWin.parent[0], &name) == 0)
+    name = NULL;
+  if (name == NULL || STRCMP(name, str))
+    XStoreName(Xdisplay, TermWin.parent[0], str);
+  if (name)
+    XFree(name);
 #endif
 }
 
@@ -697,16 +721,16 @@ void
 rxvt_term::set_iconName (const char *str)
 {
 #ifndef SMART_WINDOW_TITLE
-    XSetIconName(Xdisplay, TermWin.parent[0], str);
+  XSetIconName(Xdisplay, TermWin.parent[0], str);
 #else
-    char           *name;
-
-    if (XGetIconName(Xdisplay, TermWin.parent[0], &name))
-        name = NULL;
-    if (name == NULL || STRCMP(name, str))
-        XSetIconName(Xdisplay, TermWin.parent[0], str);
-    if (name)
-        XFree(name);
+  char           *name;
+
+  if (XGetIconName(Xdisplay, TermWin.parent[0], &name))
+    name = NULL;
+  if (name == NULL || STRCMP(name, str))
+    XSetIconName(Xdisplay, TermWin.parent[0], str);
+  if (name)
+    XFree(name);
 #endif
 }
 
@@ -714,64 +738,69 @@ rxvt_term::set_iconName (const char *str)
 void
 rxvt_term::set_window_color (int idx, const char *color)
 {
-    rxvt_color      xcol;
-    int             i;
+  rxvt_color      xcol;
+  int             i;
 
-    if (color == NULL || *color == '\0')
-        return;
+  if (color == NULL || *color == '\0')
+    return;
 
-/* handle color aliases */
-    if (isdigit(*color)) {
-        i = atoi(color);
-        if (i >= 8 && i <= 15) {        /* bright colors */
-            i -= 8;
+  /* handle color aliases */
+  if (isdigit(*color))
+    {
+      i = atoi(color);
+      if (i >= 8 && i <= 15)
+        {        /* bright colors */
+          i -= 8;
 # ifndef NO_BRIGHTCOLOR
-            PixColors[idx] = PixColors[minBrightCOLOR + i];
-            SET_PIXCOLOR(idx);
-            goto Done;
+          PixColors[idx] = PixColors[minBrightCOLOR + i];
+          SET_PIXCOLOR(idx);
+          goto Done;
 # endif
+
         }
-        if (i >= 0 && i <= 7) { /* normal colors */
-            PixColors[idx] = PixColors[minCOLOR + i];
-            SET_PIXCOLOR(idx);
-            goto Done;
+      if (i >= 0 && i <= 7)
+        { /* normal colors */
+          PixColors[idx] = PixColors[minCOLOR + i];
+          SET_PIXCOLOR(idx);
+          goto Done;
         }
     }
-    if (!rXParseAllocColor (& xcol, color))
-        return;
-/* XStoreColor (Xdisplay, XCMAP, XColor*); */
+  if (!rXParseAllocColor (& xcol, color))
+    return;
+  /* XStoreColor (Xdisplay, XCMAP, XColor*); */
 
-/*
- * FIXME: should free colors here, but no idea how to do it so instead,
- * so just keep gobbling up the colormap
- */
+  /*
  * FIXME: should free colors here, but no idea how to do it so instead,
  * so just keep gobbling up the colormap
  */
 # if 0
-    for (i = Color_Black; i <= Color_White; i++)
-        if (PixColors[idx] == PixColors[i])
-            break;
-    if (i > Color_White) {
-    /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */
-        XFreeColors(Xdisplay, XCMAP, (PixColors + idx), 1,
-                    DisplayPlanes(Xdisplay, Xscreen));
+  for (i = Color_Black; i <= Color_White; i++)
+    if (PixColors[idx] == PixColors[i])
+      break;
+  if (i > Color_White)
+    {
+      /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */
+      XFreeColors(Xdisplay, XCMAP, (PixColors + idx), 1,
+                  DisplayPlanes(Xdisplay, Xscreen));
     }
 # endif
 
-    PixColors[idx] = xcol;
-    SET_PIXCOLOR(idx);
+  PixColors[idx] = xcol;
+  SET_PIXCOLOR(idx);
 
-/* XSetWindowAttributes attr; */
-/* Cursor cursor; */
-  Done:
-    if (idx == Color_bg && !(Options & Opt_transparent))
-        XSetWindowBackground(Xdisplay, TermWin.vt,
-                             PixColors[Color_bg]);
+  /* XSetWindowAttributes attr; */
+  /* Cursor cursor; */
+Done:
+  if (idx == Color_bg && !(Options & Opt_transparent))
+    XSetWindowBackground(Xdisplay, TermWin.vt,
+                         PixColors[Color_bg]);
 
-/* handle Color_BD, scrollbar background, etc. */
+  /* handle Color_BD, scrollbar background, etc. */
 
-    set_colorfgbg ();
-    recolour_cursor ();
-/* the only reasonable way to enforce a clean update */
-    scr_poweron ();
+  set_colorfgbg ();
+  recolour_cursor ();
+  /* the only reasonable way to enforce a clean update */
+  scr_poweron ();
 }
 
 #else
@@ -782,12 +811,12 @@ void
 rxvt_term::recolour_cursor ()
 {
 #if TODO
-    rxvt_color xcol[2];
+  rxvt_color xcol[2];
 
-    xcol[0] = PixColors[Color_pointer];
-    xcol[1] = PixColors[Color_bg];
-    XQueryColors (Xdisplay, XCMAP, xcol, 2);
-    XRecolorCursor (Xdisplay, TermWin_cursor, &(xcol[0]), &(xcol[1]));
+  xcol[0] = PixColors[Color_pointer];
+  xcol[1] = PixColors[Color_bg];
+  XQueryColors (Xdisplay, XCMAP, xcol, 2);
+  XRecolorCursor (Xdisplay, TermWin_cursor, &(xcol[0]), &(xcol[1]));
 #endif
 }
 
@@ -798,37 +827,40 @@ rxvt_term::recolour_cursor ()
 void
 rxvt_term::set_colorfgbg ()
 {
-    unsigned int    i;
-    const char     *xpmb = "\0";
-    char            fstr[sizeof("default") + 1], bstr[sizeof("default") + 1];
-
-    env_colorfgbg =
-        (char *)rxvt_malloc(sizeof("COLORFGBG=default;default;bg") + 1);
-    STRCPY(fstr, "default");
-    STRCPY(bstr, "default");
-    for (i = Color_Black; i <= Color_White; i++)
-        if (PixColors[Color_fg] == PixColors[i]) {
-            sprintf(fstr, "%d", (i - Color_Black));
-            break;
-        }
-    for (i = Color_Black; i <= Color_White; i++)
-        if (PixColors[Color_bg] == PixColors[i]) {
-            sprintf(bstr, "%d", (i - Color_Black));
+  unsigned int    i;
+  const char     *xpmb = "\0";
+  char            fstr[sizeof("default") + 1], bstr[sizeof("default") + 1];
+
+  env_colorfgbg =
+    (char *)rxvt_malloc(sizeof("COLORFGBG=default;default;bg") + 1);
+  STRCPY(fstr, "default");
+  STRCPY(bstr, "default");
+  for (i = Color_Black; i <= Color_White; i++)
+    if (PixColors[Color_fg] == PixColors[i])
+      {
+        sprintf(fstr, "%d", (i - Color_Black));
+        break;
+      }
+  for (i = Color_Black; i <= Color_White; i++)
+    if (PixColors[Color_bg] == PixColors[i])
+      {
+        sprintf(bstr, "%d", (i - Color_Black));
 #ifdef XPM_BACKGROUND
-            xpmb = "default;";
+        xpmb = "default;";
 #endif
-            break;
-        }
-    sprintf(env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr);
-    putenv(env_colorfgbg);
+        break;
+      }
+  sprintf(env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr);
+  putenv(env_colorfgbg);
 
 #ifndef NO_BRIGHTCOLOR
-    colorfgbg = DEFAULT_RSTYLE;
-    for (i = minCOLOR; i <= maxCOLOR; i++) {
-        if (PixColors[Color_fg] == PixColors[i])
-            colorfgbg = SET_FGCOLOR(colorfgbg, i);
-        if (PixColors[Color_bg] == PixColors[i])
-            colorfgbg = SET_BGCOLOR(colorfgbg, i);
+  colorfgbg = DEFAULT_RSTYLE;
+  for (i = minCOLOR; i <= maxCOLOR; i++)
+    {
+      if (PixColors[Color_fg] == PixColors[i])
+        colorfgbg = SET_FGCOLOR(colorfgbg, i);
+      if (PixColors[Color_bg] == PixColors[i])
+        colorfgbg = SET_BGCOLOR(colorfgbg, i);
     }
 #endif
 }
@@ -842,12 +874,13 @@ rxvt_term::set_colorfgbg ()
 int
 rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour)
 {
-    if (!screen_in_out->set (this, colour)) {
-        rxvt_print_error("can't allocate colour: %s", colour);
-        return false;
+  if (!screen_in_out->set (this, colour))
+    {
+      rxvt_print_error("can't allocate colour: %s", colour);
+      return false;
     }
 
-    return true;
+  return true;
 }
 
 /* -------------------------------------------------------------------- *
@@ -884,25 +917,26 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno
        * if Xroot isn't the parent window, a WM will probably have offset
        * our position for handles and decorations.  Counter it
        */
-      if (x1 != x || y1 != y) {
+      if (x1 != x || y1 != y)
+        {
           x -= x1;
           y -= y1;
-      }
+        }
 
       x1 = (DisplayWidth (Xdisplay, Xscreen) - old_width) / 2;
       y1 = (DisplayHeight (Xdisplay, Xscreen) - old_height) / 2;
       dx = old_width - szHint.width;
       dy = old_height - szHint.height;
 
-  /* Check position of the center of the window */
+      /* Check position of the center of the window */
       if (x < x1)             /* left half */
-          dx = 0;
+        dx = 0;
       else if (x == x1)       /* exact center */
-          dx /= 2;
+        dx /= 2;
       if (y < y1)             /* top half */
-          dy = 0;
+        dy = 0;
       else if (y == y1)       /* exact center */
-          dy /= 2;
+        dy /= 2;
 
       XMoveResizeWindow (Xdisplay, TermWin.parent[0], x + dx, y + dy,
                          szHint.width, szHint.height);
@@ -910,6 +944,7 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno
       XResizeWindow (Xdisplay, TermWin.parent[0], szHint.width,
                      szHint.height);
 #endif
+
     }
 
   fix_screen = (TermWin.ncol != prev_ncol
@@ -934,12 +969,13 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno
 #ifdef RXVT_GRAPHICS
       if (old_height)
         Gr_Resize (old_width - szHint.base_width,
-                        old_height - szHint.base_height);
+                   old_height - szHint.base_height);
 #endif
       scr_clear ();
 #ifdef XPM_BACKGROUND
       resize_pixmap ();
 #endif
+
     }
 
   if (fix_screen || old_height == 0)
@@ -980,19 +1016,21 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno
 void
 rxvt_term::set_widthheight (unsigned int width, unsigned int height)
 {
-    XWindowAttributes wattr;
-
-    if (width == 0 || height == 0) {
-        XGetWindowAttributes(Xdisplay, Xroot, &wattr);
-        if (width == 0)
-            width = wattr.width - szHint.base_width;
-        if (height == 0)
-            height = wattr.height - szHint.base_height;
+  XWindowAttributes wattr;
+
+  if (width == 0 || height == 0)
+    {
+      XGetWindowAttributes(Xdisplay, Xroot, &wattr);
+      if (width == 0)
+        width = wattr.width - szHint.base_width;
+      if (height == 0)
+        height = wattr.height - szHint.base_height;
     }
-    if (width != TermWin.width || height != TermWin.height) {
-        width += szHint.base_width;
-        height += szHint.base_height;
-        resize_all_windows (width, height, 0);
+  if (width != TermWin.width || height != TermWin.height)
+    {
+      width += szHint.base_width;
+      height += szHint.base_height;
+      resize_all_windows (width, height, 0);
     }
 }
 
@@ -1020,47 +1058,48 @@ rxvt_term::set_color (unsigned long *fg, unsigned long *bg)
 bool
 rxvt_term::IMisRunning ()
 {
-    char           *p;
-    Atom            atom;
-    Window          win;
-    char            server[IMBUFSIZ];
-
-/* get current locale modifier */
-    if ((p = XSetLocaleModifiers(NULL)) != NULL) {
-        STRCPY(server, "@server=");
-        STRNCAT(server, &(p[4]), IMBUFSIZ - 9); /* skip "@im=" */
-        if ((p = STRCHR(server + 1, '@')) != NULL)      /* first one only */
-            *p = '\0';
-
-        atom = XInternAtom(Xdisplay, server, False);
-        win = XGetSelectionOwner(Xdisplay, atom);
-        if (win != None)
-            return True;
+  char           *p;
+  Atom            atom;
+  Window          win;
+  char            server[IMBUFSIZ];
+
+  /* get current locale modifier */
+  if ((p = XSetLocaleModifiers(NULL)) != NULL)
+    {
+      STRCPY(server, "@server=");
+      STRNCAT(server, &(p[4]), IMBUFSIZ - 9); /* skip "@im=" */
+      if ((p = STRCHR(server + 1, '@')) != NULL)      /* first one only */
+        *p = '\0';
+
+      atom = XInternAtom(Xdisplay, server, False);
+      win = XGetSelectionOwner(Xdisplay, atom);
+      if (win != None)
+        return True;
     }
-    return False;
+  return False;
 }
 
 void
 rxvt_term::IMSendSpot ()
 {
-    XPoint          spot;
-    XVaNestedList   preedit_attr;
-
-    if (Input_Context == NULL
-        || !TermWin.focus || !(input_style & XIMPreeditPosition)
-        || !(event_type == KeyPress
-             || event_type == Expose
-             || event_type == NoExpose
-             || event_type == SelectionNotify
-             || event_type == ButtonRelease || event_type == FocusIn)
-        || !IMisRunning ())
-        return;
-
-    set_position (&spot);
-
-    preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
-    XSetICValues(Input_Context, XNPreeditAttributes, preedit_attr, NULL);
-    XFree(preedit_attr);
+  XPoint          spot;
+  XVaNestedList   preedit_attr;
+
+  if (Input_Context == NULL
+      || !TermWin.focus || !(input_style & XIMPreeditPosition)
+      || !(event_type == KeyPress
+           || event_type == Expose
+           || event_type == NoExpose
+           || event_type == SelectionNotify
+           || event_type == ButtonRelease || event_type == FocusIn)
+      || !IMisRunning ())
+    return;
+
+  set_position (&spot);
+
+  preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
+  XSetICValues(Input_Context, XNPreeditAttributes, preedit_attr, NULL);
+  XFree(preedit_attr);
 }
 
 void
@@ -1095,11 +1134,11 @@ rxvt_IMDestroyCallback(XIM xim __attribute__ ((unused)), XPointer client_data
                        __attribute__ ((unused)), XPointer call_data
                        __attribute__ ((unused)))
 {
-    GET_R->Input_Context = NULL;
-/* To avoid Segmentation Fault in C locale: Solaris only? */
-    if (STRCMP (GET_R->locale, "C"))
-        XRegisterIMInstantiateCallback(GET_R->Xdisplay, NULL, NULL, NULL,
-                                       rxvt_IMInstantiateCallback, NULL);
+  GET_R->Input_Context = NULL;
+  /* To avoid Segmentation Fault in C locale: Solaris only? */
+  if (STRCMP (GET_R->locale, "C"))
+    XRegisterIMInstantiateCallback(GET_R->Xdisplay, NULL, NULL, NULL,
+                                   rxvt_IMInstantiateCallback, NULL);
 }
 
 /*
@@ -1109,114 +1148,122 @@ rxvt_IMDestroyCallback(XIM xim __attribute__ ((unused)), XPointer client_data
 bool
 rxvt_term::IM_get_IC ()
 {
-    int             i, j, found;
-    XIM             xim;
-    XPoint          spot;
-    XRectangle      rect, status_rect, needed_rect;
-    unsigned long   fg, bg;
-    const char     *p;
-    char          **s;
-    XIMStyles      *xim_styles;
-    XVaNestedList   preedit_attr, status_attr;
-    XIMCallback     ximcallback;
-
-    D_MAIN((stderr, "rxvt_IM_get_IC()"));
-    xim = XOpenIM (Xdisplay, NULL, NULL, NULL);
-    if (xim == NULL)
-        return False;
-
-    xim_styles = NULL;
-    if (XGetIMValues (xim, XNQueryInputStyle, &xim_styles, NULL)
-        || !xim_styles || !xim_styles->count_styles) {
-        XCloseIM(xim);
-        return False;
+  int             i, j, found;
+  XIM             xim;
+  XPoint          spot;
+  XRectangle      rect, status_rect, needed_rect;
+  unsigned long   fg, bg;
+  const char     *p;
+  char          **s;
+  XIMStyles      *xim_styles;
+  XVaNestedList   preedit_attr, status_attr;
+  XIMCallback     ximcallback;
+
+  D_MAIN((stderr, "rxvt_IM_get_IC()"));
+  xim = XOpenIM (Xdisplay, NULL, NULL, NULL);
+  if (xim == NULL)
+    return False;
+
+  xim_styles = NULL;
+  if (XGetIMValues (xim, XNQueryInputStyle, &xim_styles, NULL)
+      || !xim_styles || !xim_styles->count_styles)
+    {
+      XCloseIM(xim);
+      return False;
     }
 
-    p = rs[Rs_preeditType] ? rs[Rs_preeditType]
-        : "OverTheSpot,OffTheSpot,Root";
-    s = rxvt_splitcommastring(p);
-    for (i = found = 0; !found && s[i]; i++) {
-        if (!STRCMP(s[i], "OverTheSpot"))
-            input_style = (XIMPreeditPosition | XIMStatusNothing);
-        else if (!STRCMP(s[i], "OffTheSpot"))
-            input_style = (XIMPreeditArea | XIMStatusArea);
-        else if (!STRCMP(s[i], "Root"))
-            input_style = (XIMPreeditNothing | XIMStatusNothing);
-
-        for (j = 0; j < xim_styles->count_styles; j++)
-            if (input_style == xim_styles->supported_styles[j]) {
-                found = 1;
-                break;
-            }
+  p = rs[Rs_preeditType] ? rs[Rs_preeditType]
+      : "OverTheSpot,OffTheSpot,Root";
+  s = rxvt_splitcommastring(p);
+  for (i = found = 0; !found && s[i]; i++)
+    {
+      if (!STRCMP(s[i], "OverTheSpot"))
+        input_style = (XIMPreeditPosition | XIMStatusNothing);
+      else if (!STRCMP(s[i], "OffTheSpot"))
+        input_style = (XIMPreeditArea | XIMStatusArea);
+      else if (!STRCMP(s[i], "Root"))
+        input_style = (XIMPreeditNothing | XIMStatusNothing);
+
+      for (j = 0; j < xim_styles->count_styles; j++)
+        if (input_style == xim_styles->supported_styles[j])
+          {
+            found = 1;
+            break;
+          }
     }
-    for (i = 0; s[i]; i++)
-        free(s[i]);
-    free(s);
-    XFree(xim_styles);
+  for (i = 0; s[i]; i++)
+    free(s[i]);
+  free(s);
+  XFree(xim_styles);
+
+  if (!found)
+    {
+      XCloseIM(xim);
+      return False;
+    }
+
+  ximcallback.callback = rxvt_IMDestroyCallback;
 
-    if (!found) {
-        XCloseIM(xim);
-        return False;
+  /* XXX: not sure why we need this (as well as IC one below) */
+  XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL);
+
+  preedit_attr = status_attr = NULL;
+
+  if (input_style & XIMPreeditPosition)
+    {
+      set_size (&rect);
+      set_position (&spot);
+      set_color (&fg, &bg);
+
+      preedit_attr = XVaCreateNestedList(0, XNArea, &rect,
+                                         XNSpotLocation, &spot,
+                                         XNForeground, fg, XNBackground, bg,
+                                         //XNFontSet, TermWin.fontset,
+                                         NULL);
     }
+  else if (input_style & XIMPreeditArea)
+    {
+      set_color (&fg, &bg);
 
-    ximcallback.callback = rxvt_IMDestroyCallback;
-
-    /* XXX: not sure why we need this (as well as IC one below) */
-    XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL);
-
-    preedit_attr = status_attr = NULL;
-
-    if (input_style & XIMPreeditPosition) {
-        set_size (&rect);
-        set_position (&spot);
-        set_color (&fg, &bg);
-
-        preedit_attr = XVaCreateNestedList(0, XNArea, &rect,
-                                           XNSpotLocation, &spot,
-                                           XNForeground, fg, XNBackground, bg,
-                                       //XNFontSet, TermWin.fontset,
-                                           NULL);
-    } else if (input_style & XIMPreeditArea) {
-        set_color (&fg, &bg);
-
-    /*
-     * The necessary width of preedit area is unknown
-     * until create input context.
-     */
-        needed_rect.width = 0;
-
-        set_preedit_area(&rect, &status_rect, &needed_rect);
-
-        preedit_attr = XVaCreateNestedList(0, XNArea, &rect,
-                                           XNForeground, fg, XNBackground, bg,
-                                       //XNFontSet, TermWin.fontset,
-                                           NULL);
-        status_attr = XVaCreateNestedList(0, XNArea, &status_rect,
-                                          XNForeground, fg, XNBackground, bg,
-                                      //XNFontSet, TermWin.fontset,
-                                          NULL);
+      /*
+       * The necessary width of preedit area is unknown
+       * until create input context.
+       */
+      needed_rect.width = 0;
+
+      set_preedit_area(&rect, &status_rect, &needed_rect);
+
+      preedit_attr = XVaCreateNestedList(0, XNArea, &rect,
+                                         XNForeground, fg, XNBackground, bg,
+                                         //XNFontSet, TermWin.fontset,
+                                         NULL);
+      status_attr = XVaCreateNestedList(0, XNArea, &status_rect,
+                                        XNForeground, fg, XNBackground, bg,
+                                        //XNFontSet, TermWin.fontset,
+                                        NULL);
     }
-    Input_Context = XCreateIC(xim, XNInputStyle, input_style,
-                                 XNClientWindow, TermWin.parent[0],
-                                 XNFocusWindow, TermWin.parent[0],
-                                 XNDestroyCallback, &ximcallback,
-                                 preedit_attr ? XNPreeditAttributes : NULL,
-                                 preedit_attr,
-                                 status_attr ? XNStatusAttributes : NULL,
-                                 status_attr, NULL);
-    if (preedit_attr)
-        XFree(preedit_attr);
-    if (status_attr)
-        XFree(status_attr);
-    if (Input_Context == NULL) {
-        rxvt_print_error("failed to create input context");
-        XCloseIM(xim);
-        return False;
+  Input_Context = XCreateIC(xim, XNInputStyle, input_style,
+                            XNClientWindow, TermWin.parent[0],
+                            XNFocusWindow, TermWin.parent[0],
+                            XNDestroyCallback, &ximcallback,
+                            preedit_attr ? XNPreeditAttributes : NULL,
+                            preedit_attr,
+                            status_attr ? XNStatusAttributes : NULL,
+                            status_attr, NULL);
+  if (preedit_attr)
+    XFree(preedit_attr);
+  if (status_attr)
+    XFree(status_attr);
+  if (Input_Context == NULL)
+    {
+      rxvt_print_error("failed to create input context");
+      XCloseIM(xim);
+      return False;
     }
-    if (input_style & XIMPreeditArea)
-        IMSetStatusPosition ();
-    D_MAIN((stderr, "rxvt_IM_get_IC() - successful connection"));
-    return True;
+  if (input_style & XIMPreeditArea)
+    IMSetStatusPosition ();
+  D_MAIN((stderr, "rxvt_IM_get_IC() - successful connection"));
+  return True;
 }
 
 /*
@@ -1267,19 +1314,19 @@ rxvt_IMInstantiateCallback(Display * unused
             }
         }
       for (i = 0; s[i]; i++)
-          free(s[i]);
+        free(s[i]);
       free(s);
 
       if (found)
         goto done;
     }
 
-/* try with XMODIFIERS env. var. */
+  /* try with XMODIFIERS env. var. */
   if ((p = XSetLocaleModifiers ("")) && *p
       && GET_R->IM_get_IC ())
     goto done;
 
-/* try with no modifiers base IF the user didn't specify an IM */
+  /* try with no modifiers base IF the user didn't specify an IM */
   if ((p = XSetLocaleModifiers ("@im=none")) && *p
       && GET_R->IM_get_IC () == True)
     goto done;
@@ -1294,30 +1341,30 @@ done:
 void
 rxvt_term::IMSetStatusPosition ()
 {
-    XRectangle      preedit_rect, status_rect, *needed_rect;
-    XVaNestedList   preedit_attr, status_attr;
+  XRectangle      preedit_rect, status_rect, *needed_rect;
+  XVaNestedList   preedit_attr, status_attr;
 
-    if (Input_Context == NULL
-        || !TermWin.focus || !(input_style & XIMPreeditArea)
-        || !IMisRunning ())
-        return;
+  if (Input_Context == NULL
+      || !TermWin.focus || !(input_style & XIMPreeditArea)
+      || !IMisRunning ())
+    return;
 
-/* Getting the necessary width of preedit area */
-    status_attr = XVaCreateNestedList(0, XNAreaNeeded, &needed_rect, NULL);
-    XGetICValues(Input_Context, XNStatusAttributes, status_attr, NULL);
-    XFree(status_attr);
+  /* Getting the necessary width of preedit area */
+  status_attr = XVaCreateNestedList(0, XNAreaNeeded, &needed_rect, NULL);
+  XGetICValues(Input_Context, XNStatusAttributes, status_attr, NULL);
+  XFree(status_attr);
 
-    set_preedit_area(&preedit_rect, &status_rect, needed_rect);
+  set_preedit_area(&preedit_rect, &status_rect, needed_rect);
 
-    preedit_attr = XVaCreateNestedList(0, XNArea, &preedit_rect, NULL);
-    status_attr = XVaCreateNestedList(0, XNArea, &status_rect, NULL);
+  preedit_attr = XVaCreateNestedList(0, XNArea, &preedit_rect, NULL);
+  status_attr = XVaCreateNestedList(0, XNArea, &status_rect, NULL);
 
-    XSetICValues(Input_Context,
-                 XNPreeditAttributes, preedit_attr,
-                 XNStatusAttributes, status_attr, NULL);
+  XSetICValues(Input_Context,
+               XNPreeditAttributes, preedit_attr,
+               XNStatusAttributes, status_attr, NULL);
 
-    XFree(preedit_attr);
-    XFree(status_attr);
+  XFree(preedit_attr);
+  XFree(status_attr);
 }
 #endif                          /* USE_XIM */
 
index 7cd8701..9195453 100644 (file)
 #define Menu_PixelWidth(menu)                                  \
     (2 * SHADOW + Width2Pixel ((menu)->width + 3 * HSPACE))
 
-static const struct {
+static const struct
+  {
     const char      name;      /* (l)eft, (u)p, (d)own, (r)ight */
     const unsigned char str[5];        /* str[0] = STRLEN (str+1) */
-} Arrows[NARROWS] = {
-    { 'l', "\003\033[D" },
-    { 'u', "\003\033[A" },
-    { 'd', "\003\033[B" },
-    { 'r', "\003\033[C" }
-};
+  }
+Arrows[NARROWS] = {
+                    { 'l', "\003\033[D" },
+                    { 'u', "\003\033[A" },
+                    { 'd', "\003\033[B" },
+                    { 'r', "\003\033[C" }
+                  };
 
 /*}}} */
 
@@ -50,23 +52,26 @@ static const struct {
 menuitem_t     *
 rxvt_menuitem_find(const menu_t *menu, const char *name)
 {
-    menuitem_t     *item;
+  menuitem_t     *item;
 
 #ifdef DEBUG_STRICT
-    assert(name != NULL);
-    assert(menu != NULL);
+  assert(name != NULL);
+  assert(menu != NULL);
 #endif
 
-/* find the last item in the menu, this is good for separators */
-    for (item = menu->tail; item != NULL; item = item->prev) {
-       if (item->entry.type == MenuSubMenu) {
-           if (!STRCMP(name, (item->entry.submenu.menu)->name))
-               break;
-       } else if ((isSeparator(name) && isSeparator(item->name))
-                  || !STRCMP(name, item->name))
-           break;
+  /* find the last item in the menu, this is good for separators */
+  for (item = menu->tail; item != NULL; item = item->prev)
+    {
+      if (item->entry.type == MenuSubMenu)
+        {
+          if (!STRCMP(name, (item->entry.submenu.menu)->name))
+            break;
+        }
+      else if ((isSeparator(name) && isSeparator(item->name))
+               || !STRCMP(name, item->name))
+        break;
     }
-    return item;
+  return item;
 }
 
 /*
@@ -75,40 +80,41 @@ rxvt_menuitem_find(const menu_t *menu, const char *name)
 void
 rxvt_term::menuitem_free (menu_t *menu, menuitem_t *item)
 {
-/* disconnect */
-    menuitem_t     *prev, *next;
+  /* disconnect */
+  menuitem_t     *prev, *next;
 
 #ifdef DEBUG_STRICT
-    assert(menu != NULL);
+  assert(menu != NULL);
 #endif
 
-    prev = item->prev;
-    next = item->next;
-    if (prev != NULL)
-       prev->next = next;
-    if (next != NULL)
-       next->prev = prev;
-
-/* new head, tail */
-    if (menu->tail == item)
-       menu->tail = prev;
-    if (menu->head == item)
-       menu->head = next;
-
-    switch (item->entry.type) {
-    case MenuAction:
-    case MenuTerminalAction:
-       free(item->entry.action.str);
-       break;
-    case MenuSubMenu:
-       menu_delete (item->entry.submenu.menu);
-       break;
-    }
-    if (item->name != NULL)
-       free(item->name);
-    if (item->name2 != NULL)
-       free(item->name2);
-    free(item);
+  prev = item->prev;
+  next = item->next;
+  if (prev != NULL)
+    prev->next = next;
+  if (next != NULL)
+    next->prev = prev;
+
+  /* new head, tail */
+  if (menu->tail == item)
+    menu->tail = prev;
+  if (menu->head == item)
+    menu->head = next;
+
+  switch (item->entry.type)
+    {
+      case MenuAction:
+      case MenuTerminalAction:
+        free(item->entry.action.str);
+        break;
+      case MenuSubMenu:
+        menu_delete (item->entry.submenu.menu);
+        break;
+    }
+  if (item->name != NULL)
+    free(item->name);
+  if (item->name2 != NULL)
+    free(item->name2);
+  free(item);
 }
 
 /*
@@ -118,313 +124,345 @@ rxvt_term::menuitem_free (menu_t *menu, menuitem_t *item)
 int
 rxvt_action_type(action_t *action, unsigned char *str)
 {
-    unsigned int    len;
+  unsigned int    len;
 
 #if defined (DEBUG_MENU) || defined (DEBUG_MENUARROWS)
-    len = STRLEN(str);
-    fprintf(stderr, "(len %d) = %s\n", len, str);
+  len = STRLEN(str);
+  fprintf(stderr, "(len %d) = %s\n", len, str);
 #else
-    len = rxvt_Str_escaped((char *)str);
+  len = rxvt_Str_escaped((char *)str);
 #endif
 
-    if (!len)
-       return -1;
-
-/* sort command vs. terminal actions */
-    action->type = MenuAction;
-    if (str[0] == '\0') {
-       /* the functional equivalent: memmove (str, str+1, len); */
-       unsigned char  *dst = (str);
-       unsigned char  *src = (str + 1);
-       unsigned char  *end = (str + len);
-
-       while (src <= end)
-           *dst++ = *src++;
+  if (!len)
+    return -1;
 
-       len--;                  /* decrement length */
-       if (str[0] != '\0')
-           action->type = MenuTerminalAction;
+  /* sort command vs. terminal actions */
+  action->type = MenuAction;
+  if (str[0] == '\0')
+    {
+      /* the functional equivalent: memmove (str, str+1, len); */
+      unsigned char  *dst = (str);
+      unsigned char  *src = (str + 1);
+      unsigned char  *end = (str + len);
+
+      while (src <= end)
+        *dst++ = *src++;
+
+      len--;                   /* decrement length */
+      if (str[0] != '\0')
+        action->type = MenuTerminalAction;
     }
-    action->str = str;
-    action->len = len;
+  action->str = str;
+  action->len = len;
 
-    return 0;
+  return 0;
 }
 
 int
 rxvt_term::action_dispatch (action_t *action)
 {
-    switch (action->type) {
-    case MenuTerminalAction:
-       cmd_write (action->str, action->len);
-       break;
-
-    case MenuAction:
-       tt_write (action->str, action->len);
-       break;
-
-    default:
-       return -1;
-       break;
+  switch (action->type)
+    {
+      case MenuTerminalAction:
+        cmd_write (action->str, action->len);
+        break;
+
+      case MenuAction:
+        tt_write (action->str, action->len);
+        break;
+
+      default:
+        return -1;
+        break;
     }
-    return 0;
+  return 0;
 }
 
 /* return the arrow index corresponding to NAME */
 int
 rxvt_menuarrow_find(char name)
 {
-    int             i;
+  int             i;
 
-    for (i = 0; i < NARROWS; i++)
-       if (name == Arrows[i].name)
-           return i;
-    return -1;
+  for (i = 0; i < NARROWS; i++)
+    if (name == Arrows[i].name)
+      return i;
+  return -1;
 }
 
 /* free the memory associated with arrow NAME of the current menubar */
 void
 rxvt_term::menuarrow_free (char name)
 {
-    int             i;
-
-    if (name) {
-       i = rxvt_menuarrow_find(name);
-       if (i >= 0) {
-           action_t       *act = &(CurrentBar->arrows[i]);
-
-           switch (act->type) {
-           case MenuAction:
-           case MenuTerminalAction:
-               free(act->str);
-               act->str = NULL;
-               act->len = 0;
-               break;
-           }
-           act->type = MenuLabel;
-       }
-    } else {
-       for (i = 0; i < NARROWS; i++)
-           menuarrow_free (Arrows[i].name);
+  int             i;
+
+  if (name)
+    {
+      i = rxvt_menuarrow_find(name);
+      if (i >= 0)
+        {
+          action_t       *act = &(CurrentBar->arrows[i]);
+
+          switch (act->type)
+            {
+              case MenuAction:
+              case MenuTerminalAction:
+                free(act->str);
+                act->str = NULL;
+                act->len = 0;
+                break;
+            }
+          act->type = MenuLabel;
+        }
+    }
+  else
+    {
+      for (i = 0; i < NARROWS; i++)
+        menuarrow_free (Arrows[i].name);
     }
 }
 
 void
 rxvt_term::menuarrow_add (char *string)
 {
-    int             i;
-    unsigned        xtra_len;
-    char           *p;
-    struct {
-       char           *str;
-       int             len;
-    }
-    beg = { NULL, 0 },
-    end = { NULL, 0 },
-    *cur,
-    parse[NARROWS];
-
-    MEMSET(parse, 0, sizeof(parse));
-
-/* fprintf(stderr, "add arrows = `%s'\n", string); */
-    for (p = string; p != NULL && *p; string = p) {
-       p = (string + 3);
-       /* fprintf(stderr, "parsing at %s\n", string); */
-       switch (string[1]) {
-       case 'b':
-           cur = &beg;
-           break;
-       case 'e':
-           cur = &end;
-           break;
-
-       default:
-           i = rxvt_menuarrow_find(string[1]);
-           if (i >= 0)
-               cur = &(parse[i]);
-           else
-               continue;       /* not found */
-           break;
-       }
-
-       string = p;
-       cur->str = string;
-       cur->len = 0;
-
-       if (cur == &end) {
-           p = STRCHR(string, '\0');
-       } else {
-           char           *next = string;
-
-           while (1) {
-               p = STRCHR(next, '<');
-               if (p != NULL) {
-                   if (p[1] && p[2] == '>')
-                       break;
-                   /* parsed */
-               } else {
-                   if (beg.str == NULL)        /* no end needed */
-                       p = STRCHR(next, '\0');
-                   break;
-               }
-               next = (p + 1);
-           }
-       }
-
-       if (p == NULL)
-           return;
-       cur->len = (p - string);
+  int             i;
+  unsigned        xtra_len;
+  char           *p;
+  struct
+    {
+      char           *str;
+      int             len;
+    }
+  beg = { NULL, 0 },
+        end = { NULL, 0 },
+              *cur,
+              parse[NARROWS];
+
+  MEMSET(parse, 0, sizeof(parse));
+
+  /* fprintf(stderr, "add arrows = `%s'\n", string); */
+  for (p = string; p != NULL && *p; string = p)
+    {
+      p = (string + 3);
+      /* fprintf(stderr, "parsing at %s\n", string); */
+      switch (string[1])
+        {
+          case 'b':
+            cur = &beg;
+            break;
+          case 'e':
+            cur = &end;
+            break;
+
+          default:
+            i = rxvt_menuarrow_find(string[1]);
+            if (i >= 0)
+              cur = &(parse[i]);
+            else
+              continue;        /* not found */
+            break;
+        }
+
+      string = p;
+      cur->str = string;
+      cur->len = 0;
+
+      if (cur == &end)
+        {
+          p = STRCHR(string, '\0');
+        }
+      else
+        {
+          char           *next = string;
+
+          while (1)
+            {
+              p = STRCHR(next, '<');
+              if (p != NULL)
+                {
+                  if (p[1] && p[2] == '>')
+                    break;
+                  /* parsed */
+                }
+              else
+                {
+                  if (beg.str == NULL) /* no end needed */
+                    p = STRCHR(next, '\0');
+                  break;
+                }
+              next = (p + 1);
+            }
+        }
+
+      if (p == NULL)
+        return;
+      cur->len = (p - string);
     }
 
 #ifdef DEBUG_MENUARROWS
-    cur = &beg;
-    fprintf(stderr, "<b>(len %d) = %.*s\n",
-           cur->len, cur->len, (cur->str ? cur->str : ""));
-    for (i = 0; i < NARROWS; i++) {
-       cur = &(parse[i]);
-       fprintf(stderr, "<%c>(len %d) = %.*s\n",
-               Arrows[i].name,
-               cur->len, cur->len, (cur->str ? cur->str : ""));
-    }
-    cur = &end;
-    fprintf(stderr, "<e>(len %d) = %.*s\n",
-           cur->len, cur->len, (cur->str ? cur->str : ""));
+  cur = &beg;
+  fprintf(stderr, "<b>(len %d) = %.*s\n",
+          cur->len, cur->len, (cur->str ? cur->str : ""));
+  for (i = 0; i < NARROWS; i++)
+    {
+      cur = &(parse[i]);
+      fprintf(stderr, "<%c>(len %d) = %.*s\n",
+              Arrows[i].name,
+              cur->len, cur->len, (cur->str ? cur->str : ""));
+    }
+  cur = &end;
+  fprintf(stderr, "<e>(len %d) = %.*s\n",
+          cur->len, cur->len, (cur->str ? cur->str : ""));
 #endif
 
-    xtra_len = (beg.len + end.len);
-    for (i = 0; i < NARROWS; i++) {
-       if (xtra_len || parse[i].len)
-           menuarrow_free (Arrows[i].name);
+  xtra_len = (beg.len + end.len);
+  for (i = 0; i < NARROWS; i++)
+    {
+      if (xtra_len || parse[i].len)
+        menuarrow_free (Arrows[i].name);
     }
 
-    for (i = 0; i < NARROWS; i++) {
-       unsigned char  *str;
-       unsigned int    len;
+  for (i = 0; i < NARROWS; i++)
+    {
+      unsigned char  *str;
+      unsigned int    len;
 
-       if (!parse[i].len)
-           continue;
+      if (!parse[i].len)
+        continue;
 
-       str = rxvt_malloc(parse[i].len + xtra_len + 1);
+      str = rxvt_malloc(parse[i].len + xtra_len + 1);
 
-       len = 0;
-       if (beg.len) {
-           STRNCPY(str + len, beg.str, beg.len);
-           len += beg.len;
-       }
-       STRNCPY(str + len, parse[i].str, parse[i].len);
-       len += parse[i].len;
+      len = 0;
+      if (beg.len)
+        {
+          STRNCPY(str + len, beg.str, beg.len);
+          len += beg.len;
+        }
+      STRNCPY(str + len, parse[i].str, parse[i].len);
+      len += parse[i].len;
 
-       if (end.len) {
-           STRNCPY(str + len, end.str, end.len);
-           len += end.len;
-       }
-       str[len] = '\0';
+      if (end.len)
+        {
+          STRNCPY(str + len, end.str, end.len);
+          len += end.len;
+        }
+      str[len] = '\0';
 
 #ifdef DEBUG_MENUARROWS
-       fprintf(stderr, "<%c>(len %d) = %s\n", Arrows[i].name, len, str);
+      fprintf(stderr, "<%c>(len %d) = %s\n", Arrows[i].name, len, str);
 #endif
-       if (rxvt_action_type(&(CurrentBar->arrows[i]), str) < 0)
-           free(str);
+      if (rxvt_action_type(&(CurrentBar->arrows[i]), str) < 0)
+        free(str);
     }
 }
 
 menuitem_t     *
 rxvt_menuitem_add(menu_t *menu, const char *name, const char *name2, const char *action)
 {
-    menuitem_t     *item;
-    unsigned int    len;
+  menuitem_t     *item;
+  unsigned int    len;
 
 #ifdef DEBUG_STRICT
-    assert(name != NULL);
-    assert(action != NULL);
+  assert(name != NULL);
+  assert(action != NULL);
 #endif
 
-    if (menu == NULL)
-       return NULL;
-
-    if (isSeparator(name)) {
-       /* add separator, no action */
-       name = "";
-       action = "";
-    } else {
-       /*
-        * add/replace existing menu item
-        */
-       item = rxvt_menuitem_find(menu, name);
-       if (item != NULL) {
-           if (item->name2 != NULL && name2 != NULL) {
-               free(item->name2);
-               item->len2 = 0;
-               item->name2 = NULL;
-           }
-           switch (item->entry.type) {
-           case MenuAction:
-           case MenuTerminalAction:
-               free(item->entry.action.str);
-               item->entry.action.str = NULL;
-               break;
-           }
-           goto Item_Found;
-       }
-    }
-/* allocate a new itemect */
-    item = (menuitem_t *) rxvt_malloc(sizeof(menuitem_t));
-
-    item->len2 = 0;
-    item->name2 = NULL;
-
-    len = STRLEN(name);
-    item->name = rxvt_malloc(len + 1);
-    STRCPY(item->name, name);
-    if (name[0] == '.' && name[1] != '.')
-       len = 0;                /* hidden menu name */
-    item->len = len;
-
-/* add to tail of list */
-    item->prev = menu->tail;
-    item->next = NULL;
-
-    if (menu->tail != NULL)
-       (menu->tail)->next = item;
-    menu->tail = item;
-/* fix head */
-    if (menu->head == NULL)
-       menu->head = item;
+  if (menu == NULL)
+    return NULL;
 
-/*
- * add action
- */
-  Item_Found:
-    if (name2 != NULL && item->name2 == NULL) {
-       len = STRLEN(name2);
-       if (len == 0)
-           item->name2 = NULL;
-       else {
-           item->name2 = rxvt_malloc(len + 1);
-           STRCPY(item->name2, name2);
-       }
-       item->len2 = len;
+  if (isSeparator(name))
+    {
+      /* add separator, no action */
+      name = "";
+      action = "";
+    }
+  else
+    {
+      /*
+       * add/replace existing menu item
+       */
+      item = rxvt_menuitem_find(menu, name);
+      if (item != NULL)
+        {
+          if (item->name2 != NULL && name2 != NULL)
+            {
+              free(item->name2);
+              item->len2 = 0;
+              item->name2 = NULL;
+            }
+          switch (item->entry.type)
+            {
+              case MenuAction:
+              case MenuTerminalAction:
+                free(item->entry.action.str);
+                item->entry.action.str = NULL;
+                break;
+            }
+          goto Item_Found;
+        }
+    }
+  /* allocate a new itemect */
+  item = (menuitem_t *) rxvt_malloc(sizeof(menuitem_t));
+
+  item->len2 = 0;
+  item->name2 = NULL;
+
+  len = STRLEN(name);
+  item->name = rxvt_malloc(len + 1);
+  STRCPY(item->name, name);
+  if (name[0] == '.' && name[1] != '.')
+    len = 0;           /* hidden menu name */
+  item->len = len;
+
+  /* add to tail of list */
+  item->prev = menu->tail;
+  item->next = NULL;
+
+  if (menu->tail != NULL)
+    (menu->tail)->next = item;
+  menu->tail = item;
+  /* fix head */
+  if (menu->head == NULL)
+    menu->head = item;
+
+  /*
+   * add action
+   */
+Item_Found:
+  if (name2 != NULL && item->name2 == NULL)
+    {
+      len = STRLEN(name2);
+      if (len == 0)
+        item->name2 = NULL;
+      else
+        {
+          item->name2 = rxvt_malloc(len + 1);
+          STRCPY(item->name2, name2);
+        }
+      item->len2 = len;
     }
-    item->entry.type = MenuLabel;
-    len = STRLEN(action);
+  item->entry.type = MenuLabel;
+  len = STRLEN(action);
 
-    if (len == 0 && item->name2 != NULL) {
-       action = item->name2;
-       len = item->len2;
+  if (len == 0 && item->name2 != NULL)
+    {
+      action = item->name2;
+      len = item->len2;
     }
-    if (len) {
-       unsigned char  *str = rxvt_malloc(len + 1);
+  if (len)
+    {
+      unsigned char  *str = rxvt_malloc(len + 1);
 
-       STRCPY(str, action);
+      STRCPY(str, action);
 
-       if (rxvt_action_type(&(item->entry.action), str) < 0)
-           free(str);
+      if (rxvt_action_type(&(item->entry.action), str) < 0)
+        free(str);
     }
-/* new item and a possible increase in width */
-    if (menu->width < (item->len + item->len2))
-       menu->width = (item->len + item->len2);
+  /* new item and a possible increase in width */
+  if (menu->width < (item->len + item->len2))
+    menu->width = (item->len + item->len2);
 
-    return item;
+  return item;
 }
 
 /*
@@ -434,76 +472,94 @@ rxvt_menuitem_add(menu_t *menu, const char *name, const char *name2, const char
 char           *
 rxvt_term::menu_find_base (menu_t **menu, char *path)
 {
-    menu_t         *m = NULL;
-    menuitem_t     *item;
+  menu_t         *m = NULL;
+  menuitem_t     *item;
 
 #ifdef DEBUG_STRICT
-    assert(menu != NULL);
-    assert(CurrentBar != NULL);
+  assert(menu != NULL);
+  assert(CurrentBar != NULL);
 #endif
 
-    if (path[0] == '\0')
-       return path;
-
-    if (STRCHR(path, '/') != NULL) {
-       char           *p = path;
-
-       while ((p = STRCHR(p, '/')) != NULL) {
-           p++;
-           if (*p == '/')
-               path = p;
-       }
-       if (path[0] == '/') {
-           path++;
-           *menu = NULL;
-       }
-       while ((p = STRCHR(path, '/')) != NULL) {
-           p[0] = '\0';
-           if (path[0] == '\0')
-               return NULL;
-           if (!STRCMP(path, DOT)) {
-               /* nothing to do */
-           } else if (!STRCMP(path, DOTS)) {
-               if (*menu != NULL)
-                   *menu = (*menu)->parent;
-           } else {
-               path = menu_find_base (menu, path);
-               if (path[0] != '\0') {  /* not found */
-                   p[0] = '/'; /* fix-up name again */
-                   return path;
-               }
-           }
-
-           path = (p + 1);
-       }
-    }
-    if (!STRCMP(path, DOTS)) {
-       path += STRLEN(DOTS);
-       if (*menu != NULL)
-           *menu = (*menu)->parent;
-       return path;
-    }
-/* find this menu */
-    if (*menu == NULL) {
-       for (m = CurrentBar->tail; m != NULL; m = m->prev) {
-           if (!STRCMP(path, m->name))
-               break;
-       }
-    } else {
-       /* find this menu */
-       for (item = (*menu)->tail; item != NULL; item = item->prev) {
-           if (item->entry.type == MenuSubMenu
-               && !STRCMP(path, (item->entry.submenu.menu)->name)) {
-               m = (item->entry.submenu.menu);
-               break;
-           }
-       }
-    }
-    if (m != NULL) {
-       *menu = m;
-       path += STRLEN(path);
-    }
+  if (path[0] == '\0')
     return path;
+
+  if (STRCHR(path, '/') != NULL)
+    {
+      char           *p = path;
+
+      while ((p = STRCHR(p, '/')) != NULL)
+        {
+          p++;
+          if (*p == '/')
+            path = p;
+        }
+      if (path[0] == '/')
+        {
+          path++;
+          *menu = NULL;
+        }
+      while ((p = STRCHR(path, '/')) != NULL)
+        {
+          p[0] = '\0';
+          if (path[0] == '\0')
+            return NULL;
+          if (!STRCMP(path, DOT))
+            {
+              /* nothing to do */
+            }
+          else if (!STRCMP(path, DOTS))
+            {
+              if (*menu != NULL)
+                *menu = (*menu)->parent;
+            }
+          else
+            {
+              path = menu_find_base (menu, path);
+              if (path[0] != '\0')
+                {      /* not found */
+                  p[0] = '/';  /* fix-up name again */
+                  return path;
+                }
+            }
+
+          path = (p + 1);
+        }
+    }
+  if (!STRCMP(path, DOTS))
+    {
+      path += STRLEN(DOTS);
+      if (*menu != NULL)
+        *menu = (*menu)->parent;
+      return path;
+    }
+  /* find this menu */
+  if (*menu == NULL)
+    {
+      for (m = CurrentBar->tail; m != NULL; m = m->prev)
+        {
+          if (!STRCMP(path, m->name))
+            break;
+        }
+    }
+  else
+    {
+      /* find this menu */
+      for (item = (*menu)->tail; item != NULL; item = item->prev)
+        {
+          if (item->entry.type == MenuSubMenu
+              && !STRCMP(path, (item->entry.submenu.menu)->name))
+            {
+              m = (item->entry.submenu.menu);
+              break;
+            }
+        }
+    }
+  if (m != NULL)
+    {
+      *menu = m;
+      path += STRLEN(path);
+    }
+  return path;
 }
 
 /*
@@ -512,300 +568,326 @@ rxvt_term::menu_find_base (menu_t **menu, char *path)
 menu_t         *
 rxvt_term::menu_delete (menu_t *menu)
 {
-    menu_t         *parent = NULL, *prev, *next;
-    menuitem_t     *item;
-    bar_t          *CurrentBar = CurrentBar;
+  menu_t         *parent = NULL, *prev, *next;
+  menuitem_t     *item;
+  bar_t          *CurrentBar = CurrentBar;
 
 #ifdef DEBUG_STRICT
-    assert(CurrentBar != NULL);
+  assert(CurrentBar != NULL);
 #endif
 
-/* delete the entire menu */
-    if (menu == NULL)
-       return NULL;
+  /* delete the entire menu */
+  if (menu == NULL)
+    return NULL;
 
-    parent = menu->parent;
+  parent = menu->parent;
 
-/* unlink MENU */
-    prev = menu->prev;
-    next = menu->next;
-    if (prev != NULL)
-       prev->next = next;
-    if (next != NULL)
-       next->prev = prev;
+  /* unlink MENU */
+  prev = menu->prev;
+  next = menu->next;
+  if (prev != NULL)
+    prev->next = next;
+  if (next != NULL)
+    next->prev = prev;
 
-/* fix the index */
-    if (parent == NULL) {
-       const int       len = (menu->len + HSPACE);
+  /* fix the index */
+  if (parent == NULL)
+    {
+      const int       len = (menu->len + HSPACE);
 
-       if (CurrentBar->tail == menu)
-           CurrentBar->tail = prev;
-       if (CurrentBar->head == menu)
-           CurrentBar->head = next;
+      if (CurrentBar->tail == menu)
+        CurrentBar->tail = prev;
+      if (CurrentBar->head == menu)
+        CurrentBar->head = next;
 
-       for (next = menu->next; next != NULL; next = next->next)
-           next->x -= len;
-    } else {
-       for (item = parent->tail; item != NULL; item = item->prev) {
-           if (item->entry.type == MenuSubMenu
-               && item->entry.submenu.menu == menu) {
-               item->entry.submenu.menu = NULL;
-               menuitem_free (menu->parent, item);
-               break;
-           }
-       }
+      for (next = menu->next; next != NULL; next = next->next)
+        next->x -= len;
+    }
+  else
+    {
+      for (item = parent->tail; item != NULL; item = item->prev)
+        {
+          if (item->entry.type == MenuSubMenu
+              && item->entry.submenu.menu == menu)
+            {
+              item->entry.submenu.menu = NULL;
+              menuitem_free (menu->parent, item);
+              break;
+            }
+        }
     }
 
-    item = menu->tail;
-    while (item != NULL) {
-       menuitem_t     *p = item->prev;
+  item = menu->tail;
+  while (item != NULL)
+    {
+      menuitem_t     *p = item->prev;
 
-       menuitem_free (menu, item);
-       item = p;
+      menuitem_free (menu, item);
+      item = p;
     }
 
-    if (menu->name != NULL)
-       free(menu->name);
-    free(menu);
+  if (menu->name != NULL)
+    free(menu->name);
+  free(menu);
 
-    return parent;
+  return parent;
 }
 
 menu_t         *
 rxvt_term::menu_add (menu_t *parent, char *path)
 {
-    menu_t         *menu;
-    bar_t          *CurrentBar = CurrentBar;
+  menu_t         *menu;
+  bar_t          *CurrentBar = CurrentBar;
 
 #ifdef DEBUG_STRICT
-    assert(CurrentBar != NULL);
+  assert(CurrentBar != NULL);
 #endif
 
-    if (STRCHR(path, '/') != NULL) {
-       char           *p;
-
-       if (path[0] == '/') {
-           /* shouldn't happen */
-           path++;
-           parent = NULL;
-       }
-       while ((p = STRCHR(path, '/')) != NULL) {
-           p[0] = '\0';
-           if (path[0] == '\0')
-               return NULL;
-
-           parent = menu_add (parent, path);
-           path = (p + 1);
-       }
-    }
-    if (!STRCMP(path, DOTS))
-       return (parent != NULL ? parent->parent : parent);
-
-    if (!STRCMP(path, DOT) || path[0] == '\0')
-       return parent;
-
-/* allocate a new menu */
-    menu = (menu_t *) rxvt_malloc(sizeof(menu_t));
-
-    menu->width = 0;
-    menu->parent = parent;
-    menu->len = STRLEN(path);
-    menu->name = rxvt_malloc((menu->len + 1));
-    STRCPY(menu->name, path);
-
-/* initialize head/tail */
-    menu->head = menu->tail = NULL;
-    menu->prev = menu->next = NULL;
-
-    menu->win = None;
-    menu->x = menu->y = menu->w = menu->h = 0;
-    menu->item = NULL;
-
-/* add to tail of list */
-    if (parent == NULL) {
-       menu->prev = CurrentBar->tail;
-       if (CurrentBar->tail != NULL)
-           CurrentBar->tail->next = menu;
-       CurrentBar->tail = menu;
-       if (CurrentBar->head == NULL)
-           CurrentBar->head = menu;    /* fix head */
-       if (menu->prev)
-           menu->x = (menu->prev->x + menu->prev->len + HSPACE);
-    } else {
-       menuitem_t     *item;
-
-       item = rxvt_menuitem_add(parent, path, "", "");
-       if (item == NULL) {
-           free(menu);
-           return parent;
-       }
+  if (STRCHR(path, '/') != NULL)
+    {
+      char           *p;
+
+      if (path[0] == '/')
+        {
+          /* shouldn't happen */
+          path++;
+          parent = NULL;
+        }
+      while ((p = STRCHR(path, '/')) != NULL)
+        {
+          p[0] = '\0';
+          if (path[0] == '\0')
+            return NULL;
+
+          parent = menu_add (parent, path);
+          path = (p + 1);
+        }
+    }
+  if (!STRCMP(path, DOTS))
+    return (parent != NULL ? parent->parent : parent);
+
+  if (!STRCMP(path, DOT) || path[0] == '\0')
+    return parent;
+
+  /* allocate a new menu */
+  menu = (menu_t *) rxvt_malloc(sizeof(menu_t));
+
+  menu->width = 0;
+  menu->parent = parent;
+  menu->len = STRLEN(path);
+  menu->name = rxvt_malloc((menu->len + 1));
+  STRCPY(menu->name, path);
+
+  /* initialize head/tail */
+  menu->head = menu->tail = NULL;
+  menu->prev = menu->next = NULL;
+
+  menu->win = None;
+  menu->x = menu->y = menu->w = menu->h = 0;
+  menu->item = NULL;
+
+  /* add to tail of list */
+  if (parent == NULL)
+    {
+      menu->prev = CurrentBar->tail;
+      if (CurrentBar->tail != NULL)
+        CurrentBar->tail->next = menu;
+      CurrentBar->tail = menu;
+      if (CurrentBar->head == NULL)
+        CurrentBar->head = menu;       /* fix head */
+      if (menu->prev)
+        menu->x = (menu->prev->x + menu->prev->len + HSPACE);
+    }
+  else
+    {
+      menuitem_t     *item;
+
+      item = rxvt_menuitem_add(parent, path, "", "");
+      if (item == NULL)
+        {
+          free(menu);
+          return parent;
+        }
 #ifdef DEBUG_STRICT
-       assert(item->entry.type == MenuLabel);
+      assert(item->entry.type == MenuLabel);
 #endif
-       item->entry.type = MenuSubMenu;
-       item->entry.submenu.menu = menu;
+      item->entry.type = MenuSubMenu;
+      item->entry.submenu.menu = menu;
     }
 
-    return menu;
+  return menu;
 }
 
 void
 rxvt_term::drawbox_menubar (int x, int len, int state)
 {
-    GC              top, bot;
+  GC              top, bot;
 
-    x = Width2Pixel(x);
-    len = Width2Pixel(len + HSPACE);
-    if (x >= TermWin.width)
-       return;
-    else if (x + len >= TermWin.width)
-       len = (TermWin_TotalWidth() - x);
+  x = Width2Pixel(x);
+  len = Width2Pixel(len + HSPACE);
+  if (x >= TermWin.width)
+    return;
+  else if (x + len >= TermWin.width)
+    len = (TermWin_TotalWidth() - x);
 
 #ifdef MENUBAR_SHADOW_IN
-    state = -state;
+  state = -state;
 #endif
-    switch (state) {
-    case +1:
-       top = topShadowGC;
-       bot = botShadowGC;
-       break;                  /* SHADOW_OUT */
-    case -1:
-       top = botShadowGC;
-       bot = topShadowGC;
-       break;                  /* SHADOW_IN */
-    default:
-       top = bot = scrollbarGC;
-       break;                  /* neutral */
-    }
-
-    rxvt_Draw_Shadow(Xdisplay, menuBar.win, top, bot,
-                    x, 0, len, menuBar_TotalHeight());
+  switch (state)
+    {
+      case +1:
+        top = topShadowGC;
+        bot = botShadowGC;
+        break;                 /* SHADOW_OUT */
+      case -1:
+        top = botShadowGC;
+        bot = topShadowGC;
+        break;                 /* SHADOW_IN */
+      default:
+        top = bot = scrollbarGC;
+        break;                 /* neutral */
+    }
+
+  rxvt_Draw_Shadow(Xdisplay, menuBar.win, top, bot,
+                   x, 0, len, menuBar_TotalHeight());
 }
 
 void
 rxvt_term::drawtriangle (int x, int y, int state)
 {
-    GC              top, bot;
-    int             w;
+  GC              top, bot;
+  int             w;
 
 #ifdef MENU_SHADOW_IN
-    state = -state;
+  state = -state;
 #endif
-    switch (state) {
-    case +1:
-       top = topShadowGC;
-       bot = botShadowGC;
-       break;                  /* SHADOW_OUT */
-    case -1:
-       top = botShadowGC;
-       bot = topShadowGC;
-       break;                  /* SHADOW_IN */
-    default:
-       top = bot = scrollbarGC;
-       break;                  /* neutral */
-    }
-
-    w = Height2Pixel(1) - 2 * SHADOW;
-
-    x -= SHADOW + (3 * w / 2);
-    y += SHADOW * 3;
-
-    rxvt_Draw_Triangle(Xdisplay, ActiveMenu->win, top, bot, x, y, w,
-                      'r');
+  switch (state)
+    {
+      case +1:
+        top = topShadowGC;
+        bot = botShadowGC;
+        break;                 /* SHADOW_OUT */
+      case -1:
+        top = botShadowGC;
+        bot = topShadowGC;
+        break;                 /* SHADOW_IN */
+      default:
+        top = bot = scrollbarGC;
+        break;                 /* neutral */
+    }
+
+  w = Height2Pixel(1) - 2 * SHADOW;
+
+  x -= SHADOW + (3 * w / 2);
+  y += SHADOW * 3;
+
+  rxvt_Draw_Triangle(Xdisplay, ActiveMenu->win, top, bot, x, y, w,
+                     'r');
 }
 
 void
 rxvt_term::drawbox_menuitem (int y, int state)
 {
-    GC              top, bot;
+  GC              top, bot;
 
 #ifdef MENU_SHADOW_IN
-    state = -state;
+  state = -state;
 #endif
-    switch (state) {
-    case +1:
-       top = topShadowGC;
-       bot = botShadowGC;
-       break;                  /* SHADOW_OUT */
-    case -1:
-       top = botShadowGC;
-       bot = topShadowGC;
-       break;                  /* SHADOW_IN */
-    default:
-       top = bot = scrollbarGC;
-       break;                  /* neutral */
-    }
-
-    rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, top, bot,
-                    SHADOW + 0, SHADOW + y,
-                    ActiveMenu->w - 2 * (SHADOW),
-                    HEIGHT_TEXT + 2 * SHADOW);
-    XFlush(Xdisplay);
+  switch (state)
+    {
+      case +1:
+        top = topShadowGC;
+        bot = botShadowGC;
+        break;                 /* SHADOW_OUT */
+      case -1:
+        top = botShadowGC;
+        bot = topShadowGC;
+        break;                 /* SHADOW_IN */
+      default:
+        top = bot = scrollbarGC;
+        break;                 /* neutral */
+    }
+
+  rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, top, bot,
+                   SHADOW + 0, SHADOW + y,
+                   ActiveMenu->w - 2 * (SHADOW),
+                   HEIGHT_TEXT + 2 * SHADOW);
+  XFlush(Xdisplay);
 }
 
 #ifdef DEBUG_MENU_LAYOUT
 void
 rxvt_print_menu_ancestors(menu_t *menu)
 {
-    if (menu == NULL) {
-       fprintf(stderr, "Top Level menu\n");
-       return;
-    }
-    fprintf(stderr, "menu %s ", menu->name);
-    if (menu->parent != NULL) {
-       menuitem_t     *item;
-
-       for (item = menu->parent->head; item != NULL; item = item->next) {
-           if (item->entry.type == MenuSubMenu
-               && item->entry.submenu.menu == menu) {
-               break;
-           }
-       }
-       if (item == NULL) {
-           fprintf(stderr, "is an orphan!\n");
-           return;
-       }
-    }
-    fprintf(stderr, "\n");
-    rxvt_print_menu_ancestors(menu->parent);
+  if (menu == NULL)
+    {
+      fprintf(stderr, "Top Level menu\n");
+      return;
+    }
+  fprintf(stderr, "menu %s ", menu->name);
+  if (menu->parent != NULL)
+    {
+      menuitem_t     *item;
+
+      for (item = menu->parent->head; item != NULL; item = item->next)
+        {
+          if (item->entry.type == MenuSubMenu
+              && item->entry.submenu.menu == menu)
+            {
+              break;
+            }
+        }
+      if (item == NULL)
+        {
+          fprintf(stderr, "is an orphan!\n");
+          return;
+        }
+    }
+  fprintf(stderr, "\n");
+  rxvt_print_menu_ancestors(menu->parent);
 }
 
 void
 rxvt_print_menu_descendants(menu_t *menu)
 {
-    menuitem_t     *item;
-    menu_t         *parent;
-    int             i, level = 0;
-
-    parent = menu;
-    do {
-       level++;
-       parent = parent->parent;
-    }
-    while (parent != NULL);
-
-    for (i = 0; i < level; i++)
-       fprintf(stderr, ">");
-    fprintf(stderr, "%s\n", menu->name);
-
-    for (item = menu->head; item != NULL; item = item->next) {
-       if (item->entry.type == MenuSubMenu) {
-           if (item->entry.submenu.menu == NULL)
-               fprintf(stderr, "> %s == NULL\n", item->name);
-           else
-               rxvt_print_menu_descendants(item->entry.submenu.menu);
-       } else {
-           for (i = 0; i < level; i++)
-               fprintf(stderr, "+");
-           if (item->entry.type == MenuLabel)
-               fprintf(stderr, "label: ");
-           fprintf(stderr, "%s\n", item->name);
-       }
-    }
-
-    for (i = 0; i < level; i++)
-       fprintf(stderr, "<");
-    fprintf(stderr, "\n");
+  menuitem_t     *item;
+  menu_t         *parent;
+  int             i, level = 0;
+
+  parent = menu;
+  do
+    {
+      level++;
+      parent = parent->parent;
+    }
+  while (parent != NULL);
+
+  for (i = 0; i < level; i++)
+    fprintf(stderr, ">");
+  fprintf(stderr, "%s\n", menu->name);
+
+  for (item = menu->head; item != NULL; item = item->next)
+    {
+      if (item->entry.type == MenuSubMenu)
+        {
+          if (item->entry.submenu.menu == NULL)
+            fprintf(stderr, "> %s == NULL\n", item->name);
+          else
+            rxvt_print_menu_descendants(item->entry.submenu.menu);
+        }
+      else
+        {
+          for (i = 0; i < level; i++)
+            fprintf(stderr, "+");
+          if (item->entry.type == MenuLabel)
+            fprintf(stderr, "label: ");
+          fprintf(stderr, "%s\n", item->name);
+        }
+    }
+
+  for (i = 0; i < level; i++)
+    fprintf(stderr, "<");
+  fprintf(stderr, "\n");
 }
 #endif
 
@@ -813,214 +895,231 @@ rxvt_print_menu_descendants(menu_t *menu)
 void
 rxvt_term::menu_show ()
 {
-    int             x, y, xright;
-    menu_t         *ActiveMenu = ActiveMenu;
-    menuitem_t     *item;
-
-    if (ActiveMenu == NULL)
-       return;
-
-    x = ActiveMenu->x;
-    if (ActiveMenu->parent == NULL) {
-       register int    h;
-
-       drawbox_menubar (x, ActiveMenu->len, -1);
-       x = Width2Pixel(x);
-
-       ActiveMenu->y = 1;
-       ActiveMenu->w = Menu_PixelWidth(ActiveMenu);
-
-       if ((x + ActiveMenu->w) >= TermWin.width)
-           x = (TermWin_TotalWidth() - ActiveMenu->w);
-
-       /* find the height */
-       for (h = 0, item = ActiveMenu->head; item != NULL; item = item->next)
-           h += isSeparator(item->name) ? HEIGHT_SEPARATOR
-                                        : HEIGHT_TEXT + 2 * SHADOW;
-       ActiveMenu->h = h + 2 * SHADOW;
-    }
-    if (ActiveMenu->win == None) {
-       ActiveMenu->win = XCreateSimpleWindow(Xdisplay, TermWin.vt,
-                                             x, ActiveMenu->y,
-                                             ActiveMenu->w, ActiveMenu->h,
-                                             0,
-                                             PixColors[Color_fg],
-                                             PixColors[Color_scroll]);
-       XMapWindow(Xdisplay, ActiveMenu->win);
-    }
-    rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win,
-                    topShadowGC, botShadowGC,
-                    0, 0, ActiveMenu->w, ActiveMenu->h);
-
-/* determine the correct right-alignment */
-    for (xright = 0, item = ActiveMenu->head; item != NULL; item = item->next)
-       if (item->len2 > xright)
-           xright = item->len2;
-
-    for (y = 0, item = ActiveMenu->head; item != NULL; item = item->next) {
-       const int       xoff = (SHADOW + Width2Pixel(HSPACE) / 2);
-       register int    h;
-       GC              gc = menubarGC;
-
-       if (isSeparator(item->name)) {
-           rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win,
-                            topShadowGC, botShadowGC,
-                            SHADOW, y + SHADOW + 1,
-                            ActiveMenu->w - 2 * SHADOW, 0);
-           h = HEIGHT_SEPARATOR;
-       } else {
-           char           *name = item->name;
-           int             len = item->len;
-
-           if (item->entry.type == MenuLabel) {
-               gc = botShadowGC;
-           } else if (item->entry.type == MenuSubMenu) {
-               int             x1, y1;
-               menuitem_t     *it;
-               menu_t         *menu = item->entry.submenu.menu;
-
-               drawtriangle (ActiveMenu->w, y, +1);
-
-               name = menu->name;
-               len = menu->len;
-
-               y1 = ActiveMenu->y + y;
-
-               menu->w = Menu_PixelWidth(menu);
-
-               /* place sub-menu at midpoint of parent menu */
-               x1 = ActiveMenu->w / 2;
-               if (x1 > menu->w)       /* right-flush menu if too small */
-                   x1 += (x1 - menu->w);
-               x1 += x;
-
-               /* find the height of this submenu */
-               for (h = 0, it = menu->head; it != NULL; it = it->next)
-                   h += isSeparator(it->name) ? HEIGHT_SEPARATOR
-                                              : HEIGHT_TEXT + 2 * SHADOW;
-               menu->h = h + 2 * SHADOW;
-
-               /* ensure menu is in window limits */
-               if ((x1 + menu->w) >= TermWin.width)
-                   x1 = (TermWin_TotalWidth() - menu->w);
-
-               if ((y1 + menu->h) >= TermWin.height)
-                   y1 = (TermWin_TotalHeight() - menu->h);
-
-               menu->x = (x1 < 0 ? 0 : x1);
-               menu->y = (y1 < 0 ? 0 : y1);
-           } else if (item->name2 && !STRCMP(name, item->name2))
-               name = NULL;
-
-           if (len && name) {
+  int             x, y, xright;
+  menu_t         *ActiveMenu = ActiveMenu;
+  menuitem_t     *item;
+
+  if (ActiveMenu == NULL)
+    return;
+
+  x = ActiveMenu->x;
+  if (ActiveMenu->parent == NULL)
+    {
+      register int    h;
+
+      drawbox_menubar (x, ActiveMenu->len, -1);
+      x = Width2Pixel(x);
+
+      ActiveMenu->y = 1;
+      ActiveMenu->w = Menu_PixelWidth(ActiveMenu);
+
+      if ((x + ActiveMenu->w) >= TermWin.width)
+        x = (TermWin_TotalWidth() - ActiveMenu->w);
+
+      /* find the height */
+      for (h = 0, item = ActiveMenu->head; item != NULL; item = item->next)
+        h += isSeparator(item->name) ? HEIGHT_SEPARATOR
+             : HEIGHT_TEXT + 2 * SHADOW;
+      ActiveMenu->h = h + 2 * SHADOW;
+    }
+  if (ActiveMenu->win == None)
+    {
+      ActiveMenu->win = XCreateSimpleWindow(Xdisplay, TermWin.vt,
+                                            x, ActiveMenu->y,
+                                            ActiveMenu->w, ActiveMenu->h,
+                                            0,
+                                            PixColors[Color_fg],
+                                            PixColors[Color_scroll]);
+      XMapWindow(Xdisplay, ActiveMenu->win);
+    }
+  rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win,
+                   topShadowGC, botShadowGC,
+                   0, 0, ActiveMenu->w, ActiveMenu->h);
+
+  /* determine the correct right-alignment */
+  for (xright = 0, item = ActiveMenu->head; item != NULL; item = item->next)
+    if (item->len2 > xright)
+      xright = item->len2;
+
+  for (y = 0, item = ActiveMenu->head; item != NULL; item = item->next)
+    {
+      const int       xoff = (SHADOW + Width2Pixel(HSPACE) / 2);
+      register int    h;
+      GC              gc = menubarGC;
+
+      if (isSeparator(item->name))
+        {
+          rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win,
+                           topShadowGC, botShadowGC,
+                           SHADOW, y + SHADOW + 1,
+                           ActiveMenu->w - 2 * SHADOW, 0);
+          h = HEIGHT_SEPARATOR;
+        }
+      else
+        {
+          char           *name = item->name;
+          int             len = item->len;
+
+          if (item->entry.type == MenuLabel)
+            {
+              gc = botShadowGC;
+            }
+          else if (item->entry.type == MenuSubMenu)
+            {
+              int             x1, y1;
+              menuitem_t     *it;
+              menu_t         *menu = item->entry.submenu.menu;
+
+              drawtriangle (ActiveMenu->w, y, +1);
+
+              name = menu->name;
+              len = menu->len;
+
+              y1 = ActiveMenu->y + y;
+
+              menu->w = Menu_PixelWidth(menu);
+
+              /* place sub-menu at midpoint of parent menu */
+              x1 = ActiveMenu->w / 2;
+              if (x1 > menu->w)        /* right-flush menu if too small */
+                x1 += (x1 - menu->w);
+              x1 += x;
+
+              /* find the height of this submenu */
+              for (h = 0, it = menu->head; it != NULL; it = it->next)
+                h += isSeparator(it->name) ? HEIGHT_SEPARATOR
+                     : HEIGHT_TEXT + 2 * SHADOW;
+              menu->h = h + 2 * SHADOW;
+
+              /* ensure menu is in window limits */
+              if ((x1 + menu->w) >= TermWin.width)
+                x1 = (TermWin_TotalWidth() - menu->w);
+
+              if ((y1 + menu->h) >= TermWin.height)
+                y1 = (TermWin_TotalHeight() - menu->h);
+
+              menu->x = (x1 < 0 ? 0 : x1);
+              menu->y = (y1 < 0 ? 0 : y1);
+            }
+          else if (item->name2 && !STRCMP(name, item->name2))
+            name = NULL;
+
+          if (len && name)
+            {
 #ifdef USE_XIM
-               if (TermWin.fontset)
-                   XmbDrawString(Xdisplay,
-                                 ActiveMenu->win, TermWin.fontset,
-                                 gc, xoff,
-                                 2 * SHADOW + y + TermWin.font->ascent + 1,
-                                 name, len);
-               else
+              if (TermWin.fontset)
+                XmbDrawString(Xdisplay,
+                              ActiveMenu->win, TermWin.fontset,
+                              gc, xoff,
+                              2 * SHADOW + y + TermWin.font->ascent + 1,
+                              name, len);
+              else
 #endif
-                   XDrawString(Xdisplay, ActiveMenu->win, gc, xoff,
-                               2 * SHADOW + y + TermWin.font->ascent + 1,
-                               name, len);
-           }
-
-           len = item->len2;
-           name = item->name2;
-           if (len && name) {
+                XDrawString(Xdisplay, ActiveMenu->win, gc, xoff,
+                            2 * SHADOW + y + TermWin.font->ascent + 1,
+                            name, len);
+            }
+
+          len = item->len2;
+          name = item->name2;
+          if (len && name)
+            {
 #ifdef USE_XIM
-               if (TermWin.fontset)
-                   XmbDrawString(Xdisplay,
-                                 ActiveMenu->win, TermWin.fontset,
-                                 gc,
-                                 ActiveMenu->w - (xoff + Width2Pixel(xright)),
-                                 2 * SHADOW + y + TermWin.font->ascent + 1,
-                                 name, len);
-               else
+              if (TermWin.fontset)
+                XmbDrawString(Xdisplay,
+                              ActiveMenu->win, TermWin.fontset,
+                              gc,
+                              ActiveMenu->w - (xoff + Width2Pixel(xright)),
+                              2 * SHADOW + y + TermWin.font->ascent + 1,
+                              name, len);
+              else
 #endif
-                   XDrawString(Xdisplay, ActiveMenu->win, gc,
-                               ActiveMenu->w - (xoff + Width2Pixel(xright)),
-                               2 * SHADOW + y + TermWin.font->ascent + 1,
-                               name, len);
-           }
-           h = HEIGHT_TEXT + 2 * SHADOW;
-       }
-       y += h;
+                XDrawString(Xdisplay, ActiveMenu->win, gc,
+                            ActiveMenu->w - (xoff + Width2Pixel(xright)),
+                            2 * SHADOW + y + TermWin.font->ascent + 1,
+                            name, len);
+            }
+          h = HEIGHT_TEXT + 2 * SHADOW;
+        }
+      y += h;
     }
 }
 
 void
 rxvt_term::menu_display (void (*update)(rxvt_t *))
 {
-    menu_t         *ActiveMenu = ActiveMenu;
-
-    if (ActiveMenu == NULL)
-       return;
-    if (ActiveMenu->win != None)
-       XDestroyWindow(Xdisplay, ActiveMenu->win);
-    ActiveMenu->win = None;
-    ActiveMenu->item = NULL;
-
-    if (ActiveMenu->parent == NULL)
-       drawbox_menubar (ActiveMenu->x, ActiveMenu->len, +1);
-    ActiveMenu = ActiveMenu->parent;
-    update(r);
+  menu_t         *ActiveMenu = ActiveMenu;
+
+  if (ActiveMenu == NULL)
+    return;
+  if (ActiveMenu->win != None)
+    XDestroyWindow(Xdisplay, ActiveMenu->win);
+  ActiveMenu->win = None;
+  ActiveMenu->item = NULL;
+
+  if (ActiveMenu->parent == NULL)
+    drawbox_menubar (ActiveMenu->x, ActiveMenu->len, +1);
+  ActiveMenu = ActiveMenu->parent;
+  update(r);
 }
 
 void
 rxvt_term::menu_hide_all ()
 {
-    menu_display (rxvt_menu_hide_all);
+  menu_display (rxvt_menu_hide_all);
 }
 
 void
 rxvt_term::menu_hide ()
 {
-    menu_display (rxvt_menu_show);
+  menu_display (rxvt_menu_show);
 }
 
 void
 rxvt_term::menu_clear (menu_t *menu)
 {
-    if (menu != NULL) {
-       menuitem_t     *item = menu->tail;
-
-       while (item != NULL) {
-           menuitem_free (menu, item);
-           /* it didn't get freed ... why? */
-           if (item == menu->tail)
-               return;
-           item = menu->tail;
-       }
-       menu->width = 0;
+  if (menu != NULL)
+    {
+      menuitem_t     *item = menu->tail;
+
+      while (item != NULL)
+        {
+          menuitem_free (menu, item);
+          /* it didn't get freed ... why? */
+          if (item == menu->tail)
+            return;
+          item = menu->tail;
+        }
+      menu->width = 0;
     }
 }
 
 void
 rxvt_term::menubar_clear ()
 {
-    bar_t          *CurrentBar = CurrentBar;
-
-    if (CurrentBar != NULL) {
-       menu_t         *menu = CurrentBar->tail;
-
-       while (menu != NULL) {
-           menu_t         *prev = menu->prev;
-
-           menu_delete (menu);
-           menu = prev;
-       }
-       CurrentBar->head = CurrentBar->tail = NULL;
-
-       if (CurrentBar->title) {
-           free(CurrentBar->title);
-           CurrentBar->title = NULL;
-       }
-       menuarrow_free (0);     /* remove all arrow functions */
+  bar_t          *CurrentBar = CurrentBar;
+
+  if (CurrentBar != NULL)
+    {
+      menu_t         *menu = CurrentBar->tail;
+
+      while (menu != NULL)
+        {
+          menu_t         *prev = menu->prev;
+
+          menu_delete (menu);
+          menu = prev;
+        }
+      CurrentBar->head = CurrentBar->tail = NULL;
+
+      if (CurrentBar->title)
+        {
+          free(CurrentBar->title);
+          CurrentBar->title = NULL;
+        }
+      menuarrow_free (0);      /* remove all arrow functions */
     }
-    ActiveMenu = NULL;
+  ActiveMenu = NULL;
 }
 
 #if (MENUBAR_MAX > 1)
@@ -1028,281 +1127,310 @@ rxvt_term::menubar_clear ()
 bar_t          *
 rxvt_term::menubar_find (const char *name)
 {
-    bar_t          *bar = CurrentBar;
+  bar_t          *bar = CurrentBar;
 
 #ifdef DEBUG_MENUBAR_STACKING
-    fprintf(stderr, "looking for [menu:%s] ...", name ? name : "(nil)");
+  fprintf(stderr, "looking for [menu:%s] ...", name ? name : "(nil)");
 #endif
-    if (bar == NULL || name == NULL)
-       return NULL;
-
-    if (STRLEN(name) && STRCMP(name, "*")) {
-       do {
-           if (!STRCMP(bar->name, name)) {
+  if (bar == NULL || name == NULL)
+    return NULL;
+
+  if (STRLEN(name) && STRCMP(name, "*"))
+    {
+      do
+        {
+          if (!STRCMP(bar->name, name))
+            {
 #ifdef DEBUG_MENUBAR_STACKING
-               fprintf(stderr, " found!\n");
+              fprintf(stderr, " found!\n");
 #endif
-               return bar;
-           }
-           bar = bar->next;
-       }
-       while (bar != CurrentBar);
-       bar = NULL;
+              return bar;
+            }
+          bar = bar->next;
+        }
+      while (bar != CurrentBar);
+      bar = NULL;
     }
 #ifdef DEBUG_MENUBAR_STACKING
-    fprintf(stderr, "%s found!\n", (bar ? "" : " NOT"));
+  fprintf(stderr, "%s found!\n", (bar ? "" : " NOT"));
 #endif
 
-    return bar;
+  return bar;
 }
 
 int
 rxvt_term::menubar_push (const char *name)
 {
-    int             ret = 1;
-    bar_t          *bar;
-
-    if (CurrentBar == NULL) {
-       /* allocate first one */
-       bar = (bar_t *) rxvt_malloc(sizeof(bar_t));
-
-       MEMSET(bar, 0, sizeof(bar_t));
-       /* circular linked-list */
-       bar->next = bar->prev = bar;
-       bar->head = bar->tail = NULL;
-       bar->title = NULL;
-       CurrentBar = bar;
-       Nbars++;
-
-       menubar_clear ();
-    } else {
-       /* find if menu already exists */
-       bar = menubar_find (name);
-       if (bar != NULL) {
-           /* found it, use it */
-           CurrentBar = bar;
-       } else {
-           /* create if needed, or reuse the existing empty menubar */
-           if (CurrentBar->head != NULL) {
-               /* need to malloc another one */
-               if (Nbars < MENUBAR_MAX)
-                   bar = (bar_t *) rxvt_malloc(sizeof(bar_t));
-               else
-                   bar = NULL;
-
-               /* malloc failed or too many menubars, reuse another */
-               if (bar == NULL) {
-                   bar = CurrentBar->next;
-                   ret = -1;
-               } else {
-                   bar->head = bar->tail = NULL;
-                   bar->title = NULL;
-
-                   bar->next = CurrentBar->next;
-                   CurrentBar->next = bar;
-                   bar->prev = CurrentBar;
-                   bar->next->prev = bar;
-
-                   Nbars++;
-               }
-               CurrentBar = bar;
-
-           }
-           menubar_clear ();
-       }
-    }
-
-/* give menubar this name */
-    STRNCPY(CurrentBar->name, name, MAXNAME);
-    CurrentBar->name[MAXNAME - 1] = '\0';
-
-    return ret;
+  int             ret = 1;
+  bar_t          *bar;
+
+  if (CurrentBar == NULL)
+    {
+      /* allocate first one */
+      bar = (bar_t *) rxvt_malloc(sizeof(bar_t));
+
+      MEMSET(bar, 0, sizeof(bar_t));
+      /* circular linked-list */
+      bar->next = bar->prev = bar;
+      bar->head = bar->tail = NULL;
+      bar->title = NULL;
+      CurrentBar = bar;
+      Nbars++;
+
+      menubar_clear ();
+    }
+  else
+    {
+      /* find if menu already exists */
+      bar = menubar_find (name);
+      if (bar != NULL)
+        {
+          /* found it, use it */
+          CurrentBar = bar;
+        }
+      else
+        {
+          /* create if needed, or reuse the existing empty menubar */
+          if (CurrentBar->head != NULL)
+            {
+              /* need to malloc another one */
+              if (Nbars < MENUBAR_MAX)
+                bar = (bar_t *) rxvt_malloc(sizeof(bar_t));
+              else
+                bar = NULL;
+
+              /* malloc failed or too many menubars, reuse another */
+              if (bar == NULL)
+                {
+                  bar = CurrentBar->next;
+                  ret = -1;
+                }
+              else
+                {
+                  bar->head = bar->tail = NULL;
+                  bar->title = NULL;
+
+                  bar->next = CurrentBar->next;
+                  CurrentBar->next = bar;
+                  bar->prev = CurrentBar;
+                  bar->next->prev = bar;
+
+                  Nbars++;
+                }
+              CurrentBar = bar;
+
+            }
+          menubar_clear ();
+        }
+    }
+
+  /* give menubar this name */
+  STRNCPY(CurrentBar->name, name, MAXNAME);
+  CurrentBar->name[MAXNAME - 1] = '\0';
+
+  return ret;
 }
 
 /* switch to a menu called NAME and remove it */
 void
 rxvt_term::menubar_remove (const char *name)
 {
-    bar_t          *bar;
-
-    if ((bar = menubar_find (name)) == NULL)
-       return;
-    CurrentBar = bar;
-
-    do {
-       menubar_clear ();
-       /*
-        * pop a menubar, clean it up first
-        */
-       if (CurrentBar != NULL) {
-           bar_t          *prev = CurrentBar->prev;
-           bar_t          *next = CurrentBar->next;
-
-           if (prev == next && prev == CurrentBar) {   /* only 1 left */
-               prev = NULL;
-               Nbars = 0;      /* safety */
-           } else {
-               next->prev = prev;
-               prev->next = next;
-               Nbars--;
-           }
-
-           free(CurrentBar);
-           CurrentBar = prev;
-       }
-    }
-    while (CurrentBar && !STRCMP(name, "*"));
+  bar_t          *bar;
+
+  if ((bar = menubar_find (name)) == NULL)
+    return;
+  CurrentBar = bar;
+
+  do
+    {
+      menubar_clear ();
+      /*
+       * pop a menubar, clean it up first
+       */
+      if (CurrentBar != NULL)
+        {
+          bar_t          *prev = CurrentBar->prev;
+          bar_t          *next = CurrentBar->next;
+
+          if (prev == next && prev == CurrentBar)
+            {  /* only 1 left */
+              prev = NULL;
+              Nbars = 0;       /* safety */
+            }
+          else
+            {
+              next->prev = prev;
+              prev->next = next;
+              Nbars--;
+            }
+
+          free(CurrentBar);
+          CurrentBar = prev;
+        }
+    }
+  while (CurrentBar && !STRCMP(name, "*"));
 }
 
 void
 rxvt_action_decode(FILE *fp, action_t *act)
 {
-    unsigned char  *str;
-    short           len;
-
-    if (act == NULL || (len = act->len) == 0 || (str = act->str) == NULL)
-       return;
-
-    if (act->type == MenuTerminalAction) {
-       fprintf(fp, "^@");
-       /* can strip trailing ^G from XTerm sequence */
-       if (str[0] == C0_ESC && str[1] == ']' && str[len - 1] == C0_BEL)
-           len--;
-    } else if (str[0] == C0_ESC) {
-       switch (str[1]) {
-       case '[':
-       case ']':
-           break;
-
-       case 'x':
-           /* can strip trailing '\r' from M-x sequence */
-           if (str[len - 1] == '\r')
-               len--;
-           /* FALLTHROUGH */
-
-       default:
-           fprintf(fp, "M-");  /* meta prefix */
-           str++;
-           len--;
-           break;
-       }
+  unsigned char  *str;
+  short           len;
+
+  if (act == NULL || (len = act->len) == 0 || (str = act->str) == NULL)
+    return;
+
+  if (act->type == MenuTerminalAction)
+    {
+      fprintf(fp, "^@");
+      /* can strip trailing ^G from XTerm sequence */
+      if (str[0] == C0_ESC && str[1] == ']' && str[len - 1] == C0_BEL)
+        len--;
     }
-/*
- * control character form is preferred, since backslash-escaping
- * can be really ugly looking when the backslashes themselves also
- * have to be escaped to avoid Shell (or whatever scripting
- * language) interpretation
- */
-    while (len > 0) {
-       unsigned char   ch = *str++;
-
-       switch (ch) {
-       case C0_ESC:
-           fprintf(fp, "\\E");
-           break;              /* escape */
-       case '\r':
-           fprintf(fp, "\\r");
-           break;              /* carriage-return */
-       case '\\':
-           fprintf(fp, "\\\\");
-           break;              /* backslash */
-       case '^':
-           fprintf(fp, "\\^");
-           break;              /* caret */
-       case 127:
-           fprintf(fp, "^?");
-       default:
-           if (ch <= 31)
-               fprintf(fp, "^%c", ('@' + ch));
-           else if (ch > 127)
-               fprintf(fp, "\\%o", ch);
-           else
-               fprintf(fp, "%c", ch);
-           break;
-       }
-       len--;
-    }
-    fprintf(fp, "\n");
+  else if (str[0] == C0_ESC)
+    {
+      switch (str[1])
+        {
+          case '[':
+          case ']':
+            break;
+
+          case 'x':
+            /* can strip trailing '\r' from M-x sequence */
+            if (str[len - 1] == '\r')
+              len--;
+            /* FALLTHROUGH */
+
+          default:
+            fprintf(fp, "M-"); /* meta prefix */
+            str++;
+            len--;
+            break;
+        }
+    }
+  /*
+   * control character form is preferred, since backslash-escaping
+   * can be really ugly looking when the backslashes themselves also
+   * have to be escaped to avoid Shell (or whatever scripting
+   * language) interpretation
+   */
+  while (len > 0)
+    {
+      unsigned char   ch = *str++;
+
+      switch (ch)
+        {
+          case C0_ESC:
+            fprintf(fp, "\\E");
+            break;             /* escape */
+          case '\r':
+            fprintf(fp, "\\r");
+            break;             /* carriage-return */
+          case '\\':
+            fprintf(fp, "\\\\");
+            break;             /* backslash */
+          case '^':
+            fprintf(fp, "\\^");
+            break;             /* caret */
+          case 127:
+            fprintf(fp, "^?");
+          default:
+            if (ch <= 31)
+              fprintf(fp, "^%c", ('@' + ch));
+            else if (ch > 127)
+              fprintf(fp, "\\%o", ch);
+            else
+              fprintf(fp, "%c", ch);
+            break;
+        }
+      len--;
+    }
+  fprintf(fp, "\n");
 }
 
 void
 rxvt_menu_dump(FILE *fp, menu_t *menu)
 {
-    menuitem_t     *item;
-
-/* create a new menu and clear it */
-    fprintf(fp, (menu->parent ? "./%s/*\n" : "/%s/*\n"), menu->name);
-
-    for (item = menu->head; item != NULL; item = item->next) {
-       switch (item->entry.type) {
-       case MenuSubMenu:
-           if (item->entry.submenu.menu == NULL)
-               fprintf(fp, "> %s == NULL\n", item->name);
-           else
-               rxvt_menu_dump(fp, item->entry.submenu.menu);
-           break;
-
-       case MenuLabel:
-           fprintf(fp, "{%s}\n", (STRLEN(item->name) ? item->name : "-"));
-           break;
-
-       case MenuTerminalAction:
-       case MenuAction:
-           fprintf(fp, "{%s}", item->name);
-           if (item->name2 != NULL && STRLEN(item->name2))
-               fprintf(fp, "{%s}", item->name2);
-           fprintf(fp, "\t");
-           rxvt_action_decode(fp, &(item->entry.action));
-           break;
-       }
-    }
-
-    fprintf(fp, (menu->parent ? "../\n" : "/\n\n"));
+  menuitem_t     *item;
+
+  /* create a new menu and clear it */
+  fprintf(fp, (menu->parent ? "./%s/*\n" : "/%s/*\n"), menu->name);
+
+  for (item = menu->head; item != NULL; item = item->next)
+    {
+      switch (item->entry.type)
+        {
+          case MenuSubMenu:
+            if (item->entry.submenu.menu == NULL)
+              fprintf(fp, "> %s == NULL\n", item->name);
+            else
+              rxvt_menu_dump(fp, item->entry.submenu.menu);
+            break;
+
+          case MenuLabel:
+            fprintf(fp, "{%s}\n", (STRLEN(item->name) ? item->name : "-"));
+            break;
+
+          case MenuTerminalAction:
+          case MenuAction:
+            fprintf(fp, "{%s}", item->name);
+            if (item->name2 != NULL && STRLEN(item->name2))
+              fprintf(fp, "{%s}", item->name2);
+            fprintf(fp, "\t");
+            rxvt_action_decode(fp, &(item->entry.action));
+            break;
+        }
+    }
+
+  fprintf(fp, (menu->parent ? "../\n" : "/\n\n"));
 }
 
 void
 rxvt_term::menubar_dump (FILE *fp)
 {
-    bar_t          *bar = CurrentBar;
-    time_t          t;
-
-    if (bar == NULL || fp == NULL)
-       return;
-    time(&t);
-
-    fprintf(fp,
-           "# " APL_SUBCLASS " (%s)  Pid: %u\n# Date: %s\n\n",
-           rs[Rs_name], (unsigned int)getpid(), ctime(&t));
-
-/* dump in reverse order */
-    bar = CurrentBar->prev;
-    do {
-       menu_t         *menu;
-       int             i;
-
-       fprintf(fp, "[menu:%s]\n", bar->name);
-
-       if (bar->title != NULL)
-           fprintf(fp, "[title:%s]\n", bar->title);
-
-       for (i = 0; i < NARROWS; i++) {
-           switch (bar->arrows[i].type) {
-           case MenuTerminalAction:
-           case MenuAction:
-               fprintf(fp, "<%c>", Arrows[i].name);
-               rxvt_action_decode(fp, &(bar->arrows[i]));
-               break;
-           }
-       }
-       fprintf(fp, "\n");
-
-       for (menu = bar->head; menu != NULL; menu = menu->next)
-           rxvt_menu_dump(fp, menu);
-
-       fprintf(fp, "\n[done:%s]\n\n", bar->name);
-       bar = bar->prev;
-    }
-    while (bar != CurrentBar->prev);
+  bar_t          *bar = CurrentBar;
+  time_t          t;
+
+  if (bar == NULL || fp == NULL)
+    return;
+  time(&t);
+
+  fprintf(fp,
+          "# " APL_SUBCLASS " (%s)  Pid: %u\n# Date: %s\n\n",
+          rs[Rs_name], (unsigned int)getpid(), ctime(&t));
+
+  /* dump in reverse order */
+  bar = CurrentBar->prev;
+  do
+    {
+      menu_t         *menu;
+      int             i;
+
+      fprintf(fp, "[menu:%s]\n", bar->name);
+
+      if (bar->title != NULL)
+        fprintf(fp, "[title:%s]\n", bar->title);
+
+      for (i = 0; i < NARROWS; i++)
+        {
+          switch (bar->arrows[i].type)
+            {
+              case MenuTerminalAction:
+              case MenuAction:
+                fprintf(fp, "<%c>", Arrows[i].name);
+                rxvt_action_decode(fp, &(bar->arrows[i]));
+                break;
+            }
+        }
+      fprintf(fp, "\n");
+
+      for (menu = bar->head; menu != NULL; menu = menu->next)
+        rxvt_menu_dump(fp, menu);
+
+      fprintf(fp, "\n[done:%s]\n\n", bar->name);
+      bar = bar->prev;
+    }
+  while (bar != CurrentBar->prev);
 }
 #endif                         /* (MENUBAR_MAX > 1) */
 
@@ -1324,102 +1452,121 @@ rxvt_term::menubar_dump (FILE *fp)
 void
 rxvt_term::menubar_read (const char *filename)
 {
-/* read in a menu from a file */
-    FILE           *fp;
-    char            buffer[256];
-    char           *p, *file, *tag = NULL;
-
-    file = (char *)rxvt_File_find(filename, ".menu", rs[Rs_path]);
-    if (file == NULL)
-       return;
-    fp = fopen(file, "rb");
-    free(file);
-    if (fp == NULL)
-       return;
+  /* read in a menu from a file */
+  FILE           *fp;
+  char            buffer[256];
+  char           *p, *file, *tag = NULL;
+
+  file = (char *)rxvt_File_find(filename, ".menu", rs[Rs_path]);
+  if (file == NULL)
+    return;
+  fp = fopen(file, "rb");
+  free(file);
+  if (fp == NULL)
+    return;
 
 #if (MENUBAR_MAX > 1)
-/* semi-colon delimited */
-    if ((tag = STRCHR(filename, ';')) != NULL) {
-       tag++;
-       if (*tag == '\0')
-           tag = NULL;
+  /* semi-colon delimited */
+  if ((tag = STRCHR(filename, ';')) != NULL)
+    {
+      tag++;
+      if (*tag == '\0')
+        tag = NULL;
     }
 #endif                         /* (MENUBAR_MAX > 1) */
 #ifdef DEBUG_MENU
-    fprintf(stderr, "[read:%s]\n", p);
-    if (tag)
-       fprintf(stderr, "looking for [menu:%s]\n", tag);
+  fprintf(stderr, "[read:%s]\n", p);
+  if (tag)
+    fprintf(stderr, "looking for [menu:%s]\n", tag);
 #endif
 
-    while ((p = fgets(buffer, sizeof(buffer), fp)) != NULL) {
-       int             n;
-
-       if ((n = rxvt_Str_match(p, "[menu")) != 0) {
-           if (tag) {
-               /* looking for [menu:tag] */
-               if (p[n] == ':' && p[n + 1] != ']') {
-                   n++;
-                   n += rxvt_Str_match(p + n, tag);
-                   if (p[n] == ']') {
+  while ((p = fgets(buffer, sizeof(buffer), fp)) != NULL)
+    {
+      int             n;
+
+      if ((n = rxvt_Str_match(p, "[menu")) != 0)
+        {
+          if (tag)
+            {
+              /* looking for [menu:tag] */
+              if (p[n] == ':' && p[n + 1] != ']')
+                {
+                  n++;
+                  n += rxvt_Str_match(p + n, tag);
+                  if (p[n] == ']')
+                    {
 #ifdef DEBUG_MENU
-                       fprintf(stderr, "[menu:%s]\n", tag);
+                      fprintf(stderr, "[menu:%s]\n", tag);
 #endif
-                       break;
-                   }
-               }
-           } else if (p[n] == ':' || p[n] == ']')
-               break;
-       }
+                      break;
+                    }
+                }
+            }
+          else if (p[n] == ':' || p[n] == ']')
+            break;
+        }
     }
 
-/* found [menu], [menu:???] tag */
-    while (p != NULL) {
-       int             n;
+  /* found [menu], [menu:???] tag */
+  while (p != NULL)
+    {
+      int             n;
 
 #ifdef DEBUG_MENU
-       fprintf(stderr, "read line = %s\n", p);
+      fprintf(stderr, "read line = %s\n", p);
 #endif
 
-       /* looking for [done:tag] or [done:] */
-       if ((n = rxvt_Str_match(p, "[done")) != 0) {
-           if (p[n] == ']') {
-               menu_readonly = 1;
-               break;
-           } else if (p[n] == ':') {
-               n++;
-               if (p[n] == ']') {
-                   menu_readonly = 1;
-                   break;
-               } else if (tag) {
-                   n += rxvt_Str_match(p + n, tag);
-                   if (p[n] == ']') {
+      /* looking for [done:tag] or [done:] */
+      if ((n = rxvt_Str_match(p, "[done")) != 0)
+        {
+          if (p[n] == ']')
+            {
+              menu_readonly = 1;
+              break;
+            }
+          else if (p[n] == ':')
+            {
+              n++;
+              if (p[n] == ']')
+                {
+                  menu_readonly = 1;
+                  break;
+                }
+              else if (tag)
+                {
+                  n += rxvt_Str_match(p + n, tag);
+                  if (p[n] == ']')
+                    {
 #ifdef DEBUG_MENU
-                       fprintf(stderr, "[done:%s]\n", tag);
+                      fprintf(stderr, "[done:%s]\n", tag);
 #endif
-                       menu_readonly = 1;
-                       break;
-                   }
-               } else {
-                   /* what? ... skip this line */
-                   p[0] = COMMENT_CHAR;
-               }
-           }
-       }
-       /*
-        * remove leading/trailing space
-        * and strip-off leading/trailing quotes
-        * skip blank or comment lines
-        */
-       rxvt_Str_trim(p);
-       if (*p && *p != '#') {
-           menu_readonly = 0;  /* if case we read another file */
-           menubar_dispatch (p);
-       }
-       /* get another line */
-       p = fgets(buffer, sizeof(buffer), fp);
-    }
-
-    fclose(fp);
+                      menu_readonly = 1;
+                      break;
+                    }
+                }
+              else
+                {
+                  /* what? ... skip this line */
+                  p[0] = COMMENT_CHAR;
+                }
+            }
+        }
+      /*
+       * remove leading/trailing space
+       * and strip-off leading/trailing quotes
+       * skip blank or comment lines
+       */
+      rxvt_Str_trim(p);
+      if (*p && *p != '#')
+        {
+          menu_readonly = 0;   /* if case we read another file */
+          menubar_dispatch (p);
+        }
+      /* get another line */
+      p = fgets(buffer, sizeof(buffer), fp);
+    }
+
+  fclose(fp);
 }
 
 /*
@@ -1428,738 +1575,852 @@ rxvt_term::menubar_read (const char *filename)
 void
 rxvt_term::menubar_dispatch (char *str)
 {
-    int             n, cmd;
-    char           *path, *name, *name2;
-
-    if (menubar_visible(r) && ActiveMenu != NULL)
-       menubar_expose ();
-    else
-       ActiveMenu = NULL;
-
-    cmd = *str;
-    switch (cmd) {
-    case '.':
-    case '/':                  /* absolute & relative path */
-    case MENUITEM_BEG:         /* menuitem */
-       /* add `+' prefix for these cases */
-       cmd = '+';
-       break;
-
-    case '+':
-    case '-':
-       str++;                  /* skip cmd character */
-       break;
-
-    case '<':
+  int             n, cmd;
+  char           *path, *name, *name2;
+
+  if (menubar_visible(r) && ActiveMenu != NULL)
+    menubar_expose ();
+  else
+    ActiveMenu = NULL;
+
+  cmd = *str;
+  switch (cmd)
+    {
+      case '.':
+      case '/':                        /* absolute & relative path */
+      case MENUITEM_BEG:               /* menuitem */
+        /* add `+' prefix for these cases */
+        cmd = '+';
+        break;
+
+      case '+':
+      case '-':
+        str++;                 /* skip cmd character */
+        break;
+
+      case '<':
 #if (MENUBAR_MAX > 1)
-       if (CurrentBar == NULL)
-           break;
+        if (CurrentBar == NULL)
+          break;
 #endif                         /* (MENUBAR_MAX > 1) */
-       if (str[1] && str[2] == '>')    /* arrow commands */
-           menuarrow_add (str);
-       break;
-
-    case '[':                  /* extended command */
-       while (str[0] == '[') {
-           char           *next = (++str);     /* skip leading '[' */
-
-           if (str[0] == ':') {        /* [:command:] */
-               do {
-                   next++;
-                   if ((next = STRCHR(next, ':')) == NULL)
-                       return; /* parse error */
-               }
-               while (next[1] != ']');
-               /* remove and skip ':]' */
-               *next = '\0';
-               next += 2;
-           } else {
-               if ((next = STRCHR(next, ']')) == NULL)
-                   return;     /* parse error */
-               /* remove and skip ']' */
-               *next = '\0';
-               next++;
-           }
-
-           if (str[0] == ':') {
-               int             saved;
-
-               /* try and dispatch it, regardless of read/write status */
-               saved = menu_readonly;
-               menu_readonly = 0;
-               menubar_dispatch (str + 1);
-               menu_readonly = saved;
-           }
-           /* these ones don't require menu stacking */
-           else if (!STRCMP(str, "clear")) {
-               menubar_clear ();
-           } else if (!STRCMP(str, "done") || rxvt_Str_match(str, "done:")) {
-               menu_readonly = 1;
-           } else if (!STRCMP(str, "show")) {
-               map_menuBar (1);
-               menu_readonly = 1;
-           } else if (!STRCMP(str, "hide")) {
-               map_menuBar (0);
-               menu_readonly = 1;
-           } else if ((n = rxvt_Str_match(str, "read:")) != 0) {
-               /* read in a menu from a file */
-               str += n;
-               menubar_read (str);
-           } else if ((n = rxvt_Str_match(str, "title:")) != 0) {
-               str += n;
-               if (CurrentBar != NULL && !menu_readonly) {
-                   if (*str) {
-                       name = rxvt_realloc(CurrentBar->title,
-                                           STRLEN(str) + 1);
-                       if (name != NULL) {
-                           STRCPY(name, str);
-                           CurrentBar->title = name;
-                       }
-                       menubar_expose ();
-                   } else {
-                       free(CurrentBar->title);
-                       CurrentBar->title = NULL;
-                   }
-               }
-           } else if ((n = rxvt_Str_match(str, "pixmap:")) != 0) {
-               str += n;
-               xterm_seq (XTerm_Pixmap, str, CHAR_ST);
-           }
+        if (str[1] && str[2] == '>')   /* arrow commands */
+          menuarrow_add (str);
+        break;
+
+      case '[':                        /* extended command */
+        while (str[0] == '[')
+          {
+            char           *next = (++str);    /* skip leading '[' */
+
+            if (str[0] == ':')
+              {        /* [:command:] */
+                do
+                  {
+                    next++;
+                    if ((next = STRCHR(next, ':')) == NULL)
+                      return;  /* parse error */
+                  }
+                while (next[1] != ']');
+                /* remove and skip ':]' */
+                *next = '\0';
+                next += 2;
+              }
+            else
+              {
+                if ((next = STRCHR(next, ']')) == NULL)
+                  return;      /* parse error */
+                /* remove and skip ']' */
+                *next = '\0';
+                next++;
+              }
+
+            if (str[0] == ':')
+              {
+                int             saved;
+
+                /* try and dispatch it, regardless of read/write status */
+                saved = menu_readonly;
+                menu_readonly = 0;
+                menubar_dispatch (str + 1);
+                menu_readonly = saved;
+              }
+            /* these ones don't require menu stacking */
+            else if (!STRCMP(str, "clear"))
+              {
+                menubar_clear ();
+              }
+            else if (!STRCMP(str, "done") || rxvt_Str_match(str, "done:"))
+              {
+                menu_readonly = 1;
+              }
+            else if (!STRCMP(str, "show"))
+              {
+                map_menuBar (1);
+                menu_readonly = 1;
+              }
+            else if (!STRCMP(str, "hide"))
+              {
+                map_menuBar (0);
+                menu_readonly = 1;
+              }
+            else if ((n = rxvt_Str_match(str, "read:")) != 0)
+              {
+                /* read in a menu from a file */
+                str += n;
+                menubar_read (str);
+              }
+            else if ((n = rxvt_Str_match(str, "title:")) != 0)
+              {
+                str += n;
+                if (CurrentBar != NULL && !menu_readonly)
+                  {
+                    if (*str)
+                      {
+                        name = rxvt_realloc(CurrentBar->title,
+                                            STRLEN(str) + 1);
+                        if (name != NULL)
+                          {
+                            STRCPY(name, str);
+                            CurrentBar->title = name;
+                          }
+                        menubar_expose ();
+                      }
+                    else
+                      {
+                        free(CurrentBar->title);
+                        CurrentBar->title = NULL;
+                      }
+                  }
+              }
+            else if ((n = rxvt_Str_match(str, "pixmap:")) != 0)
+              {
+                str += n;
+                xterm_seq (XTerm_Pixmap, str, CHAR_ST);
+              }
 #if (MENUBAR_MAX > 1)
-           else if ((n = rxvt_Str_match(str, "rm")) != 0) {
-               str += n;
-               switch (str[0]) {
-               case ':':
-                   str++;
-               /* FALLTHROUGH */
-               case '\0':
-               /* FALLTHROUGH */
-               case '*':
-                   menubar_remove (str);
-                   break;
-               }
-               menu_readonly = 1;
-           } else if ((n = rxvt_Str_match(str, "menu")) != 0) {
-               str += n;
-               switch (str[0]) {
-               case ':':
-                   str++;
-                   /* add/access menuBar */
-                   if (*str != '\0' && *str != '*')
-                       menubar_push (str);
-                   break;
-               default:
-                   if (CurrentBar == NULL) {
-                       menubar_push ("default");
-                   }
-               }
-
-               if (CurrentBar != NULL)
-                   menu_readonly = 0;  /* allow menu build commands */
-           } else if (!STRCMP(str, "dump")) {
-               /* dump current menubars to a file */
-               FILE           *fp;
-
-               /* enough space to hold the results */
-               char            buffer[32];
-
-               sprintf(buffer, "/tmp/" APL_SUBCLASS "-%u",
-                       (unsigned int)getpid());
-
-               if ((fp = fopen(buffer, "wb")) != NULL) {
-                   xterm_seq (XTerm_title, buffer, CHAR_ST);
-                   menubar_dump (fp);
-                   fclose(fp);
-               }
-           } else if (!STRCMP(str, "next")) {
-               if (CurrentBar) {
-                   CurrentBar = CurrentBar->next;
-                   menu_readonly = 1;
-               }
-           } else if (!STRCMP(str, "prev")) {
-               if (CurrentBar) {
-                   CurrentBar = CurrentBar->prev;
-                   menu_readonly = 1;
-               }
-           } else if (!STRCMP(str, "swap")) {
-               /* swap the top 2 menus */
-               if (CurrentBar) {
-                   bar_t          *cbprev = CurrentBar->prev;
-                   bar_t          *cbnext = CurrentBar->next;
-
-                   cbprev->next = cbnext;
-                   cbnext->prev = cbprev;
-
-                   CurrentBar->next = cbprev;
-                   CurrentBar->prev = cbprev->prev;
-
-                   cbprev->prev->next = CurrentBar;
-                   cbprev->prev = CurrentBar;
-
-                   CurrentBar = cbprev;
-                   menu_readonly = 1;
-               }
-           }
+            else if ((n = rxvt_Str_match(str, "rm")) != 0)
+              {
+                str += n;
+                switch (str[0])
+                  {
+                    case ':':
+                      str++;
+                      /* FALLTHROUGH */
+                    case '\0':
+                      /* FALLTHROUGH */
+                    case '*':
+                      menubar_remove (str);
+                      break;
+                  }
+                menu_readonly = 1;
+              }
+            else if ((n = rxvt_Str_match(str, "menu")) != 0)
+              {
+                str += n;
+                switch (str[0])
+                  {
+                    case ':':
+                      str++;
+                      /* add/access menuBar */
+                      if (*str != '\0' && *str != '*')
+                        menubar_push (str);
+                      break;
+                    default:
+                      if (CurrentBar == NULL)
+                        {
+                          menubar_push ("default");
+                        }
+                  }
+
+                if (CurrentBar != NULL)
+                  menu_readonly = 0;   /* allow menu build commands */
+              }
+            else if (!STRCMP(str, "dump"))
+              {
+                /* dump current menubars to a file */
+                FILE           *fp;
+
+                /* enough space to hold the results */
+                char            buffer[32];
+
+                sprintf(buffer, "/tmp/" APL_SUBCLASS "-%u",
+                        (unsigned int)getpid());
+
+                if ((fp = fopen(buffer, "wb")) != NULL)
+                  {
+                    xterm_seq (XTerm_title, buffer, CHAR_ST);
+                    menubar_dump (fp);
+                    fclose(fp);
+                  }
+              }
+            else if (!STRCMP(str, "next"))
+              {
+                if (CurrentBar)
+                  {
+                    CurrentBar = CurrentBar->next;
+                    menu_readonly = 1;
+                  }
+              }
+            else if (!STRCMP(str, "prev"))
+              {
+                if (CurrentBar)
+                  {
+                    CurrentBar = CurrentBar->prev;
+                    menu_readonly = 1;
+                  }
+              }
+            else if (!STRCMP(str, "swap"))
+              {
+                /* swap the top 2 menus */
+                if (CurrentBar)
+                  {
+                    bar_t          *cbprev = CurrentBar->prev;
+                    bar_t          *cbnext = CurrentBar->next;
+
+                    cbprev->next = cbnext;
+                    cbnext->prev = cbprev;
+
+                    CurrentBar->next = cbprev;
+                    CurrentBar->prev = cbprev->prev;
+
+                    cbprev->prev->next = CurrentBar;
+                    cbprev->prev = CurrentBar;
+
+                    CurrentBar = cbprev;
+                    menu_readonly = 1;
+                  }
+              }
 #endif                         /* (MENUBAR_MAX > 1) */
-           str = next;
+            str = next;
 
-           BuildMenu = ActiveMenu = NULL;
-           menubar_expose ();
+            BuildMenu = ActiveMenu = NULL;
+            menubar_expose ();
 #ifdef DEBUG_MENUBAR_STACKING
-           fprintf(stderr, "menus are read%s\n",
-                   menu_readonly ? "only" : "/write");
+            fprintf(stderr, "menus are read%s\n",
+                    menu_readonly ? "only" : "/write");
 #endif
-       }
-       return;
-       break;
+
+          }
+        return;
+        break;
     }
 
 #if (MENUBAR_MAX > 1)
-    if (CurrentBar == NULL)
-       return;
-    if (menu_readonly) {
+  if (CurrentBar == NULL)
+    return;
+  if (menu_readonly)
+    {
 #ifdef DEBUG_MENUBAR_STACKING
-       fprintf(stderr, "menus are read%s\n",
-               menu_readonly ? "only" : "/write");
+      fprintf(stderr, "menus are read%s\n",
+              menu_readonly ? "only" : "/write");
 #endif
-       return;
+      return;
     }
 #endif                         /* (MENUBAR_MAX > 1) */
 
-    switch (cmd) {
-    case '+':
-    case '-':
-       path = name = str;
-
-       name2 = NULL;
-       /* parse STR, allow spaces inside (name)  */
-       if (path[0] != '\0') {
-           name = STRCHR(path, MENUITEM_BEG);
-           str = STRCHR(path, MENUITEM_END);
-           if (name != NULL || str != NULL) {
-               if (name == NULL || str == NULL || str <= (name + 1)
-                   || (name > path && name[-1] != '/')) {
-                   rxvt_print_error("menu error <%s>\n", path);
-                   break;
-               }
-               if (str[1] == MENUITEM_BEG) {
-                   name2 = (str + 2);
-                   str = STRCHR(name2, MENUITEM_END);
-
-                   if (str == NULL) {
-                       rxvt_print_error("menu error <%s>\n", path);
-                       break;
-                   }
-                   name2[-2] = '\0';   /* remove prev MENUITEM_END */
-               }
-               if (name > path && name[-1] == '/')
-                   name[-1] = '\0';
-
-               *name++ = '\0'; /* delimit */
-               *str++ = '\0';  /* delimit */
-
-               while (isspace(*str))
-                   str++;      /* skip space */
-           }
+  switch (cmd)
+    {
+      case '+':
+      case '-':
+        path = name = str;
+
+        name2 = NULL;
+        /* parse STR, allow spaces inside (name)  */
+        if (path[0] != '\0')
+          {
+            name = STRCHR(path, MENUITEM_BEG);
+            str = STRCHR(path, MENUITEM_END);
+            if (name != NULL || str != NULL)
+              {
+                if (name == NULL || str == NULL || str <= (name + 1)
+                    || (name > path && name[-1] != '/'))
+                  {
+                    rxvt_print_error("menu error <%s>\n", path);
+                    break;
+                  }
+                if (str[1] == MENUITEM_BEG)
+                  {
+                    name2 = (str + 2);
+                    str = STRCHR(name2, MENUITEM_END);
+
+                    if (str == NULL)
+                      {
+                        rxvt_print_error("menu error <%s>\n", path);
+                        break;
+                      }
+                    name2[-2] = '\0';  /* remove prev MENUITEM_END */
+                  }
+                if (name > path && name[-1] == '/')
+                  name[-1] = '\0';
+
+                *name++ = '\0';        /* delimit */
+                *str++ = '\0'; /* delimit */
+
+                while (isspace(*str))
+                  str++;       /* skip space */
+              }
 #ifdef DEBUG_MENU
-           fprintf(stderr,
-                   "`%c' path = <%s>, name = <%s>, name2 = <%s>, action = <%s>\n",
-                   cmd, (path ? path : "(nil)"), (name ? name : "(nil)"),
-                   (name2 ? name2 : "(nil)"), (str ? str : "(nil)")
-               );
+            fprintf(stderr,
+                    "`%c' path = <%s>, name = <%s>, name2 = <%s>, action = <%s>\n",
+                    cmd, (path ? path : "(nil)"), (name ? name : "(nil)"),
+                    (name2 ? name2 : "(nil)"), (str ? str : "(nil)")
+                   );
 #endif
-       }
-       /* process the different commands */
-       switch (cmd) {
-       case '+':               /* add/replace existing menu or menuitem */
-           if (path[0] != '\0') {
-               int             len;
-
-               path = menu_find_base (&(BuildMenu), path);
-               len = STRLEN(path);
-
-               /* don't allow menus called `*' */
-               if (path[0] == '*') {
-                   menu_clear (BuildMenu);
-                   break;
-               } else if (len >= 2 && !STRCMP((path + len - 2), "/*")) {
-                   path[len - 2] = '\0';
-               }
-               if (path[0] != '\0')
-                   BuildMenu = menu_add (BuildMenu, path);
-           }
-           if (name != NULL && name[0] != '\0')
-               rxvt_menuitem_add(BuildMenu,
-                                 (STRCMP(name, SEPARATOR_NAME) ? name : ""),
-                                 name2, str);
-           break;
-
-       case '-':               /* delete menu entry */
-           if (!STRCMP(path, "/*") && (name == NULL || name[0] == '\0')) {
-               menubar_clear ();
-               BuildMenu = NULL;
-               menubar_expose ();
-               break;
-           } else if (path[0] != '\0') {
-               int             len;
-               menu_t         *menu = BuildMenu;
-
-               path = menu_find_base (&menu, path);
-               len = STRLEN(path);
-
-               /* submenu called `*' clears all menu items */
-               if (path[0] == '*') {
-                   menu_clear (menu);
-                   break;      /* done */
-               } else if (len >= 2 && !STRCMP(&path[len - 2], "/*")) {
-                   /* done */
-                   break;
-               } else if (path[0] != '\0') {
-                   BuildMenu = NULL;
-                   break;
-               } else
-                   BuildMenu = menu;
-           }
-           if (BuildMenu != NULL) {
-               if (name == NULL || name[0] == '\0')
-                   BuildMenu = menu_delete (BuildMenu);
-               else {
-                   const char     *n1;
-                   menuitem_t     *item;
-                   menu_t         *BuildMenu = BuildMenu;
-
-                   n1 = STRCMP(name, SEPARATOR_NAME) ? name : "";
-                   item = rxvt_menuitem_find(BuildMenu, n1);
-                   if (item != NULL && item->entry.type != MenuSubMenu) {
-                       menuitem_free (BuildMenu, item);
-
-                       /* fix up the width */
-                       BuildMenu->width = 0;
-                       for (item = BuildMenu->head; item != NULL;
-                            item = item->next) {
-                           short           l = item->len + item->len2;
-
-                           MAX_IT(BuildMenu->width, l);
-                       }
-                   }
-               }
-               menubar_expose ();
-           }
-           break;
-       }
-       break;
+
+          }
+        /* process the different commands */
+        switch (cmd)
+          {
+            case '+':          /* add/replace existing menu or menuitem */
+              if (path[0] != '\0')
+                {
+                  int             len;
+
+                  path = menu_find_base (&(BuildMenu), path);
+                  len = STRLEN(path);
+
+                  /* don't allow menus called `*' */
+                  if (path[0] == '*')
+                    {
+                      menu_clear (BuildMenu);
+                      break;
+                    }
+                  else if (len >= 2 && !STRCMP((path + len - 2), "/*"))
+                    {
+                      path[len - 2] = '\0';
+                    }
+                  if (path[0] != '\0')
+                    BuildMenu = menu_add (BuildMenu, path);
+                }
+              if (name != NULL && name[0] != '\0')
+                rxvt_menuitem_add(BuildMenu,
+                                  (STRCMP(name, SEPARATOR_NAME) ? name : ""),
+                                  name2, str);
+              break;
+
+            case '-':          /* delete menu entry */
+              if (!STRCMP(path, "/*") && (name == NULL || name[0] == '\0'))
+                {
+                  menubar_clear ();
+                  BuildMenu = NULL;
+                  menubar_expose ();
+                  break;
+                }
+              else if (path[0] != '\0')
+                {
+                  int             len;
+                  menu_t         *menu = BuildMenu;
+
+                  path = menu_find_base (&menu, path);
+                  len = STRLEN(path);
+
+                  /* submenu called `*' clears all menu items */
+                  if (path[0] == '*')
+                    {
+                      menu_clear (menu);
+                      break;   /* done */
+                    }
+                  else if (len >= 2 && !STRCMP(&path[len - 2], "/*"))
+                    {
+                      /* done */
+                      break;
+                    }
+                  else if (path[0] != '\0')
+                    {
+                      BuildMenu = NULL;
+                      break;
+                    }
+                  else
+                    BuildMenu = menu;
+                }
+              if (BuildMenu != NULL)
+                {
+                  if (name == NULL || name[0] == '\0')
+                    BuildMenu = menu_delete (BuildMenu);
+                  else
+                    {
+                      const char     *n1;
+                      menuitem_t     *item;
+                      menu_t         *BuildMenu = BuildMenu;
+
+                      n1 = STRCMP(name, SEPARATOR_NAME) ? name : "";
+                      item = rxvt_menuitem_find(BuildMenu, n1);
+                      if (item != NULL && item->entry.type != MenuSubMenu)
+                        {
+                          menuitem_free (BuildMenu, item);
+
+                          /* fix up the width */
+                          BuildMenu->width = 0;
+                          for (item = BuildMenu->head; item != NULL;
+                               item = item->next)
+                            {
+                              short           l = item->len + item->len2;
+
+                              MAX_IT(BuildMenu->width, l);
+                            }
+                        }
+                    }
+                  menubar_expose ();
+                }
+              break;
+          }
+        break;
     }
 }
 
 void
 rxvt_term::draw_Arrows (int name, int state)
 {
-    GC              top, bot;
+  GC              top, bot;
 
-    int             i;
+  int             i;
 
 #ifdef MENU_SHADOW_IN
-    state = -state;
+  state = -state;
 #endif
-    switch (state) {
-    case +1:
-       top = topShadowGC;
-       bot = botShadowGC;
-       break;                  /* SHADOW_OUT */
-    case -1:
-       top = botShadowGC;
-       bot = topShadowGC;
-       break;                  /* SHADOW_IN */
-    default:
-       top = bot = scrollbarGC;
-       break;                  /* neutral */
-    }
-
-    if (!Arrows_x)
-       return;
-
-    for (i = 0; i < NARROWS; i++) {
-       const int       w = Width2Pixel(1);
-       const int       y = (menuBar_TotalHeight() - w) / 2;
-       int             x = Arrows_x + (5 * Width2Pixel(i)) / 4;
-
-       if (!name || name == Arrows[i].name)
-           rxvt_Draw_Triangle(Xdisplay, menuBar.win, top, bot, x, y, w,
-                              Arrows[i].name);
-    }
-    XFlush(Xdisplay);
+  switch (state)
+    {
+      case +1:
+        top = topShadowGC;
+        bot = botShadowGC;
+        break;                 /* SHADOW_OUT */
+      case -1:
+        top = botShadowGC;
+        bot = topShadowGC;
+        break;                 /* SHADOW_IN */
+      default:
+        top = bot = scrollbarGC;
+        break;                 /* neutral */
+    }
+
+  if (!Arrows_x)
+    return;
+
+  for (i = 0; i < NARROWS; i++)
+    {
+      const int       w = Width2Pixel(1);
+      const int       y = (menuBar_TotalHeight() - w) / 2;
+      int             x = Arrows_x + (5 * Width2Pixel(i)) / 4;
+
+      if (!name || name == Arrows[i].name)
+        rxvt_Draw_Triangle(Xdisplay, menuBar.win, top, bot, x, y, w,
+                           Arrows[i].name);
+    }
+  XFlush(Xdisplay);
 }
 
 void
 rxvt_term::menubar_expose ()
 {
-    menu_t         *menu;
-    int             x;
+  menu_t         *menu;
+  int             x;
 
-    if (!menubar_visible(r) || menuBar.win == 0)
-       return;
+  if (!menubar_visible(r) || menuBar.win == 0)
+    return;
 
-    if (menubarGC == None) {
-       /* Create the graphics context */
-       XGCValues       gcvalue;
+  if (menubarGC == None)
+    {
+      /* Create the graphics context */
+      XGCValues       gcvalue;
 
-       gcvalue.font = TermWin.font->fid;
+      gcvalue.font = TermWin.font->fid;
 
-       gcvalue.foreground = (XDEPTH <= 2 ? PixColors[Color_fg]
-                                         : PixColors[Color_Black]);
-       menubarGC = XCreateGC(Xdisplay, menuBar.win,
-                                   GCForeground | GCFont, &gcvalue);
+      gcvalue.foreground = (XDEPTH <= 2 ? PixColors[Color_fg]
+                            : PixColors[Color_Black]);
+      menubarGC = XCreateGC(Xdisplay, menuBar.win,
+                            GCForeground | GCFont, &gcvalue);
 
     }
-/* make sure the font is correct */
-    XSetFont(Xdisplay, menubarGC, TermWin.font->fid);
-    XSetFont(Xdisplay, botShadowGC, TermWin.font->fid);
-    XClearWindow(Xdisplay, menuBar.win);
+  /* make sure the font is correct */
+  XSetFont(Xdisplay, menubarGC, TermWin.font->fid);
+  XSetFont(Xdisplay, botShadowGC, TermWin.font->fid);
+  XClearWindow(Xdisplay, menuBar.win);
 
-    menu_hide_all ();
+  menu_hide_all ();
 
-    x = 0;
-    if (CurrentBar != NULL) {
-       for (menu = CurrentBar->head; menu != NULL; menu = menu->next) {
-           int             len = menu->len;
+  x = 0;
+  if (CurrentBar != NULL)
+    {
+      for (menu = CurrentBar->head; menu != NULL; menu = menu->next)
+        {
+          int             len = menu->len;
 
-           x = (menu->x + menu->len + HSPACE);
+          x = (menu->x + menu->len + HSPACE);
 
 #ifdef DEBUG_MENU_LAYOUT
-           rxvt_print_menu_descendants(menu);
+          rxvt_print_menu_descendants(menu);
 #endif
 
-           if (x >= TermWin.ncol)
-               len = (TermWin.ncol - (menu->x + HSPACE));
+          if (x >= TermWin.ncol)
+            len = (TermWin.ncol - (menu->x + HSPACE));
 
-           drawbox_menubar (menu->x, len, +1);
+          drawbox_menubar (menu->x, len, +1);
 #ifdef USE_XIM
-           if (TermWin.fontset)
-               XmbDrawString(Xdisplay,
-                             menuBar.win, TermWin.fontset,
-                             menubarGC,
-                             (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2),
-                             menuBar_height() - SHADOW, menu->name, len);
-           else
+          if (TermWin.fontset)
+            XmbDrawString(Xdisplay,
+                          menuBar.win, TermWin.fontset,
+                          menubarGC,
+                          (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2),
+                          menuBar_height() - SHADOW, menu->name, len);
+          else
 #endif
-               XDrawString(Xdisplay, menuBar.win, menubarGC,
-                           (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2),
-                           menuBar_height() - SHADOW, menu->name, len);
-
-           if (x >= TermWin.ncol)
-               break;
-       }
-    }
-    drawbox_menubar (x, TermWin.ncol, (CurrentBar ? +1 : -1));
-
-/* add the menuBar title, if it exists and there's plenty of room */
-    Arrows_x = 0;
-    if (x < TermWin.ncol) {
-       const char     *str;
-       int             ncol;
-       unsigned int    len;
-       char            title[256];
-
-       ncol = (int)TermWin.ncol;
-       if (x < (ncol - (NARROWS + 1))) {
-           ncol -= (NARROWS + 1);
-           Arrows_x = Width2Pixel(ncol);
-       }
-       draw_Arrows (0, +1);
-
-       str = (CurrentBar
-              && CurrentBar->title) ? CurrentBar->title : "%n-%v";
-       for (len = 0; str[0] && len < sizeof(title) - 1; str++) {
-           const char     *s = NULL;
-
-           switch (str[0]) {
-           case '%':
-               str++;
-               switch (str[0]) {
-               case 'n':
-                   s = rs[Rs_name];
-                   break;      /* resource name */
-               case 'v':
-                   s = VERSION;
-                   break;      /* version number */
-               case '%':
-                   s = "%";
-                   break;      /* literal '%' */
-               }
-               if (s != NULL)
-                   while (*s && len < sizeof(title) - 1)
-                       title[len++] = *s++;
-               break;
-
-           default:
-               title[len++] = str[0];
-               break;
-           }
-       }
-       title[len] = '\0';
-
-       ncol -= (x + len + HSPACE);
-       if (len > 0 && ncol >= 0) {
+            XDrawString(Xdisplay, menuBar.win, menubarGC,
+                        (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2),
+                        menuBar_height() - SHADOW, menu->name, len);
+
+          if (x >= TermWin.ncol)
+            break;
+        }
+    }
+  drawbox_menubar (x, TermWin.ncol, (CurrentBar ? +1 : -1));
+
+  /* add the menuBar title, if it exists and there's plenty of room */
+  Arrows_x = 0;
+  if (x < TermWin.ncol)
+    {
+      const char     *str;
+      int             ncol;
+      unsigned int    len;
+      char            title[256];
+
+      ncol = (int)TermWin.ncol;
+      if (x < (ncol - (NARROWS + 1)))
+        {
+          ncol -= (NARROWS + 1);
+          Arrows_x = Width2Pixel(ncol);
+        }
+      draw_Arrows (0, +1);
+
+      str = (CurrentBar
+             && CurrentBar->title) ? CurrentBar->title : "%n-%v";
+      for (len = 0; str[0] && len < sizeof(title) - 1; str++)
+        {
+          const char     *s = NULL;
+
+          switch (str[0])
+            {
+              case '%':
+                str++;
+                switch (str[0])
+                  {
+                    case 'n':
+                      s = rs[Rs_name];
+                      break;   /* resource name */
+                    case 'v':
+                      s = VERSION;
+                      break;   /* version number */
+                    case '%':
+                      s = "%";
+                      break;   /* literal '%' */
+                  }
+                if (s != NULL)
+                  while (*s && len < sizeof(title) - 1)
+                    title[len++] = *s++;
+                break;
+
+              default:
+                title[len++] = str[0];
+                break;
+            }
+        }
+      title[len] = '\0';
+
+      ncol -= (x + len + HSPACE);
+      if (len > 0 && ncol >= 0)
+        {
 #ifdef USE_XIM
-           if (TermWin.fontset)
-               XmbDrawString(Xdisplay,
-                             menuBar.win, TermWin.fontset,
-                             menubarGC,
-                             Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2,
-                             menuBar_height() - SHADOW, title, len);
-           else
+          if (TermWin.fontset)
+            XmbDrawString(Xdisplay,
+                          menuBar.win, TermWin.fontset,
+                          menubarGC,
+                          Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2,
+                          menuBar_height() - SHADOW, title, len);
+          else
 #endif
-               XDrawString(Xdisplay, menuBar.win, menubarGC,
-                           Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2,
-                           menuBar_height() - SHADOW, title, len);
-       }
+            XDrawString(Xdisplay, menuBar.win, menubarGC,
+                        Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2,
+                        menuBar_height() - SHADOW, title, len);
+        }
     }
 }
 
 int
 rxvt_term::menubar_mapping (int map)
 {
-    int             change = 0;
-
-    if (map && !menubar_visible(r)) {
-       menuBar.state = 1;
-       if (menuBar.win == 0)
-           return 0;
-       XMapWindow(Xdisplay, menuBar.win);
-       change = 1;
-    } else if (!map && menubar_visible(r)) {
-       menubar_expose ();
-       menuBar.state = 0;
-       XUnmapWindow(Xdisplay, menuBar.win);
-       change = 1;
-    } else
-       menubar_expose ();
-
-    return change;
+  int             change = 0;
+
+  if (map && !menubar_visible(r))
+    {
+      menuBar.state = 1;
+      if (menuBar.win == 0)
+        return 0;
+      XMapWindow(Xdisplay, menuBar.win);
+      change = 1;
+    }
+  else if (!map && menubar_visible(r))
+    {
+      menubar_expose ();
+      menuBar.state = 0;
+      XUnmapWindow(Xdisplay, menuBar.win);
+      change = 1;
+    }
+  else
+    menubar_expose ();
+
+  return change;
 }
 
 int
 rxvt_term::menu_select (XButtonEvent *ev)
 {
-    menuitem_t     *thisitem, *item = NULL;
-    int             this_y, y;
-    menu_t         *ActiveMenu = ActiveMenu;
-
-    Window          unused_root, unused_child;
-    int             unused_root_x, unused_root_y;
-    unsigned int    unused_mask;
-
-    if (ActiveMenu == NULL)
-       return 0;
-
-    XQueryPointer(Xdisplay, ActiveMenu->win,
-                 &unused_root, &unused_child,
-                 &unused_root_x, &unused_root_y,
-                 &(ev->x), &(ev->y), &unused_mask);
-
-    if (ActiveMenu->parent != NULL && (ev->x < 0 || ev->y < 0)) {
-       menu_hide ();
-       return 1;
-    }
-/* determine the menu item corresponding to the Y index */
-    y = SHADOW;
-    if (ev->x >= 0 && ev->x <= (ActiveMenu->w - SHADOW)) {
-       for (item = ActiveMenu->head; item != NULL; item = item->next) {
-           int             h = HEIGHT_TEXT + 2 * SHADOW;
-
-           if (isSeparator(item->name))
-               h = HEIGHT_SEPARATOR;
-           else if (ev->y >= y && ev->y < (y + h))
-               break;
-           y += h;
-       }
-    }
-    if (item == NULL && ev->type == ButtonRelease) {
-       menu_hide_all ();
-       return 0;
-    }
-    thisitem = item;
-    this_y = y - SHADOW;
-
-/* erase the last item */
-    if (ActiveMenu->item != NULL) {
-       if (ActiveMenu->item != thisitem) {
-           for (y = 0, item = ActiveMenu->head; item != NULL;
-                item = item->next) {
-               int             h;
-
-               if (isSeparator(item->name))
-                   h = HEIGHT_SEPARATOR;
-               else if (item == ActiveMenu->item) {
-                   /* erase old menuitem */
-                   drawbox_menuitem (y, 0);    /* No Shadow */
-                   if (item->entry.type == MenuSubMenu)
-                       drawtriangle (ActiveMenu->w, y, +1);
-                   break;
-               } else
-                   h = HEIGHT_TEXT + 2 * SHADOW;
-               y += h;
-           }
-       } else {
-           switch (ev->type) {
-           case ButtonRelease:
-               switch (item->entry.type) {
-               case MenuLabel:
-               case MenuSubMenu:
-                   menu_hide_all ();
-                   break;
-
-               case MenuAction:
-               case MenuTerminalAction:
-                   drawbox_menuitem (_y, -1);
-                   {
+  menuitem_t     *thisitem, *item = NULL;
+  int             this_y, y;
+  menu_t         *ActiveMenu = ActiveMenu;
+
+  Window          unused_root, unused_child;
+  int             unused_root_x, unused_root_y;
+  unsigned int    unused_mask;
+
+  if (ActiveMenu == NULL)
+    return 0;
+
+  XQueryPointer(Xdisplay, ActiveMenu->win,
+                &unused_root, &unused_child,
+                &unused_root_x, &unused_root_y,
+                &(ev->x), &(ev->y), &unused_mask);
+
+  if (ActiveMenu->parent != NULL && (ev->x < 0 || ev->y < 0))
+    {
+      menu_hide ();
+      return 1;
+    }
+  /* determine the menu item corresponding to the Y index */
+  y = SHADOW;
+  if (ev->x >= 0 && ev->x <= (ActiveMenu->w - SHADOW))
+    {
+      for (item = ActiveMenu->head; item != NULL; item = item->next)
+        {
+          int             h = HEIGHT_TEXT + 2 * SHADOW;
+
+          if (isSeparator(item->name))
+            h = HEIGHT_SEPARATOR;
+          else if (ev->y >= y && ev->y < (y + h))
+            break;
+          y += h;
+        }
+    }
+  if (item == NULL && ev->type == ButtonRelease)
+    {
+      menu_hide_all ();
+      return 0;
+    }
+  thisitem = item;
+  this_y = y - SHADOW;
+
+  /* erase the last item */
+  if (ActiveMenu->item != NULL)
+    {
+      if (ActiveMenu->item != thisitem)
+        {
+          for (y = 0, item = ActiveMenu->head; item != NULL;
+               item = item->next)
+            {
+              int             h;
+
+              if (isSeparator(item->name))
+                h = HEIGHT_SEPARATOR;
+              else if (item == ActiveMenu->item)
+                {
+                  /* erase old menuitem */
+                  drawbox_menuitem (y, 0);     /* No Shadow */
+                  if (item->entry.type == MenuSubMenu)
+                    drawtriangle (ActiveMenu->w, y, +1);
+                  break;
+                }
+              else
+                h = HEIGHT_TEXT + 2 * SHADOW;
+              y += h;
+            }
+        }
+      else
+        {
+          switch (ev->type)
+            {
+              case ButtonRelease:
+                switch (item->entry.type)
+                  {
+                    case MenuLabel:
+                    case MenuSubMenu:
+                      menu_hide_all ();
+                      break;
+
+                    case MenuAction:
+                    case MenuTerminalAction:
+                      drawbox_menuitem (_y, -1);
+                      {
 #ifdef HAVE_NANOSLEEP
-                       struct timespec rqt;
+                        struct timespec rqt;
 
-                       rqt.tv_sec = 0;
-                       rqt.tv_nsec = MENU_DELAY_USEC * 1000;
-                       nanosleep(&rqt, NULL);
+                        rqt.tv_sec = 0;
+                        rqt.tv_nsec = MENU_DELAY_USEC * 1000;
+                        nanosleep(&rqt, NULL);
 #else
-                   /* use select for timing */
-                       struct timeval  tv;
+                        /* use select for timing */
+                        struct timeval  tv;
 
-                       tv.tv_sec = 0;
-                       tv.tv_usec = MENU_DELAY_USEC;
-                       select(0, NULL, NULL, NULL, &tv);
+                        tv.tv_sec = 0;
+                        tv.tv_usec = MENU_DELAY_USEC;
+                        select(0, NULL, NULL, NULL, &tv);
 #endif
-                   }
-                   /* remove menu before sending keys to the application */
-                   menu_hide_all ();
+
+                      }
+                      /* remove menu before sending keys to the application */
+                      menu_hide_all ();
 #ifndef DEBUG_MENU
-                   action_dispatch (&(item->entry.action));
+                      action_dispatch (&(item->entry.action));
 #else                          /* DEBUG_MENU */
-                   fprintf(stderr, "%s: %s\n", item->name,
-                           item->entry.action.str);
+                      fprintf(stderr, "%s: %s\n", item->name,
+                              item->entry.action.str);
 #endif                         /* DEBUG_MENU */
-                   break;
-               }
-               break;
-
-           default:
-               if (item->entry.type == MenuSubMenu)
-                   goto DoMenu;
-               break;
-           }
-           return 0;
-       }
-    }
-  DoMenu:
-    ActiveMenu->item = thisitem;
-    y = this_y;
-    if (item != NULL) {
-       item = ActiveMenu->item;
-       if (item->entry.type != MenuLabel)
-           drawbox_menuitem (y, +1);
-       if (item->entry.type == MenuSubMenu) {
-           int             x;
-
-           drawtriangle (ActiveMenu->w, y, -1);
-
-           x = ev->x + (ActiveMenu->parent
-                        ? ActiveMenu->x
-                        : Width2Pixel(ActiveMenu->x));
-
-           if (x >= item->entry.submenu.menu->x) {
-               ActiveMenu = item->entry.submenu.menu;
-               menu_show ();
-               return 1;
-           }
-       }
+                      break;
+                  }
+                break;
+
+              default:
+                if (item->entry.type == MenuSubMenu)
+                  goto DoMenu;
+                break;
+            }
+          return 0;
+        }
     }
-    return 0;
+DoMenu:
+  ActiveMenu->item = thisitem;
+  y = this_y;
+  if (item != NULL)
+    {
+      item = ActiveMenu->item;
+      if (item->entry.type != MenuLabel)
+        drawbox_menuitem (y, +1);
+      if (item->entry.type == MenuSubMenu)
+        {
+          int             x;
+
+          drawtriangle (ActiveMenu->w, y, -1);
+
+          x = ev->x + (ActiveMenu->parent
+                       ? ActiveMenu->x
+                       : Width2Pixel(ActiveMenu->x));
+
+          if (x >= item->entry.submenu.menu->x)
+            {
+              ActiveMenu = item->entry.submenu.menu;
+              menu_show ();
+              return 1;
+            }
+        }
+    }
+  return 0;
 }
 
 void
 rxvt_term::menubar_select (XButtonEvent *ev)
 {
-    menu_t         *menu = NULL;
-
-/* determine the pulldown menu corresponding to the X index */
-    if (ev->y >= 0 && ev->y <= menuBar_height() && CurrentBar != NULL) {
-       for (menu = CurrentBar->head; menu != NULL; menu = menu->next) {
-           int             x = Width2Pixel(menu->x);
-           int             w = Width2Pixel(menu->len + HSPACE);
-
-           if ((ev->x >= x && ev->x < x + w))
-               break;
-       }
-    }
-    switch (ev->type) {
-    case ButtonRelease:
-       menu_hide_all ();
-       break;
-
-    case ButtonPress:
-       if (menu == NULL && Arrows_x && ev->x >= Arrows_x) {
-           int             i;
-
-           for (i = 0; i < NARROWS; i++) {
-               if (ev->x >= (Arrows_x + (Width2Pixel(4 * i + i)) / 4)
-                   && ev->x < (Arrows_x
-                               + (Width2Pixel(4 * i + i + 4)) / 4)) {
-                   draw_Arrows (Arrows[i].name, -1);
-                   {
+  menu_t         *menu = NULL;
+
+  /* determine the pulldown menu corresponding to the X index */
+  if (ev->y >= 0 && ev->y <= menuBar_height() && CurrentBar != NULL)
+    {
+      for (menu = CurrentBar->head; menu != NULL; menu = menu->next)
+        {
+          int             x = Width2Pixel(menu->x);
+          int             w = Width2Pixel(menu->len + HSPACE);
+
+          if ((ev->x >= x && ev->x < x + w))
+            break;
+        }
+    }
+  switch (ev->type)
+    {
+      case ButtonRelease:
+        menu_hide_all ();
+        break;
+
+      case ButtonPress:
+        if (menu == NULL && Arrows_x && ev->x >= Arrows_x)
+          {
+            int             i;
+
+            for (i = 0; i < NARROWS; i++)
+              {
+                if (ev->x >= (Arrows_x + (Width2Pixel(4 * i + i)) / 4)
+                    && ev->x < (Arrows_x
+                                + (Width2Pixel(4 * i + i + 4)) / 4))
+                  {
+                    draw_Arrows (Arrows[i].name, -1);
+                    {
 #ifdef HAVE_NANOSLEEP
-                       struct timespec rqt;
+                      struct timespec rqt;
 
-                       rqt.tv_sec = 0;
-                       rqt.tv_nsec = MENU_DELAY_USEC * 1000;
-                       nanosleep(&rqt, NULL);
+                      rqt.tv_sec = 0;
+                      rqt.tv_nsec = MENU_DELAY_USEC * 1000;
+                      nanosleep(&rqt, NULL);
 #else
-                   /* use select for timing */
-                       struct timeval  tv;
+                      /* use select for timing */
+                      struct timeval  tv;
 
-                       tv.tv_sec = 0;
-                       tv.tv_usec = MENU_DELAY_USEC;
-                       select(0, NULL, NULL, NULL, &tv);
+                      tv.tv_sec = 0;
+                      tv.tv_usec = MENU_DELAY_USEC;
+                      select(0, NULL, NULL, NULL, &tv);
 #endif
-                   }
-                   draw_Arrows (Arrows[i].name, +1);
+
+                    }
+                    draw_Arrows (Arrows[i].name, +1);
 #ifdef DEBUG_MENUARROWS
-                   fprintf(stderr, "'%c': ", Arrows[i].name);
-
-                   if (CurrentBar == NULL
-                       || (CurrentBar->arrows[i].type != MenuAction
-                           && CurrentBar->arrows[i].type !=
-                           MenuTerminalAction)) {
-                       if (Arrows[i].str != NULL && Arrows[i].str[0])
-                           fprintf(stderr, "(default) \\033%s\n",
-                                   &(Arrows[i].str[2]));
-                   } else {
-                       fprintf(stderr, "%s\n",
-                               CurrentBar->arrows[i].str);
-                   }
+                    fprintf(stderr, "'%c': ", Arrows[i].name);
+
+                    if (CurrentBar == NULL
+                        || (CurrentBar->arrows[i].type != MenuAction
+                            && CurrentBar->arrows[i].type !=
+                            MenuTerminalAction))
+                      {
+                        if (Arrows[i].str != NULL && Arrows[i].str[0])
+                          fprintf(stderr, "(default) \\033%s\n",
+                                  &(Arrows[i].str[2]));
+                      }
+                    else
+                      {
+                        fprintf(stderr, "%s\n",
+                                CurrentBar->arrows[i].str);
+                      }
 #else                          /* DEBUG_MENUARROWS */
-                   if (CurrentBar == NULL
-                       || rxvt_action_dispatch(r,
-                                               &(CurrentBar->arrows[i]))
-                      ) {
-                       if (Arrows[i].str != NULL && Arrows[i].str[0] != 0)
-                           tt_write ((Arrows[i].str + 1),
-                                         Arrows[i].str[0]);
-                   }
+                    if (CurrentBar == NULL
+                        || rxvt_action_dispatch(r,
+                                                &(CurrentBar->arrows[i]))
+                       )
+                      {
+                        if (Arrows[i].str != NULL && Arrows[i].str[0] != 0)
+                          tt_write ((Arrows[i].str + 1),
+                                    Arrows[i].str[0]);
+                      }
 #endif                         /* DEBUG_MENUARROWS */
-                   return;
-               }
-           }
-       }
-       /* FALLTHROUGH */
-
-    default:
-       /*
-        * press menubar or move to a new entry
-        */
-       if (menu != NULL && menu != ActiveMenu) {
-           menu_hide_all ();   /* pop down old menu */
-           ActiveMenu = menu;
-           menu_show ();       /* pop up new menu */
-       }
-       break;
+                    return;
+                  }
+              }
+          }
+        /* FALLTHROUGH */
+
+      default:
+        /*
+         * press menubar or move to a new entry
+         */
+        if (menu != NULL && menu != ActiveMenu)
+          {
+            menu_hide_all ();  /* pop down old menu */
+            ActiveMenu = menu;
+            menu_show ();      /* pop up new menu */
+          }
+        break;
     }
 }
 
@@ -2170,45 +2431,47 @@ rxvt_term::menubar_select (XButtonEvent *ev)
 void
 rxvt_term::menubar_control (XButtonEvent *ev)
 {
-    switch (ev->type) {
-    case ButtonPress:
-       if (ev->button == Button1)
-           menubar_select (ev);
-       break;
-
-    case ButtonRelease:
-       if (ev->button == Button1)
-           menu_select (ev);
-       break;
-
-    case MotionNotify:
-       while (XCheckTypedWindowEvent(Xdisplay, TermWin.parent[0],
-                                     MotionNotify, (XEvent *) ev)) ;
-
-       if (ActiveMenu)
-           while (menu_select (ev)) ;
-       else
-           ev->y = -1;
-       if (ev->y < 0) {
-           Window          unused_root, unused_child;
-           int             unused_root_x, unused_root_y;
-           unsigned int    unused_mask;
-
-           XQueryPointer(Xdisplay, menuBar.win,
-                         &unused_root, &unused_child,
-                         &unused_root_x, &unused_root_y,
-                         &(ev->x), &(ev->y), &unused_mask);
-           menubar_select (ev);
-       }
-       break;
+  switch (ev->type)
+    {
+      case ButtonPress:
+        if (ev->button == Button1)
+          menubar_select (ev);
+        break;
+
+      case ButtonRelease:
+        if (ev->button == Button1)
+          menu_select (ev);
+        break;
+
+      case MotionNotify:
+        while (XCheckTypedWindowEvent(Xdisplay, TermWin.parent[0],
+                                      MotionNotify, (XEvent *) ev)) ;
+
+        if (ActiveMenu)
+          while (menu_select (ev)) ;
+        else
+          ev->y = -1;
+        if (ev->y < 0)
+          {
+            Window          unused_root, unused_child;
+            int             unused_root_x, unused_root_y;
+            unsigned int    unused_mask;
+
+            XQueryPointer(Xdisplay, menuBar.win,
+                          &unused_root, &unused_child,
+                          &unused_root_x, &unused_root_y,
+                          &(ev->x), &(ev->y), &unused_mask);
+            menubar_select (ev);
+          }
+        break;
     }
 }
 
 void
 rxvt_term::map_menuBar (int map)
 {
-    if (menubar_mapping (map))
-       resize_all_windows (0, 0, 0);
+  if (menubar_mapping (map))
+    resize_all_windows (0, 0, 0);
 }
 #endif
 /*----------------------- end-of-file (C source) -----------------------*/
index 01f79e6..ad7d061 100644 (file)
@@ -37,9 +37,9 @@ rxvt_strdup (const char *str)
 char           *
 rxvt_r_basename(const char *str)
 {
-    char           *base = STRRCHR(str, '/');
+  char           *base = STRRCHR(str, '/');
 
-    return (char *)(base ? base + 1 : str);
+  return (char *)(base ? base + 1 : str);
 }
 
 /*
@@ -49,13 +49,13 @@ rxvt_r_basename(const char *str)
 void
 rxvt_print_error(const char *fmt,...)
 {
-    va_list         arg_ptr;
+  va_list         arg_ptr;
 
-    va_start(arg_ptr, fmt);
-    fprintf(stderr, APL_NAME ": ");
-    vfprintf(stderr, fmt, arg_ptr);
-    fprintf(stderr, "\n");
-    va_end(arg_ptr);
+  va_start(arg_ptr, fmt);
+  fprintf(stderr, APL_NAME ": ");
+  vfprintf(stderr, fmt, arg_ptr);
+  fprintf(stderr, "\n");
+  va_end(arg_ptr);
 }
 
 /*
@@ -70,19 +70,19 @@ rxvt_print_error(const char *fmt,...)
 int
 rxvt_Str_match(const char *s1, const char *s2)
 {
-    int             n = STRLEN(s2);
+  int             n = STRLEN(s2);
 
-    return ((STRNCMP(s1, s2, n) == 0) ? n : 0);
+  return ((STRNCMP(s1, s2, n) == 0) ? n : 0);
 }
 
 /* EXTPROTO */
 const char     *
 rxvt_Str_skip_space(const char *str)
 {
-    if (str)
-       while (*str && isspace(*str))
-           str++;
-    return str;
+  if (str)
+    while (*str && isspace(*str))
+      str++;
+  return str;
 }
 
 /*
@@ -93,33 +93,34 @@ rxvt_Str_skip_space(const char *str)
 char           *
 rxvt_Str_trim(char *str)
 {
-    char           *r, *s;
-    int             n;
-
-    if (!str || !*str)         /* shortcut */
-       return str;
-
-/* skip leading spaces */
-    for (s = str; *s && isspace(*s); s++) ;
-/* goto end of string */
-    for (n = 0, r = s; *r++; n++) ;
-    r -= 2;
-/* dump return */
-    if (n > 0 && *r == '\n')
-       n--, r--;
-/* backtrack along trailing spaces */
-    for (; n > 0 && isspace(*r); r--, n--) ;
-/* skip matching leading/trailing quotes */
-    if (*s == '"' && *r == '"' && n > 1) {
-       s++;
-       n -= 2;
-    }
-/* copy back over: forwards copy */
-    for (r = str; n; n--)
-       *r++ = *s++;
-    *r = '\0';
+  char           *r, *s;
+  int             n;
 
+  if (!str || !*str)           /* shortcut */
     return str;
+
+  /* skip leading spaces */
+  for (s = str; *s && isspace(*s); s++) ;
+  /* goto end of string */
+  for (n = 0, r = s; *r++; n++) ;
+  r -= 2;
+  /* dump return */
+  if (n > 0 && *r == '\n')
+    n--, r--;
+  /* backtrack along trailing spaces */
+  for (; n > 0 && isspace(*r); r--, n--) ;
+  /* skip matching leading/trailing quotes */
+  if (*s == '"' && *r == '"' && n > 1)
+    {
+      s++;
+      n -= 2;
+    }
+  /* copy back over: forwards copy */
+  for (r = str; n; n--)
+    *r++ = *s++;
+  *r = '\0';
+
+  return str;
 }
 
 /*
@@ -140,64 +141,72 @@ rxvt_Str_trim(char *str)
 int
 rxvt_Str_escaped(char *str)
 {
-    char            ch, *s, *d;
-    int             i, num, append = 0;
-
-    if (!str || !*str)
-       return 0;
-
-    d = s = str;
-
-    if (*s == 'M' && s[1] == '-') {
-       /* Emacs convenience, replace leading `M-..' with `\E..' */
-       *d++ = C0_ESC;
-       s += 2;
-       if (toupper(*s) == 'X')
-           /* append carriage-return for `M-xcommand' */
-           for (*d++ = 'x', append = '\r', s++; isspace(*s); s++) ;
+  char            ch, *s, *d;
+  int             i, num, append = 0;
+
+  if (!str || !*str)
+    return 0;
+
+  d = s = str;
+
+  if (*s == 'M' && s[1] == '-')
+    {
+      /* Emacs convenience, replace leading `M-..' with `\E..' */
+      *d++ = C0_ESC;
+      s += 2;
+      if (toupper(*s) == 'X')
+        /* append carriage-return for `M-xcommand' */
+        for (*d++ = 'x', append = '\r', s++; isspace(*s); s++) ;
     }
-    for (; (ch = *s++);) {
-       if (ch == '\\') {
-           ch = *s++;
-           if (ch >= '0' && ch <= '7') {       /* octal */
-               num = ch - '0';
-               for (i = 0; i < 2; i++, s++) {
-                   ch = *s;
-                   if (ch < '0' || ch > '7')
-                       break;
-                   num = num * 8 + ch - '0';
-               }
-               ch = (char)num;
-           } else if (ch == 'a')
-               ch = C0_BEL;    /* bell */
-           else if (ch == 'b')
-               ch = C0_BS;     /* backspace */
-           else if (ch == 'E' || ch == 'e')
-               ch = C0_ESC;    /* escape */
-           else if (ch == 'n')
-               ch = '\n';      /* newline */
-           else if (ch == 'r')
-               ch = '\r';      /* carriage-return */
-           else if (ch == 't')
-               ch = C0_HT;     /* tab */
-       } else if (ch == '^') {
-           ch = *s++;
-           ch = toupper(ch);
-           ch = (ch == '?' ? 127 : (ch - '@'));
-       }
-       *d++ = ch;
+  for (; (ch = *s++);)
+    {
+      if (ch == '\\')
+        {
+          ch = *s++;
+          if (ch >= '0' && ch <= '7')
+            {  /* octal */
+              num = ch - '0';
+              for (i = 0; i < 2; i++, s++)
+                {
+                  ch = *s;
+                  if (ch < '0' || ch > '7')
+                    break;
+                  num = num * 8 + ch - '0';
+                }
+              ch = (char)num;
+            }
+          else if (ch == 'a')
+            ch = C0_BEL;       /* bell */
+          else if (ch == 'b')
+            ch = C0_BS;        /* backspace */
+          else if (ch == 'E' || ch == 'e')
+            ch = C0_ESC;       /* escape */
+          else if (ch == 'n')
+            ch = '\n'; /* newline */
+          else if (ch == 'r')
+            ch = '\r'; /* carriage-return */
+          else if (ch == 't')
+            ch = C0_HT;        /* tab */
+        }
+      else if (ch == '^')
+        {
+          ch = *s++;
+          ch = toupper(ch);
+          ch = (ch == '?' ? 127 : (ch - '@'));
+        }
+      *d++ = ch;
     }
 
-/* ESC] is an XTerm escape sequence, must be terminated */
-    if (*str == '\0' && str[1] == C0_ESC && str[2] == ']')
-       append = CHAR_ST;
+  /* ESC] is an XTerm escape sequence, must be terminated */
+  if (*str == '\0' && str[1] == C0_ESC && str[2] == ']')
+    append = CHAR_ST;
 
-/* add trailing character as required */
-    if (append && d[-1] != append)
-       *d++ = append;
-    *d = '\0';
+  /* add trailing character as required */
+  if (append && d[-1] != append)
+    *d++ = append;
+  *d = '\0';
 
-    return (d - str);
+  return (d - str);
 }
 
 /*
@@ -210,29 +219,30 @@ rxvt_Str_escaped(char *str)
 char          **
 rxvt_splitcommastring(const char *cs)
 {
-    int             l, n, p;
-    const char     *s, *t;
-    char          **ret;
-
-    if ((s = cs) == NULL)
-       s = "";
-
-    for (n = 1, t = s; *t; t++)
-       if (*t == ',')
-           n++;
-    ret = (char **)malloc((n + 1) * sizeof(char *));
-    ret[n] = NULL;
-
-    for (l = 0, t = s; l < n; l++) {
-       for ( ; *t && *t != ','; t++) ;
-       p = t - s;
-       ret[l] = (char *)malloc(p + 1);
-       strncpy(ret[l], s, p);
-       ret[l][p] = '\0';
-       rxvt_Str_trim(ret[l]);
-       s = ++t;
+  int             l, n, p;
+  const char     *s, *t;
+  char          **ret;
+
+  if ((s = cs) == NULL)
+    s = "";
+
+  for (n = 1, t = s; *t; t++)
+    if (*t == ',')
+      n++;
+  ret = (char **)malloc((n + 1) * sizeof(char *));
+  ret[n] = NULL;
+
+  for (l = 0, t = s; l < n; l++)
+    {
+      for ( ; *t && *t != ','; t++) ;
+      p = t - s;
+      ret[l] = (char *)malloc(p + 1);
+      strncpy(ret[l], s, p);
+      ret[l][p] = '\0';
+      rxvt_Str_trim(ret[l]);
+      s = ++t;
     }
-    return ret;
+  return ret;
 }
 
 /*----------------------------------------------------------------------*
@@ -252,93 +262,97 @@ rxvt_splitcommastring(const char *cs)
 char           *
 rxvt_File_search_path(const char *pathlist, const char *file, const char *ext)
 {
-    int             maxpath, len;
-    const char     *p, *path;
-    char            name[256];
+  int             maxpath, len;
+  const char     *p, *path;
+  char            name[256];
 
-    if (!access(file, R_OK))   /* found (plain name) in current directory */
-       return STRDUP(file);
+  if (!access(file, R_OK))     /* found (plain name) in current directory */
+    return STRDUP(file);
 
-/* semi-colon delimited */
-    if ((p = STRCHR(file, ';')))
-       len = (p - file);
-    else
-       len = STRLEN(file);
+  /* semi-colon delimited */
+  if ((p = STRCHR(file, ';')))
+    len = (p - file);
+  else
+    len = STRLEN(file);
 
 #ifdef DEBUG_SEARCH_PATH
-    getcwd(name, sizeof(name));
-    fprintf(stderr, "pwd: \"%s\"\n", name);
-    fprintf(stderr, "find: \"%.*s\"\n", len, file);
+  getcwd(name, sizeof(name));
+  fprintf(stderr, "pwd: \"%s\"\n", name);
+  fprintf(stderr, "find: \"%.*s\"\n", len, file);
 #endif
 
-/* leave room for an extra '/' and trailing '\0' */
-    maxpath = sizeof(name) - (len + (ext ? STRLEN(ext) : 0) + 2);
-    if (maxpath <= 0)
-       return NULL;
-
-/* check if we can find it now */
-    STRNCPY(name, file, len);
-    name[len] = '\0';
-
-    if (!access(name, R_OK))
-       return STRDUP(name);
-    if (ext) {
-       STRCAT(name, ext);
-       if (!access(name, R_OK))
-           return STRDUP(name);
+  /* leave room for an extra '/' and trailing '\0' */
+  maxpath = sizeof(name) - (len + (ext ? STRLEN(ext) : 0) + 2);
+  if (maxpath <= 0)
+    return NULL;
+
+  /* check if we can find it now */
+  STRNCPY(name, file, len);
+  name[len] = '\0';
+
+  if (!access(name, R_OK))
+    return STRDUP(name);
+  if (ext)
+    {
+      STRCAT(name, ext);
+      if (!access(name, R_OK))
+        return STRDUP(name);
     }
-    for (path = pathlist; path != NULL && *path != '\0'; path = p) {
-       int             n;
-
-       /* colon delimited */
-       if ((p = STRCHR(path, ':')) == NULL)
-           p = STRCHR(path, '\0');
-
-       n = (p - path);
-       if (*p != '\0')
-           p++;
-
-       if (n > 0 && n <= maxpath) {
-           STRNCPY(name, path, n);
-           if (name[n - 1] != '/')
-               name[n++] = '/';
-           name[n] = '\0';
-           STRNCAT(name, file, len);
-
-           if (!access(name, R_OK))
-               return STRDUP(name);
-           if (ext) {
-               STRCAT(name, ext);
-               if (!access(name, R_OK))
-                   return STRDUP(name);
-           }
-       }
+  for (path = pathlist; path != NULL && *path != '\0'; path = p)
+    {
+      int             n;
+
+      /* colon delimited */
+      if ((p = STRCHR(path, ':')) == NULL)
+        p = STRCHR(path, '\0');
+
+      n = (p - path);
+      if (*p != '\0')
+        p++;
+
+      if (n > 0 && n <= maxpath)
+        {
+          STRNCPY(name, path, n);
+          if (name[n - 1] != '/')
+            name[n++] = '/';
+          name[n] = '\0';
+          STRNCAT(name, file, len);
+
+          if (!access(name, R_OK))
+            return STRDUP(name);
+          if (ext)
+            {
+              STRCAT(name, ext);
+              if (!access(name, R_OK))
+                return STRDUP(name);
+            }
+        }
     }
-    return NULL;
+  return NULL;
 }
 
 /* EXTPROTO */
 char           *
 rxvt_File_find(const char *file, const char *ext, const char *path)
 {
-    char           *f;
+  char           *f;
 
-    if (file == NULL || *file == '\0')
-       return NULL;
+  if (file == NULL || *file == '\0')
+    return NULL;
 
-/* search environment variables here too */
-    if ((f = rxvt_File_search_path(path, file, ext)) == NULL)
+  /* search environment variables here too */
+  if ((f = rxvt_File_search_path(path, file, ext)) == NULL)
 #ifdef PATH_ENV
-       if ((f = rxvt_File_search_path(getenv(PATH_ENV), file, ext)) == NULL)
+    if ((f = rxvt_File_search_path(getenv(PATH_ENV), file, ext)) == NULL)
 #endif
-           f = rxvt_File_search_path(getenv("PATH"), file, ext);
+      f = rxvt_File_search_path(getenv("PATH"), file, ext);
 
 #ifdef DEBUG_SEARCH_PATH
-    if (f)
-       fprintf(stderr, "found: \"%s\"\n", f);
+  if (f)
+    fprintf(stderr, "found: \"%s\"\n", f);
 #endif
 
-    return f;
+  return f;
 }
 #endif                         /* defined (XPM_BACKGROUND) || (MENUBAR_MAX) */
 
@@ -354,16 +368,17 @@ rxvt_File_find(const char *file, const char *ext, const char *path)
 void
 rxvt_Draw_Shadow(Display *Xdisplay, Window win, GC topShadow, GC botShadow, int x, int y, int w, int h)
 {
-    int             shadow;
-
-    shadow = (w == 0 || h == 0) ? 1 : SHADOW;
-    w += x - 1;
-    h += y - 1;
-    for (; shadow-- > 0; x++, y++, w--, h--) {
-       XDrawLine(Xdisplay, win, topShadow, x, y, w, y);
-       XDrawLine(Xdisplay, win, topShadow, x, y, x, h);
-       XDrawLine(Xdisplay, win, botShadow, w, h, w, y + 1);
-       XDrawLine(Xdisplay, win, botShadow, w, h, x + 1, h);
+  int             shadow;
+
+  shadow = (w == 0 || h == 0) ? 1 : SHADOW;
+  w += x - 1;
+  h += y - 1;
+  for (; shadow-- > 0; x++, y++, w--, h--)
+    {
+      XDrawLine(Xdisplay, win, topShadow, x, y, w, y);
+      XDrawLine(Xdisplay, win, topShadow, x, y, x, h);
+      XDrawLine(Xdisplay, win, botShadow, w, h, w, y + 1);
+      XDrawLine(Xdisplay, win, botShadow, w, h, x + 1, h);
     }
 }
 #endif
@@ -374,38 +389,40 @@ rxvt_Draw_Shadow(Display *Xdisplay, Window win, GC topShadow, GC botShadow, int
 void
 rxvt_Draw_Triangle(Display *Xdisplay, Window win, GC topShadow, GC botShadow, int x, int y, int w, int type)
 {
-    switch (type) {
-    case 'r':                  /* right triangle */
-       XDrawLine(Xdisplay, win, topShadow, x, y, x, y + w);
-       XDrawLine(Xdisplay, win, topShadow, x, y, x + w, y + w / 2);
-       XDrawLine(Xdisplay, win, botShadow, x, y + w, x + w, y + w / 2);
-       break;
-
-    case 'l':                  /* left triangle */
-       XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x + w, y);
-       XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x, y + w / 2);
-       XDrawLine(Xdisplay, win, topShadow, x, y + w / 2, x + w, y);
-       break;
-
-    case 'd':                  /* down triangle */
-       XDrawLine(Xdisplay, win, topShadow, x, y, x + w / 2, y + w);
-       XDrawLine(Xdisplay, win, topShadow, x, y, x + w, y);
-       XDrawLine(Xdisplay, win, botShadow, x + w, y, x + w / 2, y + w);
-       break;
-
-    case 'u':                  /* up triangle */
-       XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x + w / 2, y);
-       XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x, y + w);
-       XDrawLine(Xdisplay, win, topShadow, x, y + w, x + w / 2, y);
-       break;
+  switch (type)
+    {
+      case 'r':                        /* right triangle */
+        XDrawLine(Xdisplay, win, topShadow, x, y, x, y + w);
+        XDrawLine(Xdisplay, win, topShadow, x, y, x + w, y + w / 2);
+        XDrawLine(Xdisplay, win, botShadow, x, y + w, x + w, y + w / 2);
+        break;
+
+      case 'l':                        /* left triangle */
+        XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x + w, y);
+        XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x, y + w / 2);
+        XDrawLine(Xdisplay, win, topShadow, x, y + w / 2, x + w, y);
+        break;
+
+      case 'd':                        /* down triangle */
+        XDrawLine(Xdisplay, win, topShadow, x, y, x + w / 2, y + w);
+        XDrawLine(Xdisplay, win, topShadow, x, y, x + w, y);
+        XDrawLine(Xdisplay, win, botShadow, x + w, y, x + w / 2, y + w);
+        break;
+
+      case 'u':                        /* up triangle */
+        XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x + w / 2, y);
+        XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x, y + w);
+        XDrawLine(Xdisplay, win, topShadow, x, y + w, x + w / 2, y);
+        break;
 #if 0
-    case 's':                  /* square */
-       XDrawLine(Xdisplay, win, topShadow, x + w, y, x, y);
-       XDrawLine(Xdisplay, win, topShadow, x, y, x, y + w);
-       XDrawLine(Xdisplay, win, botShadow, x, y + w, x + w, y + w);
-       XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x + w, y);
-       break;
+      case 's':                        /* square */
+        XDrawLine(Xdisplay, win, topShadow, x + w, y, x, y);
+        XDrawLine(Xdisplay, win, topShadow, x, y, x, y + w);
+        XDrawLine(Xdisplay, win, botShadow, x, y + w, x + w, y + w);
+        XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x + w, y);
+        break;
 #endif
+
     }
 }
 #endif
index 0223780..627b90a 100644 (file)
 char           *
 rxvt_network_display(const char *display)
 {
-    char            buffer[1024], *rval = NULL;
-    struct ifconf   ifc;
-    struct ifreq   *ifr;
-    int             i, skfd;
+  char            buffer[1024], *rval = NULL;
+  struct ifconf   ifc;
+  struct ifreq   *ifr;
+  int             i, skfd;
 
-    if (display[0] != ':' && STRNCMP(display, "unix:", 5))
-       return (char *) display;                /* nothing to do */
+  if (display[0] != ':' && STRNCMP(display, "unix:", 5))
+    return (char *) display;           /* nothing to do */
 
-    ifc.ifc_len = sizeof(buffer);      /* Get names of all ifaces */
-    ifc.ifc_buf = buffer;
+  ifc.ifc_len = sizeof(buffer);        /* Get names of all ifaces */
+  ifc.ifc_buf = buffer;
 
-    if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-       perror("socket");
-       return NULL;
+  if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+    {
+      perror("socket");
+      return NULL;
     }
-    if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) {
-       perror("SIOCGIFCONF");
-       close(skfd);
-       return NULL;
+  if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
+    {
+      perror("SIOCGIFCONF");
+      close(skfd);
+      return NULL;
     }
-    for (i = 0, ifr = ifc.ifc_req;
-        i < (ifc.ifc_len / sizeof(struct ifreq));
-        i++, ifr++) {
-       struct ifreq    ifr2;
+  for (i = 0, ifr = ifc.ifc_req;
+       i < (ifc.ifc_len / sizeof(struct ifreq));
+       i++, ifr++)
+    {
+      struct ifreq    ifr2;
 
-       STRCPY(ifr2.ifr_name, ifr->ifr_name);
-       if (ioctl(skfd, SIOCGIFADDR, &ifr2) >= 0) {
-           unsigned long   addr;
-           struct sockaddr_in *p_addr;
+      STRCPY(ifr2.ifr_name, ifr->ifr_name);
+      if (ioctl(skfd, SIOCGIFADDR, &ifr2) >= 0)
+        {
+          unsigned long   addr;
+          struct sockaddr_in *p_addr;
 
-           p_addr = (struct sockaddr_in *)&(ifr2.ifr_addr);
-           addr = htonl((unsigned long)p_addr->sin_addr.s_addr);
+          p_addr = (struct sockaddr_in *)&(ifr2.ifr_addr);
+          addr = htonl((unsigned long)p_addr->sin_addr.s_addr);
 
-       /*
-        * not "0.0.0.0" or "127.0.0.1" - so format the address
-        */
-           if (addr && addr != 0x7F000001) {
-               char           *colon = STRCHR(display, ':');
+          /*
+           * not "0.0.0.0" or "127.0.0.1" - so format the address
+           */
+          if (addr && addr != 0x7F000001)
+            {
+              char           *colon = STRCHR(display, ':');
 
-               if (colon == NULL)
-                   colon = ":0.0";
+              if (colon == NULL)
+                colon = ":0.0";
 
-               rval = rxvt_malloc(STRLEN(colon) + 16);
-               sprintf(rval, "%d.%d.%d.%d%s",
-                       (int)((addr >> 030) & 0xFF),
-                       (int)((addr >> 020) & 0xFF),
-                       (int)((addr >> 010) & 0xFF),
-                       (int)(addr & 0xFF), colon);
-               break;
-           }
-       }
+              rval = rxvt_malloc(STRLEN(colon) + 16);
+              sprintf(rval, "%d.%d.%d.%d%s",
+                      (int)((addr >> 030) & 0xFF),
+                      (int)((addr >> 020) & 0xFF),
+                      (int)((addr >> 010) & 0xFF),
+                      (int)(addr & 0xFF), colon);
+              break;
+            }
+        }
     }
 
-    close(skfd);
-    return rval;
+  close(skfd);
+  return rval;
 }
 #endif                         /* DISPLAY_IS_IP */
 /*----------------------- end-of-file (C source) -----------------------*/
index 592ec35..23ccb58 100644 (file)
@@ -185,7 +185,7 @@ rxvt_term::scr_reset ()
       talloc = new rxvt_salloc (ncol * sizeof (text_t));
       ralloc = new rxvt_salloc (ncol * sizeof (rend_t));
     }
-     
+
   if (prev_nrow == 0)
     {
       /*
@@ -339,7 +339,7 @@ rxvt_term::scr_reset ()
           int common = min (prev_ncol, ncol);
           rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t));
           rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t));
-     
+
           for (p = 0; p < total_rows; p++)
             {
               if (screen.text[p])
@@ -503,25 +503,26 @@ rxvt_term::scr_poweron ()
 void
 rxvt_term::scr_cursor (int mode)
 {
-    screen_t       *s;
+  screen_t       *s;
 
-    D_SCREEN((stderr, "rxvt_scr_cursor(%c)", mode));
+  D_SCREEN((stderr, "rxvt_scr_cursor(%c)", mode));
 
 #if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR)
-    if (current_screen == SECONDARY)
-        s = &(swap);
-    else
+  if (current_screen == SECONDARY)
+    s = &(swap);
+  else
 #endif
-        s = &(screen);
-    switch (mode) {
-    case SAVE:
+    s = &(screen);
+  switch (mode)
+    {
+      case SAVE:
         s->s_cur.row = s->cur.row;
         s->s_cur.col = s->cur.col;
         s->s_rstyle = rstyle;
         s->s_charset = s->charset;
         s->s_charset_char = charsets[s->charset];
         break;
-    case RESTORE:
+      case RESTORE:
         want_refresh = 1;
         s->cur.row = s->s_cur.row;
         s->cur.col = s->s_cur.col;
@@ -532,15 +533,15 @@ rxvt_term::scr_cursor (int mode)
         set_font_style ();
         break;
     }
-/* boundary check in case screen size changed between SAVE and RESTORE */
-    MIN_IT(s->cur.row, TermWin.nrow - 1);
-    MIN_IT(s->cur.col, TermWin.ncol - 1);
+  /* boundary check in case screen size changed between SAVE and RESTORE */
+  MIN_IT(s->cur.row, TermWin.nrow - 1);
+  MIN_IT(s->cur.col, TermWin.ncol - 1);
 #ifdef DEBUG_STRICT
-    assert(s->cur.row >= 0);
-    assert(s->cur.col >= 0);
+  assert(s->cur.row >= 0);
+  assert(s->cur.col >= 0);
 #else                           /* drive with your eyes closed */
-    MAX_IT(s->cur.row, 0);
-    MAX_IT(s->cur.col, 0);
+  MAX_IT(s->cur.row, 0);
+  MAX_IT(s->cur.col, 0);
 #endif
 }
 
@@ -553,69 +554,71 @@ rxvt_term::scr_cursor (int mode)
 int
 rxvt_term::scr_change_screen (int scrn)
 {
-    int             i;
+  int             i;
 #if NSCREENS
-    int             offset;
+  int             offset;
 #endif
 
-    want_refresh = 1;
+  want_refresh = 1;
 
-    D_SCREEN((stderr, "rxvt_scr_change_screen(%d)", scrn));
+  D_SCREEN((stderr, "rxvt_scr_change_screen(%d)", scrn));
 
-    TermWin.view_start = 0;
+  TermWin.view_start = 0;
 
-    if (current_screen == scrn)
-        return current_screen;
+  if (current_screen == scrn)
+    return current_screen;
 
-    selection_check (2);        /* check for boundary cross */
+  selection_check (2);        /* check for boundary cross */
 
-    SWAP_IT(current_screen, scrn, int);
+  SWAP_IT(current_screen, scrn, int);
 #if NSCREENS
-    num_scr = 0;
-    offset = TermWin.saveLines;
-    for (i = prev_nrow; i--;) {
-        SWAP_IT(screen.text[i + offset], swap.text[i], text_t *);
-        SWAP_IT(screen.tlen[i + offset], swap.tlen[i], int16_t);
-        SWAP_IT(screen.rend[i + offset], swap.rend[i], rend_t *);
-    }
-    SWAP_IT(screen.cur.row, swap.cur.row, int16_t);
-    SWAP_IT(screen.cur.col, swap.cur.col, int16_t);
+  num_scr = 0;
+  offset = TermWin.saveLines;
+  for (i = prev_nrow; i--;)
+    {
+      SWAP_IT(screen.text[i + offset], swap.text[i], text_t *);
+      SWAP_IT(screen.tlen[i + offset], swap.tlen[i], int16_t);
+      SWAP_IT(screen.rend[i + offset], swap.rend[i], rend_t *);
+    }
+  SWAP_IT(screen.cur.row, swap.cur.row, int16_t);
+  SWAP_IT(screen.cur.col, swap.cur.col, int16_t);
 # ifdef DEBUG_STRICT
-    assert((screen.cur.row >= 0) && (screen.cur.row < prev_nrow));
-    assert((screen.cur.col >= 0) && (screen.cur.col < prev_ncol));
+  assert((screen.cur.row >= 0) && (screen.cur.row < prev_nrow));
+  assert((screen.cur.col >= 0) && (screen.cur.col < prev_ncol));
 # else                          /* drive with your eyes closed */
-    MAX_IT(screen.cur.row, 0);
-    MIN_IT(screen.cur.row, (int32_t)prev_nrow - 1);
-    MAX_IT(screen.cur.col, 0);
-    MIN_IT(screen.cur.col, (int32_t)prev_ncol - 1);
+  MAX_IT(screen.cur.row, 0);
+  MIN_IT(screen.cur.row, (int32_t)prev_nrow - 1);
+  MAX_IT(screen.cur.col, 0);
+  MIN_IT(screen.cur.col, (int32_t)prev_ncol - 1);
 # endif
-    SWAP_IT(screen.charset, swap.charset, int16_t);
-    SWAP_IT(screen.flags, swap.flags, int);
-    screen.flags |= Screen_VisibleCursor;
-    swap.flags |= Screen_VisibleCursor;
+  SWAP_IT(screen.charset, swap.charset, int16_t);
+  SWAP_IT(screen.flags, swap.flags, int);
+  screen.flags |= Screen_VisibleCursor;
+  swap.flags |= Screen_VisibleCursor;
 
 # ifdef RXVT_GRAPHICS
 
-    if (Gr_Displayed ()) {
-        Gr_scroll (0);
-        Gr_ChangeScreen ();
+  if (Gr_Displayed ())
+    {
+      Gr_scroll (0);
+      Gr_ChangeScreen ();
     }
 # endif
 #else
 # ifdef SCROLL_ON_NO_SECONDARY
 #  ifdef RXVT_GRAPHICS
-    if (Gr_Displayed ())
-        Gr_ClearScreen ();
+  if (Gr_Displayed ())
+    Gr_ClearScreen ();
 #  endif
-    if (current_screen == PRIMARY
+  if (current_screen == PRIMARY
 #  ifdef RXVT_GRAPHICS
-        && !Gr_Displayed ()
+      && !Gr_Displayed ()
 #  endif
-        )
-        scr_scroll_text(0, (prev_nrow - 1), prev_nrow, 0);
+     )
+    scr_scroll_text(0, (prev_nrow - 1), prev_nrow, 0);
 # endif
 #endif
-    return scrn;
+  return scrn;
 }
 
 /* ------------------------------------------------------------------------- */
@@ -625,11 +628,11 @@ rxvt_term::scr_change_screen (int scrn)
 void
 rxvt_term::scr_color (unsigned int color, int fgbg)
 {
-    color &= RS_fgMask;
-    if (fgbg == Color_fg)
-        rstyle = SET_FGCOLOR(rstyle, color);
-    else 
-        rstyle = SET_BGCOLOR(rstyle, color);
+  color &= RS_fgMask;
+  if (fgbg == Color_fg)
+    rstyle = SET_FGCOLOR(rstyle, color);
+  else
+    rstyle = SET_BGCOLOR(rstyle, color);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -638,14 +641,14 @@ rxvt_term::scr_color (unsigned int color, int fgbg)
  */
 void
 rxvt_term::scr_rendition (int set, int style)
-{
+  {
     if (set)
-        rstyle |= style;
+      rstyle |= style;
     else if (style == ~RS_None)
-        rstyle = DEFAULT_RSTYLE;
+      rstyle = DEFAULT_RSTYLE;
     else
-        rstyle &= ~style;
-}
+      rstyle &= ~style;
+  }
 
 /* ------------------------------------------------------------------------- */
 /*
@@ -786,156 +789,162 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec)
 void
 rxvt_term::scr_add_lines (const uint32_t *str, int nlines, int len)
 {
-    unsigned char   checksel, clearsel;
-    uint32_t        c;
-    int             i, row, last_col;
-    text_t         *stp;
-    rend_t         *srp;
+  unsigned char   checksel, clearsel;
+  uint32_t        c;
+  int             i, row, last_col;
+  text_t         *stp;
+  rend_t         *srp;
 
-    if (len <= 0)               /* sanity */
-        return;
+  if (len <= 0)               /* sanity */
+    return;
+
+  want_refresh = 1;
+  last_col = TermWin.ncol;
 
-    want_refresh = 1;
-    last_col = TermWin.ncol;
-
-    D_SCREEN((stderr, "rxvt_scr_add_lines(%d,%d)", nlines, len));
-    ZERO_SCROLLBACK();
-    if (nlines > 0) {
-        nlines += (screen.cur.row - screen.bscroll);
-        if ((nlines > 0)
-            && (screen.tscroll == 0)
-            && (screen.bscroll == (TermWin.nrow - 1))) {
-            /* _at least_ this many lines need to be scrolled */
-            scr_scroll_text(screen.tscroll, screen.bscroll, nlines, 0);
-            screen.cur.row -= nlines;
+  D_SCREEN((stderr, "rxvt_scr_add_lines(%d,%d)", nlines, len));
+  ZERO_SCROLLBACK();
+  if (nlines > 0)
+    {
+      nlines += (screen.cur.row - screen.bscroll);
+      if ((nlines > 0)
+          && (screen.tscroll == 0)
+          && (screen.bscroll == (TermWin.nrow - 1)))
+        {
+          /* _at least_ this many lines need to be scrolled */
+          scr_scroll_text(screen.tscroll, screen.bscroll, nlines, 0);
+          screen.cur.row -= nlines;
         }
     }
 #ifdef DEBUG_STRICT
-    assert(screen.cur.col < last_col);
-    assert((screen.cur.row < TermWin.nrow)
-           && (screen.cur.row >= -(int32_t)TermWin.nscrolled));
+  assert(screen.cur.col < last_col);
+  assert((screen.cur.row < TermWin.nrow)
+         && (screen.cur.row >= -(int32_t)TermWin.nscrolled));
 #else                           /* drive with your eyes closed */
-    MIN_IT(screen.cur.col, last_col - 1);
-    MIN_IT(screen.cur.row, (int32_t)TermWin.nrow - 1);
-    MAX_IT(screen.cur.row, -(int32_t)TermWin.nscrolled);
+  MIN_IT(screen.cur.col, last_col - 1);
+  MIN_IT(screen.cur.row, (int32_t)TermWin.nrow - 1);
+  MAX_IT(screen.cur.row, -(int32_t)TermWin.nscrolled);
 #endif
-    row = screen.cur.row + TermWin.saveLines;
+  row = screen.cur.row + TermWin.saveLines;
 
-    checksel = (selection.op
-                && current_screen == selection.screen) ? 1 : 0;
-    clearsel = 0;
+  checksel = (selection.op
+              && current_screen == selection.screen) ? 1 : 0;
+  clearsel = 0;
 
-    stp = screen.text[row];
-    srp = screen.rend[row];
+  stp = screen.text[row];
+  srp = screen.rend[row];
 
-    for (i = 0; i < len;) {
-        c = str[i++];
-        switch (c) {
-        case '\t':
+  for (i = 0; i < len;)
+    {
+      c = str[i++];
+      switch (c)
+        {
+          case '\t':
             scr_tab (1);
             continue;
-        case '\n':
+          case '\n':
             if (screen.tlen[row] != -1)      /* XXX: think about this */
-                MAX_IT(screen.tlen[row], screen.cur.col);
+              MAX_IT(screen.tlen[row], screen.cur.col);
             screen.flags &= ~Screen_WrapNext;
             if (screen.cur.row == screen.bscroll)
-                scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0);
+              scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0);
             else if (screen.cur.row < (TermWin.nrow - 1))
-                row = (++screen.cur.row) + TermWin.saveLines;
+              row = (++screen.cur.row) + TermWin.saveLines;
             stp = screen.text[row];  /* _must_ refresh */
             srp = screen.rend[row];  /* _must_ refresh */
             continue;
-        case '\r':
+          case '\r':
             if (screen.tlen[row] != -1)      /* XXX: think about this */
-                MAX_IT(screen.tlen[row], screen.cur.col);
+              MAX_IT(screen.tlen[row], screen.cur.col);
             screen.flags &= ~Screen_WrapNext;
             screen.cur.col = 0;
             continue;
-        default:
+          default:
             if (c == 127)
-                continue;       /* yummmm..... */
+              continue;       /* yummmm..... */
             break;
         }
 
-        if (checksel            /* see if we're writing within selection */
-            && !ROWCOL_IS_BEFORE(screen.cur, selection.beg)
-            && ROWCOL_IS_BEFORE(screen.cur, selection.end)) {
-            checksel = 0;
-            clearsel = 1;
+      if (checksel            /* see if we're writing within selection */
+          && !ROWCOL_IS_BEFORE(screen.cur, selection.beg)
+          && ROWCOL_IS_BEFORE(screen.cur, selection.end))
+        {
+          checksel = 0;
+          clearsel = 1;
         }
-        if (screen.flags & Screen_WrapNext) {
-            screen.tlen[row] = -1;
-            if (screen.cur.row == screen.bscroll)
-                scr_scroll_text(screen.tscroll, screen.bscroll, 1, 0);
-            else if (screen.cur.row < (TermWin.nrow - 1))
-                row = (++screen.cur.row) + TermWin.saveLines;
-            stp = screen.text[row];  /* _must_ refresh */
-            srp = screen.rend[row];  /* _must_ refresh */
-            screen.cur.col = 0;
-            screen.flags &= ~Screen_WrapNext;
+      if (screen.flags & Screen_WrapNext)
+        {
+          screen.tlen[row] = -1;
+          if (screen.cur.row == screen.bscroll)
+            scr_scroll_text(screen.tscroll, screen.bscroll, 1, 0);
+          else if (screen.cur.row < (TermWin.nrow - 1))
+            row = (++screen.cur.row) + TermWin.saveLines;
+          stp = screen.text[row];  /* _must_ refresh */
+          srp = screen.rend[row];  /* _must_ refresh */
+          screen.cur.col = 0;
+          screen.flags &= ~Screen_WrapNext;
         }
-        if (screen.flags & Screen_Insert)
-            scr_insdel_chars (1, INSERT);
+      if (screen.flags & Screen_Insert)
+        scr_insdel_chars (1, INSERT);
 
-        if (charsets[screen.charset] == '0') // DEC SPECIAL
-          switch (c)
-            {
-              case '+': c = 0x2192; break; case ',': c = 0x2190; break; case '-': c = 0x2191; break;
-              case '.': c = 0x2193; break; case '0': c = 0x25ae; break; case '`': c = 0x25c6; break;
-              case 'a': c = 0x2592; break; case 'f': c = 0x00b0; break; case 'g': c = 0x00b1; break;
-              case 'h': c = 0x2592; break; case 'i': c = 0x2603; break; case 'j': c = 0x2518; break;
-              case 'k': c = 0x2510; break; case 'l': c = 0x250c; break; case 'm': c = 0x2514; break;
-              case 'n': c = 0x253c; break; case 'o': c = 0x23ba; break; case 'p': c = 0x23bb; break;
-              case 'q': c = 0x2500; break; case 'r': c = 0x23bc; break; case 's': c = 0x23bd; break;
-              case 't': c = 0x251c; break; case 'u': c = 0x2524; break; case 'v': c = 0x2534; break;
-              case 'w': c = 0x252c; break; case 'x': c = 0x2502; break; case 'y': c = 0x2264; break;
-              case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break;
-              case '}': c = 0x00a3; break; case '~': c = 0x00b7; break;
-            }
+      if (charsets[screen.charset] == '0') // DEC SPECIAL
+        switch (c)
+          {
+        case '+': c = 0x2192; break; case ',': c = 0x2190; break; case '-': c = 0x2191; break;
+        case '.': c = 0x2193; break; case '0': c = 0x25ae; break; case '`': c = 0x25c6; break;
+        case 'a': c = 0x2592; break; case 'f': c = 0x00b0; break; case 'g': c = 0x00b1; break;
+        case 'h': c = 0x2592; break; case 'i': c = 0x2603; break; case 'j': c = 0x2518; break;
+        case 'k': c = 0x2510; break; case 'l': c = 0x250c; break; case 'm': c = 0x2514; break;
+        case 'n': c = 0x253c; break; case 'o': c = 0x23ba; break; case 'p': c = 0x23bb; break;
+        case 'q': c = 0x2500; break; case 'r': c = 0x23bc; break; case 's': c = 0x23bd; break;
+        case 't': c = 0x251c; break; case 'u': c = 0x2524; break; case 'v': c = 0x2534; break;
+        case 'w': c = 0x252c; break; case 'x': c = 0x2502; break; case 'y': c = 0x2264; break;
+        case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break;
+          case '}': c = 0x00a3; break; case '~': c = 0x00b7; break;
+          }
 
-        rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c));
-        // rely on wcwidth to tell us the character width, at least for non-ascii
-        int width = c <= 128 ? 1 : wcwidth (c);
+      rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c));
+      // rely on wcwidth to tell us the character width, at least for non-ascii
+      int width = c <= 128 ? 1 : wcwidth (c);
 
-        // width -1 characters (e.g. combining chars) are ignored currently.
-        if (width > 0)
-          do
-            {
-              stp[screen.cur.col] = c;
-              srp[screen.cur.col] = rend;
+      // width -1 characters (e.g. combining chars) are ignored currently.
+      if (width > 0)
+        do
+          {
+            stp[screen.cur.col] = c;
+            srp[screen.cur.col] = rend;
 
-              if (screen.cur.col < last_col - 1)
-                screen.cur.col++;
-              else
-                {
-                  screen.tlen[row] = last_col;
-                  if (screen.flags & Screen_Autowrap)
-                    screen.flags |= Screen_WrapNext;
-                  break;
-                }
+            if (screen.cur.col < last_col - 1)
+              screen.cur.col++;
+            else
+              {
+                screen.tlen[row] = last_col;
+                if (screen.flags & Screen_Autowrap)
+                  screen.flags |= Screen_WrapNext;
+                break;
+              }
 
-              c = NOCHAR;
-            }
-          while (--width > 0);
-        else
-          (void)0; /* handle combining character etc. here. */
+            c = NOCHAR;
+          }
+        while (--width > 0);
+      else
+        (void)0; /* handle combining character etc. here. */
     }
 
-    if (screen.tlen[row] != -1)      /* XXX: think about this */
-      MAX_IT(screen.tlen[row], screen.cur.col);
+  if (screen.tlen[row] != -1)      /* XXX: think about this */
+    MAX_IT(screen.tlen[row], screen.cur.col);
 
-/*
- * If we wrote anywhere in the selected area, kill the selection
- * XXX: should we kill the mark too?  Possibly, but maybe that
- *      should be a similar check.
- */
-    if (clearsel)
-        CLEAR_SELECTION();
+  /*
  * If we wrote anywhere in the selected area, kill the selection
  * XXX: should we kill the mark too?  Possibly, but maybe that
  *      should be a similar check.
  */
+  if (clearsel)
+    CLEAR_SELECTION();
 
 #ifdef DEBUG_STRICT
-    assert(screen.cur.row >= 0);
+  assert(screen.cur.row >= 0);
 #else                           /* drive with your eyes closed */
-    MAX_IT(screen.cur.row, 0);
+  MAX_IT(screen.cur.row, 0);
 #endif
 }
 
@@ -947,18 +956,22 @@ rxvt_term::scr_add_lines (const uint32_t *str, int nlines, int len)
 void
 rxvt_term::scr_backspace ()
 {
-    want_refresh = 1;
-    if (screen.cur.col == 0) {
-        if (screen.cur.row > 0) {
+  want_refresh = 1;
+  if (screen.cur.col == 0)
+    {
+      if (screen.cur.row > 0)
+        {
 #ifdef TERMCAP_HAS_BW
-            screen.cur.col = TermWin.ncol - 1;
-            screen.cur.row--;
-            return;
+          screen.cur.col = TermWin.ncol - 1;
+          screen.cur.row--;
+          return;
 #endif
+
         }
-    } else if ((screen.flags & Screen_WrapNext) == 0)
-        scr_gotorc (0, -1, RELATIVE);
-    screen.flags &= ~Screen_WrapNext;
+    }
+  else if ((screen.flags & Screen_WrapNext) == 0)
+    scr_gotorc (0, -1, RELATIVE);
+  screen.flags &= ~Screen_WrapNext;
 }
 
 /* ------------------------------------------------------------------------- */
@@ -970,34 +983,39 @@ rxvt_term::scr_backspace ()
 void
 rxvt_term::scr_tab (int count)
 {
-    int             i, x;
+  int             i, x;
 
-    D_SCREEN((stderr, "rxvt_scr_tab(%d)", count));
-    want_refresh = 1;
-    i = x = screen.cur.col;
-    if (count == 0)
-        return;
-    else if (count > 0) {
-        for (; ++i < TermWin.ncol; )
-            if (tabs[i]) {
-                x = i;
-                if (!--count)
-                    break;
-            }
-        if (count)
-            x = TermWin.ncol - 1;
-    } else /* if (count < 0) */ {
-        for (; --i >= 0; )
-            if (tabs[i]) {
-                x = i;
-                if (!++count)
-                    break;
-            }
-        if (count)
-            x = 0;
+  D_SCREEN((stderr, "rxvt_scr_tab(%d)", count));
+  want_refresh = 1;
+  i = x = screen.cur.col;
+  if (count == 0)
+    return;
+  else if (count > 0)
+    {
+      for (; ++i < TermWin.ncol; )
+        if (tabs[i])
+          {
+            x = i;
+            if (!--count)
+              break;
+          }
+      if (count)
+        x = TermWin.ncol - 1;
+    }
+  else /* if (count < 0) */
+    {
+      for (; --i >= 0; )
+        if (tabs[i])
+          {
+            x = i;
+            if (!++count)
+              break;
+          }
+      if (count)
+        x = 0;
     }
-    if (x != screen.cur.col)
-        scr_gotorc (0, x, R_RELATIVE);
+  if (x != screen.cur.col)
+    scr_gotorc (0, x, R_RELATIVE);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1011,12 +1029,13 @@ rxvt_term::scr_tab (int count)
 void
 rxvt_term::scr_backindex ()
 {
-    if (screen.cur.col > 0)
-        scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);
-    else {
-        if (screen.tlen[screen.cur.row + TermWin.saveLines] == 0)
-            return;             /* um, yeah? */
-        scr_insdel_chars (1, INSERT);
+  if (screen.cur.col > 0)
+    scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);
+  else
+    {
+      if (screen.tlen[screen.cur.row + TermWin.saveLines] == 0)
+        return;             /* um, yeah? */
+      scr_insdel_chars (1, INSERT);
     }
 }
 #endif
@@ -1031,19 +1050,20 @@ rxvt_term::scr_backindex ()
 void
 rxvt_term::scr_forwardindex ()
 {
-    int             row;
+  int             row;
 
-    if (screen.cur.col < TermWin.ncol - 1)
-        scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
-    else {
-        row = screen.cur.row + TermWin.saveLines;
-        if (screen.tlen[row] == 0)
-            return;             /* um, yeah? */
-        else if (screen.tlen[row] == -1)
-            screen.tlen[row] = TermWin.ncol;
-        scr_gotorc (0, 0, R_RELATIVE);
-        scr_insdel_chars (1, DELETE);
-        scr_gotorc (0, TermWin.ncol - 1, R_RELATIVE);
+  if (screen.cur.col < TermWin.ncol - 1)
+    scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
+  else
+    {
+      row = screen.cur.row + TermWin.saveLines;
+      if (screen.tlen[row] == 0)
+        return;             /* um, yeah? */
+      else if (screen.tlen[row] == -1)
+        screen.tlen[row] = TermWin.ncol;
+      scr_gotorc (0, 0, R_RELATIVE);
+      scr_insdel_chars (1, DELETE);
+      scr_gotorc (0, TermWin.ncol - 1, R_RELATIVE);
     }
 }
 #endif
@@ -1055,44 +1075,52 @@ rxvt_term::scr_forwardindex ()
 void
 rxvt_term::scr_gotorc (int row, int col, int relative)
 {
-    want_refresh = 1;
-    ZERO_SCROLLBACK();
+  want_refresh = 1;
+  ZERO_SCROLLBACK();
 #ifdef RXVT_GRAPHICS
-    if (Gr_Displayed ())
-        Gr_scroll (0);
+  if (Gr_Displayed ())
+    Gr_scroll (0);
 #endif
 
-    D_SCREEN((stderr, "rxvt_scr_gotorc(r:%s%d,c:%s%d): from (r:%d,c:%d)", (relative & R_RELATIVE ? "+" : ""), row, (relative & C_RELATIVE ? "+" : ""), col, screen.cur.row, screen.cur.col));
+  D_SCREEN((stderr, "rxvt_scr_gotorc(r:%s%d,c:%s%d): from (r:%d,c:%d)", (relative & R_RELATIVE ? "+" : ""), row, (relative & C_RELATIVE ? "+" : ""), col, screen.cur.row, screen.cur.col));
 
-    screen.cur.col = ((relative & C_RELATIVE) ? (screen.cur.col + col)
-                                                 : col);
-    MAX_IT(screen.cur.col, 0);
-    MIN_IT(screen.cur.col, (int32_t)TermWin.ncol - 1);
+  screen.cur.col = ((relative & C_RELATIVE) ? (screen.cur.col + col)
+                    : col);
+  MAX_IT(screen.cur.col, 0);
+  MIN_IT(screen.cur.col, (int32_t)TermWin.ncol - 1);
 
-    screen.flags &= ~Screen_WrapNext;
-    if (relative & R_RELATIVE) {
-        if (row > 0) {
-            if (screen.cur.row <= screen.bscroll
-                && (screen.cur.row + row) > screen.bscroll)
-                screen.cur.row = screen.bscroll;
-            else
-                screen.cur.row += row;
-        } else if (row < 0) {
-            if (screen.cur.row >= screen.tscroll
-                && (screen.cur.row + row) < screen.tscroll)
-                screen.cur.row = screen.tscroll;
-            else
-                screen.cur.row += row;
+  screen.flags &= ~Screen_WrapNext;
+  if (relative & R_RELATIVE)
+    {
+      if (row > 0)
+        {
+          if (screen.cur.row <= screen.bscroll
+              && (screen.cur.row + row) > screen.bscroll)
+            screen.cur.row = screen.bscroll;
+          else
+            screen.cur.row += row;
+        }
+      else if (row < 0)
+        {
+          if (screen.cur.row >= screen.tscroll
+              && (screen.cur.row + row) < screen.tscroll)
+            screen.cur.row = screen.tscroll;
+          else
+            screen.cur.row += row;
+        }
+    }
+  else
+    {
+      if (screen.flags & Screen_Relative)
+        {        /* relative origin mode */
+          screen.cur.row = row + screen.tscroll;
+          MIN_IT(screen.cur.row, screen.bscroll);
         }
-    } else {
-        if (screen.flags & Screen_Relative) {        /* relative origin mode */
-            screen.cur.row = row + screen.tscroll;
-            MIN_IT(screen.cur.row, screen.bscroll);
-        } else
-            screen.cur.row = row;
+      else
+        screen.cur.row = row;
     }
-    MAX_IT(screen.cur.row, 0);
-    MIN_IT(screen.cur.row, (int32_t)TermWin.nrow - 1);
+  MAX_IT(screen.cur.row, 0);
+  MIN_IT(screen.cur.row, (int32_t)TermWin.nrow - 1);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1102,28 +1130,28 @@ rxvt_term::scr_gotorc (int row, int col, int relative)
 void
 rxvt_term::scr_index (enum page_dirn direction)
 {
-    int             dirn;
+  int             dirn;
 
-    want_refresh = 1;
-    dirn = ((direction == UP) ? 1 : -1);
-    D_SCREEN((stderr, "rxvt_scr_index(%d)", dirn));
+  want_refresh = 1;
+  dirn = ((direction == UP) ? 1 : -1);
+  D_SCREEN((stderr, "rxvt_scr_index(%d)", dirn));
 
-    ZERO_SCROLLBACK();
+  ZERO_SCROLLBACK();
 
 #ifdef RXVT_GRAPHICS
-    if (Gr_Displayed ())
-        Gr_scroll (0);
+  if (Gr_Displayed ())
+    Gr_scroll (0);
 #endif
 
-    screen.flags &= ~Screen_WrapNext;
-    if ((screen.cur.row == screen.bscroll && direction == UP)
-        || (screen.cur.row == screen.tscroll && direction == DN))
-        scr_scroll_text(screen.tscroll, screen.bscroll, dirn, 0);
-    else
-        screen.cur.row += dirn;
-    MAX_IT(screen.cur.row, 0);
-    MIN_IT(screen.cur.row, (int32_t)TermWin.nrow - 1);
-    selection_check (0);
+  screen.flags &= ~Screen_WrapNext;
+  if ((screen.cur.row == screen.bscroll && direction == UP)
+      || (screen.cur.row == screen.tscroll && direction == DN))
+    scr_scroll_text(screen.tscroll, screen.bscroll, dirn, 0);
+  else
+    screen.cur.row += dirn;
+  MAX_IT(screen.cur.row, 0);
+  MIN_IT(screen.cur.row, (int32_t)TermWin.nrow - 1);
+  selection_check (0);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1183,7 +1211,7 @@ rxvt_term::scr_erase_line (int mode)
 
   if (screen.text[row])
     scr_blank_line (&(screen.text[row][col]),
-                       &(screen.rend[row][col]), num, rstyle);
+                    &(screen.rend[row][col]), num, rstyle);
   else
     scr_blank_screen_mem (screen.text, screen.rend, row, rstyle);
 }
@@ -1198,30 +1226,31 @@ rxvt_term::scr_erase_line (int mode)
 void
 rxvt_term::scr_erase_screen (int mode)
 {
-    int             num;
-    int32_t         row, row_offset;
-    rend_t          ren;
-    XGCValues       gcvalue;
+  int             num;
+  int32_t         row, row_offset;
+  rend_t          ren;
+  XGCValues       gcvalue;
 
-    want_refresh = 1;
-    D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, screen.cur.row));
-    ZERO_SCROLLBACK ();
-    row_offset = (int32_t)TermWin.saveLines;
+  want_refresh = 1;
+  D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, screen.cur.row));
+  ZERO_SCROLLBACK ();
+  row_offset = (int32_t)TermWin.saveLines;
 
-    switch (mode) {
-    case 0:                     /* erase to end of screen */
+  switch (mode)
+    {
+      case 0:                     /* erase to end of screen */
         selection_check (1);
         scr_erase_line (0);
         row = screen.cur.row + 1;    /* possible OOB */
         num = TermWin.nrow - row;
         break;
-    case 1:                     /* erase to beginning of screen */
+      case 1:                     /* erase to beginning of screen */
         selection_check (3);
         scr_erase_line (1);
         row = 0;
         num = screen.cur.row;
         break;
-    case 2:                     /* erase whole screen */
+      case 2:                     /* erase whole screen */
         selection_check (3);
 #ifdef RXVT_GRAPHICS
         Gr_ClearScreen ();
@@ -1229,37 +1258,41 @@ rxvt_term::scr_erase_screen (int mode)
         row = 0;
         num = TermWin.nrow;
         break;
-    default:
+      default:
         return;
     }
-    refresh_type |= REFRESH_BOUNDS;
-    if (selection.op && current_screen == selection.screen
-        && ((selection.beg.row >= row && selection.beg.row <= row + num)
-            || (selection.end.row >= row
-                && selection.end.row <= row + num)))
-        CLEAR_SELECTION ();
-    if (row >= TermWin.nrow) /* Out Of Bounds */
-        return;
-    MIN_IT(num, (TermWin.nrow - row));
-    if (rstyle & (RS_RVid | RS_Uline))
-        ren = (rend_t) ~RS_None;
-    else if (GET_BASEBG(rstyle) == Color_bg) {
-        ren = DEFAULT_RSTYLE;
-        CLEAR_ROWS(row, num);
-    } else {
-        ren = (rstyle & (RS_fgMask | RS_bgMask));
-        gcvalue.foreground = PixColors[GET_BGCOLOR(rstyle)];
-        XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue);
-        ERASE_ROWS(row, num);
-        gcvalue.foreground = PixColors[Color_fg];
-        XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue);
-    }
-    for (; num--; row++) {
-        scr_blank_screen_mem (screen.text, screen.rend,
-                                 (unsigned int)(row + row_offset), rstyle);
-        screen.tlen[row + row_offset] = 0;
-        scr_blank_line (drawn_text[row], drawn_rend[row],
-                           (unsigned int)TermWin.ncol, ren);
+  refresh_type |= REFRESH_BOUNDS;
+  if (selection.op && current_screen == selection.screen
+      && ((selection.beg.row >= row && selection.beg.row <= row + num)
+          || (selection.end.row >= row
+              && selection.end.row <= row + num)))
+    CLEAR_SELECTION ();
+  if (row >= TermWin.nrow) /* Out Of Bounds */
+    return;
+  MIN_IT(num, (TermWin.nrow - row));
+  if (rstyle & (RS_RVid | RS_Uline))
+    ren = (rend_t) ~RS_None;
+  else if (GET_BASEBG(rstyle) == Color_bg)
+    {
+      ren = DEFAULT_RSTYLE;
+      CLEAR_ROWS(row, num);
+    }
+  else
+    {
+      ren = (rstyle & (RS_fgMask | RS_bgMask));
+      gcvalue.foreground = PixColors[GET_BGCOLOR(rstyle)];
+      XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue);
+      ERASE_ROWS(row, num);
+      gcvalue.foreground = PixColors[Color_fg];
+      XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue);
+    }
+  for (; num--; row++)
+    {
+      scr_blank_screen_mem (screen.text, screen.rend,
+                            (unsigned int)(row + row_offset), rstyle);
+      screen.tlen[row + row_offset] = 0;
+      scr_blank_line (drawn_text[row], drawn_rend[row],
+                      (unsigned int)TermWin.ncol, ren);
     }
 }
 
@@ -1271,20 +1304,21 @@ rxvt_term::scr_erase_screen (int mode)
 void
 rxvt_term::scr_E ()
 {
-    int             i, j, k;
-    rend_t         *r1, fs;
+  int             i, j, k;
+  rend_t         *r1, fs;
 
-    want_refresh = 1;
-    num_scr_allow = 0;
-    ZERO_SCROLLBACK();
-    selection_check (3);
+  want_refresh = 1;
+  num_scr_allow = 0;
+  ZERO_SCROLLBACK();
+  selection_check (3);
 
-    fs = SET_FONT (rstyle, TermWin.fontset->find_font ('E'));
-    for (k = TermWin.saveLines, i = TermWin.nrow; i--; k++) {
-        screen.tlen[k] = TermWin.ncol;    /* make the `E's selectable */
-        fill_text (screen.text[k], 'E', TermWin.ncol);
-        for (r1 = screen.rend[k], j = TermWin.ncol; j--; )
-            *r1++ = fs;
+  fs = SET_FONT (rstyle, TermWin.fontset->find_font ('E'));
+  for (k = TermWin.saveLines, i = TermWin.nrow; i--; k++)
+    {
+      screen.tlen[k] = TermWin.ncol;    /* make the `E's selectable */
+      fill_text (screen.text[k], 'E', TermWin.ncol);
+      for (r1 = screen.rend[k], j = TermWin.ncol; j--; )
+        *r1++ = fs;
     }
 }
 
@@ -1295,30 +1329,31 @@ rxvt_term::scr_E ()
 void
 rxvt_term::scr_insdel_lines (int count, int insdel)
 {
-    int             end;
+  int             end;
 
-    ZERO_SCROLLBACK();
+  ZERO_SCROLLBACK();
 
 #ifdef RXVT_GRAPHICS
-    if (Gr_Displayed ())
-        Gr_scroll (0);
+  if (Gr_Displayed ())
+    Gr_scroll (0);
 #endif
 
-    selection_check (1);
+  selection_check (1);
 
-    if (screen.cur.row > screen.bscroll)
-        return;
+  if (screen.cur.row > screen.bscroll)
+    return;
 
-    end = screen.bscroll - screen.cur.row + 1;
-    if (count > end) {
-        if (insdel == DELETE)
-            return;
-        else if (insdel == INSERT)
-            count = end;
+  end = screen.bscroll - screen.cur.row + 1;
+  if (count > end)
+    {
+      if (insdel == DELETE)
+        return;
+      else if (insdel == INSERT)
+        count = end;
     }
-    screen.flags &= ~Screen_WrapNext;
+  screen.flags &= ~Screen_WrapNext;
 
-    scr_scroll_text(screen.cur.row, screen.bscroll, insdel * count, 0);
+  scr_scroll_text(screen.cur.row, screen.bscroll, insdel * count, 0);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1328,91 +1363,99 @@ rxvt_term::scr_insdel_lines (int count, int insdel)
 void
 rxvt_term::scr_insdel_chars (int count, int insdel)
 {
-    int             col, row;
-    rend_t          tr;
-    text_t         *stp;
-    rend_t         *srp;
-    int16_t        *slp;
+  int             col, row;
+  rend_t          tr;
+  text_t         *stp;
+  rend_t         *srp;
+  int16_t        *slp;
 
-    want_refresh = 1;
-    ZERO_SCROLLBACK();
+  want_refresh = 1;
+  ZERO_SCROLLBACK();
 
 #ifdef RXVT_GRAPHICS
-    if (Gr_Displayed ())
-        Gr_scroll (0);
+  if (Gr_Displayed ())
+    Gr_scroll (0);
 #endif
 
-    if (count <= 0)
-        return;
+  if (count <= 0)
+    return;
 
-    selection_check (1);
-    MIN_IT(count, (TermWin.ncol - screen.cur.col));
+  selection_check (1);
+  MIN_IT(count, (TermWin.ncol - screen.cur.col));
 
-    row = screen.cur.row + TermWin.saveLines;
-    screen.flags &= ~Screen_WrapNext;
+  row = screen.cur.row + TermWin.saveLines;
+  screen.flags &= ~Screen_WrapNext;
 
-    stp = screen.text[row];
-    srp = screen.rend[row];
-    slp = &(screen.tlen[row]);
-    switch (insdel) {
-    case INSERT:
+  stp = screen.text[row];
+  srp = screen.rend[row];
+  slp = &(screen.tlen[row]);
+  switch (insdel)
+    {
+      case INSERT:
         for (col = TermWin.ncol - 1; (col - count) >= screen.cur.col;
-             col--) {
+             col--)
+          {
             stp[col] = stp[col - count];
             srp[col] = srp[col - count];
-        }
-        if (*slp != -1) {
+          }
+        if (*slp != -1)
+          {
             *slp += count;
             MIN_IT(*slp, TermWin.ncol);
-        }
+          }
         if (selection.op && current_screen == selection.screen
-            && ROWCOL_IN_ROW_AT_OR_AFTER(selection.beg, screen.cur)) {
+            && ROWCOL_IN_ROW_AT_OR_AFTER(selection.beg, screen.cur))
+          {
             if (selection.end.row != screen.cur.row
                 || (selection.end.col + count >= TermWin.ncol))
-                CLEAR_SELECTION();
-            else {              /* shift selection */
+              CLEAR_SELECTION();
+            else
+              {              /* shift selection */
                 selection.beg.col += count;
                 selection.mark.col += count; /* XXX: yes? */
                 selection.end.col += count;
-            }
-        }
+              }
+          }
         scr_blank_line (&(stp[screen.cur.col]), &(srp[screen.cur.col]),
-                           (unsigned int)count, rstyle);
+                        (unsigned int)count, rstyle);
         break;
-    case ERASE:
+      case ERASE:
         screen.cur.col += count;     /* don't worry if > TermWin.ncol */
         selection_check (1);
         screen.cur.col -= count;
         scr_blank_line (&(stp[screen.cur.col]), &(srp[screen.cur.col]),
-                           (unsigned int)count, rstyle);
+                        (unsigned int)count, rstyle);
         break;
-    case DELETE:
+      case DELETE:
         tr = srp[TermWin.ncol - 1]
              & (RS_fgMask | RS_bgMask | RS_baseattrMask);
-        for (col = screen.cur.col; (col + count) < TermWin.ncol; col++) {
+        for (col = screen.cur.col; (col + count) < TermWin.ncol; col++)
+          {
             stp[col] = stp[col + count];
             srp[col] = srp[col + count];
-        }
+          }
         scr_blank_line (&(stp[TermWin.ncol - count]),
-                           &(srp[TermWin.ncol - count]),
-                           (unsigned int)count, tr);
+                        &(srp[TermWin.ncol - count]),
+                        (unsigned int)count, tr);
         if (*slp == -1) /* break line continuation */
-            *slp = TermWin.ncol;
+          *slp = TermWin.ncol;
         *slp -= count;
         MAX_IT(*slp, 0);
         if (selection.op && current_screen == selection.screen
-            && ROWCOL_IN_ROW_AT_OR_AFTER(selection.beg, screen.cur)) {
+            && ROWCOL_IN_ROW_AT_OR_AFTER(selection.beg, screen.cur))
+          {
             if (selection.end.row != screen.cur.row
                 || (screen.cur.col >= selection.beg.col - count)
                 || selection.end.col >= TermWin.ncol)
-                CLEAR_SELECTION();
-            else {
+              CLEAR_SELECTION();
+            else
+              {
                 /* shift selection */
                 selection.beg.col -= count;
                 selection.mark.col -= count; /* XXX: yes? */
                 selection.end.col -= count;
-            }
-        }
+              }
+          }
         break;
     }
 }
@@ -1425,13 +1468,13 @@ rxvt_term::scr_insdel_chars (int count, int insdel)
 void
 rxvt_term::scr_scroll_region (int top, int bot)
 {
-    MAX_IT(top, 0);
-    MIN_IT(bot, (int)TermWin.nrow - 1);
-    if (top > bot)
-        return;
-    screen.tscroll = top;
-    screen.bscroll = bot;
-    scr_gotorc (0, 0, 0);
+  MAX_IT(top, 0);
+  MIN_IT(bot, (int)TermWin.nrow - 1);
+  if (top > bot)
+    return;
+  screen.tscroll = top;
+  screen.bscroll = bot;
+  scr_gotorc (0, 0, 0);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1443,11 +1486,11 @@ rxvt_term::scr_scroll_region (int top, int bot)
 void
 rxvt_term::scr_cursor_visible (int mode)
 {
-    want_refresh = 1;
-    if (mode)
-        screen.flags |= Screen_VisibleCursor;
-    else
-        screen.flags &= ~Screen_VisibleCursor;
+  want_refresh = 1;
+  if (mode)
+    screen.flags |= Screen_VisibleCursor;
+  else
+    screen.flags &= ~Screen_VisibleCursor;
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1459,10 +1502,10 @@ rxvt_term::scr_cursor_visible (int mode)
 void
 rxvt_term::scr_autowrap (int mode)
 {
-    if (mode)
-        screen.flags |= Screen_Autowrap;
-    else
-        screen.flags &= ~(Screen_Autowrap | Screen_WrapNext);
+  if (mode)
+    screen.flags |= Screen_Autowrap;
+  else
+    screen.flags &= ~(Screen_Autowrap | Screen_WrapNext);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1478,11 +1521,11 @@ rxvt_term::scr_autowrap (int mode)
 void
 rxvt_term::scr_relative_origin (int mode)
 {
-    if (mode)
-        screen.flags |= Screen_Relative;
-    else
-        screen.flags &= ~Screen_Relative;
-    scr_gotorc (0, 0, 0);
+  if (mode)
+    screen.flags |= Screen_Relative;
+  else
+    screen.flags &= ~Screen_Relative;
+  scr_gotorc (0, 0, 0);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1494,10 +1537,10 @@ rxvt_term::scr_relative_origin (int mode)
 void
 rxvt_term::scr_insert_mode (int mode)
 {
-    if (mode)
-        screen.flags |= Screen_Insert;
-    else
-        screen.flags &= ~Screen_Insert;
+  if (mode)
+    screen.flags |= Screen_Insert;
+  else
+    screen.flags &= ~Screen_Insert;
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1510,10 +1553,10 @@ rxvt_term::scr_insert_mode (int mode)
 void
 rxvt_term::scr_set_tab (int mode)
 {
-    if (mode < 0)
-        MEMSET(tabs, 0, TermWin.ncol * sizeof(char));
-    else if (screen.cur.col < TermWin.ncol)
-        tabs[screen.cur.col] = (mode ? 1 : 0);
+  if (mode < 0)
+    MEMSET(tabs, 0, TermWin.ncol * sizeof(char));
+  else if (screen.cur.col < TermWin.ncol)
+    tabs[screen.cur.col] = (mode ? 1 : 0);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1525,26 +1568,27 @@ rxvt_term::scr_set_tab (int mode)
 void
 rxvt_term::scr_rvideo_mode (int mode)
 {
-    XGCValues       gcvalue;
+  XGCValues       gcvalue;
 
-    if (rvideo != mode) {
-        rvideo = mode;
-        SWAP_IT(PixColors[Color_fg], PixColors[Color_bg], rxvt_color);
+  if (rvideo != mode)
+    {
+      rvideo = mode;
+      SWAP_IT(PixColors[Color_fg], PixColors[Color_bg], rxvt_color);
 #if defined(XPM_BACKGROUND)
-        if (bgPixmap.pixmap == None)
+      if (bgPixmap.pixmap == None)
 #endif
 #if defined(TRANSPARENT)
-            if (!(Options & Opt_transparent) || am_transparent == 0)
+        if (!(Options & Opt_transparent) || am_transparent == 0)
 #endif
-            XSetWindowBackground(Xdisplay, TermWin.vt,
-                                 PixColors[Color_bg]);
+          XSetWindowBackground(Xdisplay, TermWin.vt,
+                               PixColors[Color_bg]);
 
-        gcvalue.foreground = PixColors[Color_fg];
-        gcvalue.background = PixColors[Color_bg];
-        XChangeGC(Xdisplay, TermWin.gc, GCBackground | GCForeground,
-                  &gcvalue);
-        scr_clear ();
-        scr_touch (true);
+      gcvalue.foreground = PixColors[Color_fg];
+      gcvalue.background = PixColors[Color_bg];
+      XChangeGC(Xdisplay, TermWin.gc, GCBackground | GCForeground,
+                &gcvalue);
+      scr_clear ();
+      scr_touch (true);
     }
 }
 
@@ -1556,7 +1600,7 @@ rxvt_term::scr_rvideo_mode (int mode)
 void
 rxvt_term::scr_report_position ()
 {
-    tt_printf("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1);
+  tt_printf("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1);
 }
 \f
 /* ------------------------------------------------------------------------- *
@@ -1569,20 +1613,21 @@ rxvt_term::scr_report_position ()
 void
 rxvt_term::set_font_style ()
 {
-    switch (charsets[screen.charset]) {
-    case '0':                   /* DEC Special Character & Line Drawing Set */
+  switch (charsets[screen.charset])
+    {
+      case '0':                   /* DEC Special Character & Line Drawing Set */
         break;
-    case 'A':                   /* United Kingdom (UK) */
+      case 'A':                   /* United Kingdom (UK) */
         break;
-    case 'B':                   /* United States (USASCII) */
+      case 'B':                   /* United States (USASCII) */
         break;
-    case '<':                   /* Multinational character set */
+      case '<':                   /* Multinational character set */
         break;
-    case '5':                   /* Finnish character set */
+      case '5':                   /* Finnish character set */
         break;
-    case 'C':                   /* Finnish character set */
+      case 'C':                   /* Finnish character set */
         break;
-    case 'K':                   /* German character set */
+      case 'K':                   /* German character set */
         break;
     }
 }
@@ -1597,10 +1642,10 @@ rxvt_term::set_font_style ()
  */
 void
 rxvt_term::scr_charset_choose (int set)
-{
+  {
     screen.charset = set;
     set_font_style ();
-}
+  }
 
 /* ------------------------------------------------------------------------- */
 /*
@@ -1613,10 +1658,10 @@ rxvt_term::scr_charset_choose (int set)
  */
 void
 rxvt_term::scr_charset_set (int set, unsigned int ch)
-{
+  {
     charsets[set] = (unsigned char)ch;
     set_font_style ();
-}
+  }
 
 \f
 /* ------------------------------------------------------------------------- *
@@ -1651,9 +1696,9 @@ rxvt_term::scr_refresh_rend (rend_t mask, rend_t value)
  * Refresh an area
  */
 enum {
-    PART_BEG = 0,
-    PART_END,
-    RC_COUNT
+  PART_BEG = 0,
+  PART_END,
+  RC_COUNT
 };
 
 void
@@ -1672,14 +1717,14 @@ rxvt_term::scr_expose (int x, int y, int width, int height, bool refresh)
   y = min(y, (int)TermWin.height);
 #endif
 
-/* round down */
+  /* round down */
   rc[PART_BEG].col = Pixel2Col(x);
   rc[PART_BEG].row = Pixel2Row(y);
-/* round up */
+  /* round up */
   rc[PART_END].col = Pixel2Width(x + width + TermWin.fwidth - 1);
   rc[PART_END].row = Pixel2Row(y + height + TermWin.fheight - 1);
 
-/* sanity checks */
+  /* sanity checks */
   for (i = PART_BEG; i < RC_COUNT; i++)
     {
       MIN_IT(rc[i].col, TermWin.ncol - 1);
@@ -1714,19 +1759,20 @@ rxvt_term::scr_touch (bool refresh)
 int
 rxvt_term::scr_move_to (int y, int len)
 {
-    long p = 0;
-    uint16_t oldviewstart;
+  long p = 0;
+  uint16_t oldviewstart;
 
-    oldviewstart = TermWin.view_start;
-    if (y < len) {
-        p = (TermWin.nrow + TermWin.nscrolled) * (len - y) / len;
-        p -= (long)(TermWin.nrow - 1);
-        p = max(p, 0);
+  oldviewstart = TermWin.view_start;
+  if (y < len)
+    {
+      p = (TermWin.nrow + TermWin.nscrolled) * (len - y) / len;
+      p -= (long)(TermWin.nrow - 1);
+      p = max(p, 0);
     }
-    TermWin.view_start = (uint16_t)min(p, TermWin.nscrolled);
-    D_SCREEN((stderr, "rxvt_scr_move_to(%d, %d) view_start:%d", y, len, TermWin.view_start));
+  TermWin.view_start = (uint16_t)min(p, TermWin.nscrolled);
+  D_SCREEN((stderr, "rxvt_scr_move_to(%d, %d) view_start:%d", y, len, TermWin.view_start));
 
-    return scr_changeview (oldviewstart);
+  return scr_changeview (oldviewstart);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1737,36 +1783,40 @@ rxvt_term::scr_move_to (int y, int len)
 int
 rxvt_term::scr_page (enum page_dirn direction, int nlines)
 {
-    int             n;
-    uint16_t       oldviewstart;
+  int             n;
+  uint16_t       oldviewstart;
 
-    D_SCREEN((stderr, "rxvt_scr_page(%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start));
+  D_SCREEN((stderr, "rxvt_scr_page(%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start));
 #ifdef DEBUG_STRICT
-    assert((nlines >= 0) && (nlines <= TermWin.nrow));
+  assert((nlines >= 0) && (nlines <= TermWin.nrow));
 #endif
-    oldviewstart = TermWin.view_start;
-    if (direction == UP) {
-        n = TermWin.view_start + nlines;
-        TermWin.view_start = min(n, TermWin.nscrolled);
-    } else {
-        n = TermWin.view_start - nlines;
-        TermWin.view_start = max(n, 0);
+  oldviewstart = TermWin.view_start;
+  if (direction == UP)
+    {
+      n = TermWin.view_start + nlines;
+      TermWin.view_start = min(n, TermWin.nscrolled);
+    }
+  else
+    {
+      n = TermWin.view_start - nlines;
+      TermWin.view_start = max(n, 0);
     }
-    return scr_changeview (oldviewstart);
+  return scr_changeview (oldviewstart);
 }
 
 int
 rxvt_term::scr_changeview (uint16_t oldviewstart)
 {
-    if (TermWin.view_start != oldviewstart) {
-        want_refresh = 1;
+  if (TermWin.view_start != oldviewstart)
+    {
+      want_refresh = 1;
 #ifdef RXVT_GRAPHICS
-        if (Gr_Displayed ())
-            Gr_scroll (0);
+      if (Gr_Displayed ())
+        Gr_scroll (0);
 #endif
-        num_scr -= (TermWin.view_start - oldviewstart);
+      num_scr -= (TermWin.view_start - oldviewstart);
     }
-    return (int)(TermWin.view_start - oldviewstart);
+  return (int)(TermWin.view_start - oldviewstart);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1776,15 +1826,17 @@ rxvt_term::scr_bell ()
 #ifndef NO_BELL
 # ifndef NO_MAPALERT
 #  ifdef MAPALERT_OPTION
-    if (Options & Opt_mapAlert)
+  if (Options & Opt_mapAlert)
 #  endif
-        XMapWindow(Xdisplay, TermWin.parent[0]);
+    XMapWindow(Xdisplay, TermWin.parent[0]);
 # endif
-    if (Options & Opt_visualBell) {
-        scr_rvideo_mode (!rvideo); /* refresh also done */
-        scr_rvideo_mode (!rvideo); /* refresh also done */
-    } else
-        XBell(Xdisplay, 0);
+  if (Options & Opt_visualBell)
+    {
+      scr_rvideo_mode (!rvideo); /* refresh also done */
+      scr_rvideo_mode (!rvideo); /* refresh also done */
+    }
+  else
+    XBell(Xdisplay, 0);
 #endif
 }
 
@@ -1794,29 +1846,31 @@ void
 rxvt_term::scr_printscreen (int fullhist)
 {
 #ifdef PRINTPIPE
-    int             i, r1, nrows, row_offset;
-    text_t         *t;
-    FILE           *fd;
+  int             i, r1, nrows, row_offset;
+  text_t         *t;
+  FILE           *fd;
 
-    if ((fd = popen_printer ()) == NULL)
-        return;
-    nrows = TermWin.nrow;
-    row_offset = TermWin.saveLines;
-    if (!fullhist)
-        row_offset -= TermWin.view_start;
-    else {
-        nrows += TermWin.nscrolled;
-        row_offset -= TermWin.nscrolled;
-    }
-
-    for (r1 = 0; r1 < nrows; r1++) {
-        t = screen.text[r1 + row_offset];
-        for (i = TermWin.ncol - 1; i >= 0; i--)
-            if (!isspace(t[i]))
-                break;
-        fprintf(fd, "%.*s\n", (i + 1), t);
+  if ((fd = popen_printer ()) == NULL)
+    return;
+  nrows = TermWin.nrow;
+  row_offset = TermWin.saveLines;
+  if (!fullhist)
+    row_offset -= TermWin.view_start;
+  else
+    {
+      nrows += TermWin.nscrolled;
+      row_offset -= TermWin.nscrolled;
+    }
+
+  for (r1 = 0; r1 < nrows; r1++)
+    {
+      t = screen.text[r1 + row_offset];
+      for (i = TermWin.ncol - 1; i >= 0; i--)
+        if (!isspace(t[i]))
+          break;
+      fprintf(fd, "%.*s\n", (i + 1), t);
     }
-    pclose_printer (fd);
+  pclose_printer (fd);
 #endif
 }
 
@@ -1839,416 +1893,429 @@ rxvt_term::scr_printscreen (int fullhist)
 void
 rxvt_term::scr_refresh (unsigned char refresh_type)
 {
-    unsigned char   clearfirst, /* first character writes before cell        */
-                    clearlast,  /* last character writes beyond cell         */
-                    must_clear, /* use draw_string not draw_image_string     */
-                    rvid,       /* reverse video this position               */
-                    showcursor; /* show the cursor                           */
-    int16_t         col, row,   /* column/row we're processing               */
-                    ocrow;      /* old cursor row                            */
-    int             cursorwidth;
-    int             i,          /* tmp                                       */
-                    row_offset; /* basic offset in screen structure          */
+  unsigned char   clearfirst, /* first character writes before cell        */
+  clearlast,  /* last character writes beyond cell         */
+  must_clear, /* use draw_string not draw_image_string     */
+  rvid,       /* reverse video this position               */
+  showcursor; /* show the cursor                           */
+  int16_t         col, row,   /* column/row we're processing               */
+  ocrow;      /* old cursor row                            */
+  int             cursorwidth;
+  int             i,          /* tmp                                       */
+  row_offset; /* basic offset in screen structure          */
 #ifndef NO_CURSORCOLOR
-    rend_t          cc1;        /* store colours at cursor position(s)       */
+  rend_t          cc1;        /* store colours at cursor position(s)       */
 #endif
-    rend_t         *drp, *srp;  /* drawn-rend-pointer, screen-rend-pointer   */
-    text_t         *dtp, *stp;  /* drawn-text-pointer, screen-text-pointer   */
+  rend_t         *drp, *srp;  /* drawn-rend-pointer, screen-rend-pointer   */
+  text_t         *dtp, *stp;  /* drawn-text-pointer, screen-text-pointer   */
 
-    if (refresh_type == NO_REFRESH || !TermWin.mapped)
-      return;
+  if (refresh_type == NO_REFRESH || !TermWin.mapped)
+    return;
 
-    /*
-     * A: set up vars
-     */
-    clearfirst = clearlast = must_clear = 0;
+  /*
+   * A: set up vars
+   */
+  clearfirst = clearlast = must_clear = 0;
 
-    refresh_count = 0;
+  refresh_count = 0;
 
-    row_offset = TermWin.saveLines - TermWin.view_start;
+  row_offset = TermWin.saveLines - TermWin.view_start;
 
-    if ((refresh_type & REFRESH_BOUNDS))
-      {
-        clearfirst = clearlast = 1;
-        refresh_type &= ~REFRESH_BOUNDS;
-      }
+  if ((refresh_type & REFRESH_BOUNDS))
+    {
+      clearfirst = clearlast = 1;
+      refresh_type &= ~REFRESH_BOUNDS;
+    }
 
 #ifdef XPM_BACKGROUND
-    must_clear |= (bgPixmap.pixmap != None);
+  must_clear |= (bgPixmap.pixmap != None);
 #endif
 #ifdef TRANSPARENT
-    must_clear |= ((Options & Opt_transparent) && am_transparent);
+  must_clear |= ((Options & Opt_transparent) && am_transparent);
 #endif
-    ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
-
-    /*
-     * B: reverse any characters which are selected
-     */
-    scr_reverse_selection ();
+  ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
 
-    /*
-     * C: set the cursor character(s)
-     */
-    {
-      unsigned char   setoldcursor;
-      rend_t          ccol1,  /* Cursor colour       */
-                      ccol2;  /* Cursor colour2      */
+  /*
+   * B: reverse any characters which are selected
+   */
+  scr_reverse_selection ();
 
-      showcursor = (screen.flags & Screen_VisibleCursor);
-      cursorwidth = 0;
+  /*
+   * C: set the cursor character(s)
+   */
+  {
+    unsigned char   setoldcursor;
+    rend_t          ccol1,  /* Cursor colour       */
+    ccol2;  /* Cursor colour2      */
+
+    showcursor = (screen.flags & Screen_VisibleCursor);
+    cursorwidth = 0;
 #ifdef CURSOR_BLINK
-      if (hidden_cursor)
-          showcursor = 0;
+    if (hidden_cursor)
+      showcursor = 0;
 #endif
 
-      cursorwidth = 0;
+    cursorwidth = 0;
 
-      if (showcursor)
-        {
-          cursorwidth++;
+    if (showcursor)
+      {
+        cursorwidth++;
 
-          srp = &(screen.rend[screen.cur.row + TermWin.saveLines]
-                                [screen.cur.col]);
+        srp = &(screen.rend[screen.cur.row + TermWin.saveLines]
+                [screen.cur.col]);
 
-          if (showcursor && TermWin.focus)
-            {
-              *srp ^= RS_RVid;
+        if (showcursor && TermWin.focus)
+          {
+            *srp ^= RS_RVid;
 #ifndef NO_CURSORCOLOR
-              cc1 = *srp & (RS_fgMask | RS_bgMask);
-              if (ISSET_PIXCOLOR (Color_cursor))
-                  ccol1 = Color_cursor;
-              else
+            cc1 = *srp & (RS_fgMask | RS_bgMask);
+            if (ISSET_PIXCOLOR (Color_cursor))
+              ccol1 = Color_cursor;
+            else
 #ifdef CURSOR_COLOR_IS_RENDITION_COLOR
-                  ccol1 = GET_FGCOLOR(rstyle);
+              ccol1 = GET_FGCOLOR(rstyle);
 #else
-                  ccol1 = Color_fg;
+              ccol1 = Color_fg;
 #endif
-              if (ISSET_PIXCOLOR (Color_cursor2))
-                  ccol2 = Color_cursor2;
-              else
+            if (ISSET_PIXCOLOR (Color_cursor2))
+              ccol2 = Color_cursor2;
+            else
 #ifdef CURSOR_COLOR_IS_RENDITION_COLOR
-                  ccol2 = GET_BGCOLOR(rstyle);
+              ccol2 = GET_BGCOLOR(rstyle);
 #else
-                  ccol2 = Color_bg;
+              ccol2 = Color_bg;
 #endif
-              *srp = SET_FGCOLOR(*srp, ccol1);
-              *srp = SET_BGCOLOR(*srp, ccol2);
+            *srp = SET_FGCOLOR(*srp, ccol1);
+            *srp = SET_BGCOLOR(*srp, ccol2);
 #endif
-            }
-        }
 
-      /* make sure no outline cursor is left around */
-      setoldcursor = 0;
-      if (ocrow != -1) {
-          if (screen.cur.row + TermWin.view_start != ocrow
-              || screen.cur.col != oldcursor.col) {
-              if (ocrow < TermWin.nrow
-                  && oldcursor.col < TermWin.ncol) {
-                  drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline);
-              }
-              if (TermWin.focus || !showcursor)
-                  oldcursor.row = -1;
-              else
-                  setoldcursor = 1;
-          }
-      } else if (!TermWin.focus)
-          setoldcursor = 1;
-      if (setoldcursor) {
-          if (screen.cur.row + TermWin.view_start >= TermWin.nrow)
-              oldcursor.row = -1;
-          else {
-              oldcursor.row = screen.cur.row + TermWin.view_start;
-              oldcursor.col = screen.cur.col;
           }
       }
-    }
 
-#ifndef NO_SLOW_LINK_SUPPORT
-    /*
-     * D: CopyArea pass - very useful for slower links
-     *    This has been deliberately kept simple.
-     */
-    i = num_scr;
-    if (refresh_type == FAST_REFRESH && num_scr_allow && i
-        && abs(i) < TermWin.nrow && !must_clear)
+    /* make sure no outline cursor is left around */
+    setoldcursor = 0;
+    if (ocrow != -1)
       {
-        int16_t         nits;
-        int             j;
-        rend_t         *drp2;
-        text_t         *dtp2;
-        int             len, wlen;
-
-        j = TermWin.nrow;
-        wlen = len = -1;
-        row = i > 0 ? 0 : j - 1;
-        for (; j-- >= 0; row += (i > 0 ? 1 : -1))
+        if (screen.cur.row + TermWin.view_start != ocrow
+            || screen.cur.col != oldcursor.col)
           {
-            if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow)
-              {
-                stp = screen.text[row + row_offset];
-                srp = screen.rend[row + row_offset];
-                dtp = drawn_text[row];
-                dtp2 = drawn_text[row + i];
-                drp = drawn_rend[row];
-                drp2 = drawn_rend[row + i];
-
-                for (nits = 0, col = TermWin.ncol; col--; )
-                  if (stp[col] != dtp2[col] || srp[col] != drp2[col])
-                    nits--;
-                  else if (stp[col] != dtp[col] || srp[col] != drp[col])
-                    nits++;
-
-                if (nits > 8) /* XXX: arbitrary choice */
-                  {
-                    for (col = TermWin.ncol; col--; )
-                      {
-                        *dtp++ = *dtp2++;
-                        *drp++ = *drp2++;
-                      }
-
-                    if (len == -1)
-                      len = row;
-
-                    wlen = row;
-                    continue;
-                  }
-              }
-
-            if (len != -1)
+            if (ocrow < TermWin.nrow
+                && oldcursor.col < TermWin.ncol)
               {
-                /* also comes here at end if needed because of >= above */
-                if (wlen < len)
-                  SWAP_IT(wlen, len, int);
-
-                D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1));
-                XCopyArea (Xdisplay, TermWin.vt, TermWin.vt,
-                           TermWin.gc, 0, Row2Pixel (len + i),
-                           (unsigned int)TermWin_TotalWidth (),
-                           (unsigned int)Height2Pixel (wlen - len + 1),
-                           0, Row2Pixel (len));
-                len = -1;
+                drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline);
               }
+            if (TermWin.focus || !showcursor)
+              oldcursor.row = -1;
+            else
+              setoldcursor = 1;
           }
-    }
+      }
+    else if (!TermWin.focus)
+      setoldcursor = 1;
+    if (setoldcursor)
+      {
+        if (screen.cur.row + TermWin.view_start >= TermWin.nrow)
+          oldcursor.row = -1;
+        else
+          {
+            oldcursor.row = screen.cur.row + TermWin.view_start;
+            oldcursor.col = screen.cur.col;
+          }
+      }
+  }
+
+#ifndef NO_SLOW_LINK_SUPPORT
+  /*
+   * D: CopyArea pass - very useful for slower links
+   *    This has been deliberately kept simple.
+   */
+  i = num_scr;
+  if (refresh_type == FAST_REFRESH && num_scr_allow && i
+      && abs(i) < TermWin.nrow && !must_clear)
+    {
+      int16_t         nits;
+      int             j;
+      rend_t         *drp2;
+      text_t         *dtp2;
+      int             len, wlen;
+
+      j = TermWin.nrow;
+      wlen = len = -1;
+      row = i > 0 ? 0 : j - 1;
+      for (; j-- >= 0; row += (i > 0 ? 1 : -1))
+        {
+          if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow)
+            {
+              stp = screen.text[row + row_offset];
+              srp = screen.rend[row + row_offset];
+              dtp = drawn_text[row];
+              dtp2 = drawn_text[row + i];
+              drp = drawn_rend[row];
+              drp2 = drawn_rend[row + i];
+
+              for (nits = 0, col = TermWin.ncol; col--; )
+                if (stp[col] != dtp2[col] || srp[col] != drp2[col])
+                  nits--;
+                else if (stp[col] != dtp[col] || srp[col] != drp[col])
+                  nits++;
+
+              if (nits > 8) /* XXX: arbitrary choice */
+                {
+                  for (col = TermWin.ncol; col--; )
+                    {
+                      *dtp++ = *dtp2++;
+                      *drp++ = *drp2++;
+                    }
+
+                  if (len == -1)
+                    len = row;
+
+                  wlen = row;
+                  continue;
+                }
+            }
+
+          if (len != -1)
+            {
+              /* also comes here at end if needed because of >= above */
+              if (wlen < len)
+                SWAP_IT(wlen, len, int);
+
+              D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1));
+              XCopyArea (Xdisplay, TermWin.vt, TermWin.vt,
+                         TermWin.gc, 0, Row2Pixel (len + i),
+                         (unsigned int)TermWin_TotalWidth (),
+                         (unsigned int)Height2Pixel (wlen - len + 1),
+                         0, Row2Pixel (len));
+              len = -1;
+            }
+        }
+    }
 #endif
 
-    /*
-     * E: main pass across every character
-     */
-    for (row = 0; row < TermWin.nrow; row++)
-      {
-        stp = screen.text[row + row_offset];
-        srp = screen.rend[row + row_offset];
-        dtp = drawn_text[row];
-        drp = drawn_rend[row];
+  /*
+   * E: main pass across every character
+   */
+  for (row = 0; row < TermWin.nrow; row++)
+    {
+      stp = screen.text[row + row_offset];
+      srp = screen.rend[row + row_offset];
+      dtp = drawn_text[row];
+      drp = drawn_rend[row];
 
-        /*
-         * E2: OK, now the real pass
-         */
-        int ypixel = (int)Row2Pixel(row);
+      /*
+       * E2: OK, now the real pass
+       */
+      int ypixel = (int)Row2Pixel(row);
 
-        for (col = 0; col < TermWin.ncol; col++)
-          {
-            /* compare new text with old - if exactly the same then continue */
-            rend_t rend = srp[col];     /* screen rendition (target rendtion) */
+      for (col = 0; col < TermWin.ncol; col++)
+        {
+          /* compare new text with old - if exactly the same then continue */
+          rend_t rend = srp[col];     /* screen rendition (target rendtion) */
 
-            if (stp[col] == dtp[col]    /* Must match characters to skip. */
-                && (rend == drp[col]    /* Either rendition the same or   */
-                    || (stp[col] == ' ' /* space w/ no background change  */
-                        && GET_BGATTR(rend) == GET_BGATTR(drp[col]))))
-              continue;
+          if (stp[col] == dtp[col]    /* Must match characters to skip. */
+              && (rend == drp[col]    /* Either rendition the same or   */
+                  || (stp[col] == ' ' /* space w/ no background change  */
+                      && GET_BGATTR(rend) == GET_BGATTR(drp[col]))))
+            continue;
 
-            text_t *text = stp + col;
-            int count = 1;
+          text_t *text = stp + col;
+          int count = 1;
 
-            /* redraw one or more characters */
+          /* redraw one or more characters */
 
-            dtp[col] = stp[col];
-            drp[col] = rend;
+          dtp[col] = stp[col];
+          drp[col] = rend;
 
-            if (*text == NOCHAR) // never start redrawing at invisible characters. */
-              continue;
+          if (*text == NOCHAR) // never start redrawing at invisible characters. */
+            continue;
 
-            int xpixel = Col2Pixel(col);
+          int xpixel = Col2Pixel(col);
 
-            // this loop looks very messy, it can probably be optimized
-            // and cleaned a bit by you?
-            for (i = 0; ++col < TermWin.ncol; )
-              {
-                if (stp[col] == NOCHAR)
-                  {
-                    dtp[col] = stp[col];
-                    drp[col] = rend;
-                    count++;
+          // this loop looks very messy, it can probably be optimized
+          // and cleaned a bit by you?
+          for (i = 0; ++col < TermWin.ncol; )
+            {
+              if (stp[col] == NOCHAR)
+                {
+                  dtp[col] = stp[col];
+                  drp[col] = rend;
+                  count++;
 
-                    if (i) // only possible skip if char unchanged
-                      i++;
+                  if (i) // only possible skip if char unchanged
+                    i++;
 
-                    continue;
-                  }
+                  continue;
+                }
 
-                if (rend != srp[col])
-                  break;
+              if (rend != srp[col])
+                break;
 
-                count++;
+              count++;
 
-                if (stp[col] != dtp[col]
-                    || srp[col] != drp[col])
-                  {
-                    if (must_clear && (i++ > (count / 2)))
-                      break;
+              if (stp[col] != dtp[col]
+                  || srp[col] != drp[col])
+                {
+                  if (must_clear && (i++ > (count / 2)))
+                    break;
 
-                    dtp[col] = stp[col];
-                    drp[col] = rend;
-                    i = 0;
-                  }
-                else if (must_clear || (stp[col] != ' ' && ++i >= 32))
-                  break;
-              }
+                  dtp[col] = stp[col];
+                  drp[col] = rend;
+                  i = 0;
+                }
+              else if (must_clear || (stp[col] != ' ' && ++i >= 32))
+                break;
+            }
 
-            col--;      /* went one too far.  move back */
-            count -= i; /* dump any matching trailing chars */
+          col--;      /* went one too far.  move back */
+          count -= i; /* dump any matching trailing chars */
 
-            /*
-             * Determine the attributes for the string
-             */
-            int fid = GET_FONT (rend);
-            int fore = GET_FGCOLOR (rend); // desired foreground
-            int back = GET_BGCOLOR (rend); // desired background
+          /*
+           * Determine the attributes for the string
+           */
+          int fid = GET_FONT (rend);
+          int fore = GET_FGCOLOR (rend); // desired foreground
+          int back = GET_BGCOLOR (rend); // desired background
 
-            rend = GET_ATTR (rend);
+          rend = GET_ATTR (rend);
 
-            rvid = !!(rend & RS_RVid);
-            if (rvid)
-              {
-                SWAP_IT(fore, back, int);
+          rvid = !!(rend & RS_RVid);
+          if (rvid)
+            {
+              SWAP_IT(fore, back, int);
 
 #ifndef NO_BOLD_UNDERLINE_REVERSE
-                if (ISSET_PIXCOLOR (Color_RV)
+              if (ISSET_PIXCOLOR (Color_RV)
 # ifndef NO_CURSORCOLOR
-                    && !ISSET_PIXCOLOR (Color_cursor)
+                  && !ISSET_PIXCOLOR (Color_cursor)
 # endif
-                    )
-                  back = Color_RV;
+                 )
+                back = Color_RV;
 #endif
-              }
+
+            }
 #ifdef TEXT_BLINK
-            if (rend & RS_Blink)
-              {
-                if (!text_blink_ev.active)
-                  {
-                    text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
-                    hidden_text = 0;
-                  }
-                else if (hidden_text)
-                  fore = back;
-              }
+          if (rend & RS_Blink)
+            {
+              if (!text_blink_ev.active)
+                {
+                  text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
+                  hidden_text = 0;
+                }
+              else if (hidden_text)
+                fore = back;
+            }
 #endif
 #ifndef NO_BOLD_UNDERLINE_REVERSE
-            else if (rend & RS_Bold)
-              {
-                if (ISSET_PIXCOLOR (Color_BD))
-                  fore = Color_BD;
-                else if (fore == Color_fg)
-                  fore = Color_White;
-              }
-            else if (rend & RS_Uline)
-              {
-                if (ISSET_PIXCOLOR (Color_UL))
-                  fore = Color_UL;
-              }
+          else if (rend & RS_Bold)
+            {
+              if (ISSET_PIXCOLOR (Color_BD))
+                fore = Color_BD;
+              else if (fore == Color_fg)
+                fore = Color_White;
+            }
+          else if (rend & RS_Uline)
+            {
+              if (ISSET_PIXCOLOR (Color_UL))
+                fore = Color_UL;
+            }
 #endif
 
-            /*
-             * Actually do the drawing of the string here
-             */
-            rxvt_font *font = (*TermWin.fontset)[fid];
+          /*
+           * Actually do the drawing of the string here
+           */
+          rxvt_font *font = (*TermWin.fontset)[fid];
 
-            if (back == fore)
-              font->clear_rect (xpixel, ypixel,
-                                TermWin.fwidth * count, TermWin.fheight,
-                                back);
-            else if (back == Color_bg)
-              {
-                if (must_clear)
-                  {
-                    CLEAR_CHARS (xpixel, ypixel, count);
-
-                    for (i = 0; i < count; i++) /* don't draw empty strings */
-                      if (text[i] != ' ')
-                        {
-                          font->draw (xpixel, ypixel, text, count, fore, -1);
-                          break;
-                        }
-                  }
-                else
-                  font->draw (xpixel, ypixel, text, count, fore, Color_bg);
-              }
-            else
-              font->draw (xpixel, ypixel, text, count, fore, back);
+          if (back == fore)
+            font->clear_rect (xpixel, ypixel,
+                              TermWin.fwidth * count, TermWin.fheight,
+                              back);
+          else if (back == Color_bg)
+            {
+              if (must_clear)
+                {
+                  CLEAR_CHARS (xpixel, ypixel, count);
+
+                  for (i = 0; i < count; i++) /* don't draw empty strings */
+                    if (text[i] != ' ')
+                      {
+                        font->draw (xpixel, ypixel, text, count, fore, -1);
+                        break;
+                      }
+                }
+              else
+                font->draw (xpixel, ypixel, text, count, fore, Color_bg);
+            }
+          else
+            font->draw (xpixel, ypixel, text, count, fore, back);
 
-            if ((rend & RS_Uline) && (font->descent > 1))
-                XDrawLine(Xdisplay, drawBuffer, TermWin.gc,
-                          xpixel, ypixel + font->ascent + 1,
-                          xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1);
-          }                     /* for (col....) */
-      }                         /* for (row....) */
+          if ((rend & RS_Uline) && (font->descent > 1))
+            XDrawLine(Xdisplay, drawBuffer, TermWin.gc,
+                      xpixel, ypixel + font->ascent + 1,
+                      xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1);
+        }                     /* for (col....) */
+    }                         /* for (row....) */
 
-    /*
-     * G: cleanup cursor and display outline cursor if necessary
-     */
-    if (showcursor) {
-        if (TermWin.focus) {
-            srp = &(screen.rend[screen.cur.row + TermWin.saveLines]
-                                  [screen.cur.col]);
-            *srp ^= RS_RVid;
+  /*
+   * G: cleanup cursor and display outline cursor if necessary
+   */
+  if (showcursor)
+    {
+      if (TermWin.focus)
+        {
+          srp = &(screen.rend[screen.cur.row + TermWin.saveLines]
+                  [screen.cur.col]);
+          *srp ^= RS_RVid;
 #ifndef NO_CURSORCOLOR
-            *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1;
+          *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1;
 #endif
-        } else if (oldcursor.row >= 0) {
+
+        }
+      else if (oldcursor.row >= 0)
+        {
 #ifndef NO_CURSORCOLOR
-            if (ISSET_PIXCOLOR (Color_cursor))
-              XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]);
+          if (ISSET_PIXCOLOR (Color_cursor))
+            XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]);
 #endif
-            XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc,
-                           Col2Pixel(oldcursor.col),
-                           Row2Pixel(oldcursor.row),
-                           (unsigned int)(Width2Pixel(cursorwidth) - 1),
-                           (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1));
+          XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc,
+                         Col2Pixel(oldcursor.col),
+                         Row2Pixel(oldcursor.row),
+                         (unsigned int)(Width2Pixel(cursorwidth) - 1),
+                         (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1));
         }
     }
 
+  /*
+   * H: cleanup selection
+   */
+  scr_reverse_selection ();
+
+  /*
+   * I: other general cleanup
+   */
+  if (clearfirst && TermWin.int_bwidth)
     /*
-     * H: cleanup selection
+     * clear the whole screen height, note that width == 0 is treated
+     * specially by XClearArea
      */
-    scr_reverse_selection ();
-
+    XClearArea(Xdisplay, TermWin.vt, 0, 0,
+               (unsigned int)TermWin.int_bwidth,
+               (unsigned int)TermWin_TotalHeight(), False);
+  if (clearlast && TermWin.int_bwidth)
     /*
-     * I: other general cleanup
+     * clear the whole screen height, note that width == 0 is treated
+     * specially by XClearArea
      */
-    if (clearfirst && TermWin.int_bwidth)
-        /* 
-         * clear the whole screen height, note that width == 0 is treated
-         * specially by XClearArea
-         */
-        XClearArea(Xdisplay, TermWin.vt, 0, 0,
-                   (unsigned int)TermWin.int_bwidth,
-                   (unsigned int)TermWin_TotalHeight(), False);
-    if (clearlast && TermWin.int_bwidth)
-        /* 
-         * clear the whole screen height, note that width == 0 is treated
-         * specially by XClearArea
-         */
-        XClearArea(Xdisplay, TermWin.vt,
-                   TermWin.width + TermWin.int_bwidth, 0,
-                   (unsigned int)TermWin.int_bwidth,
-                   (unsigned int)TermWin_TotalHeight(), False);
-    if (refresh_type & SMOOTH_REFRESH)
-        XSync(Xdisplay, False);
-
-    num_scr = 0;
-    num_scr_allow = 1;
-    want_refresh = 0;        /* screen is current */
+    XClearArea(Xdisplay, TermWin.vt,
+               TermWin.width + TermWin.int_bwidth, 0,
+               (unsigned int)TermWin.int_bwidth,
+               (unsigned int)TermWin_TotalHeight(), False);
+  if (refresh_type & SMOOTH_REFRESH)
+    XSync(Xdisplay, False);
+
+  num_scr = 0;
+  num_scr_allow = 1;
+  want_refresh = 0;        /* screen is current */
 }
 
 /* ------------------------------------------------------------------------- */
@@ -2283,26 +2350,28 @@ rxvt_term::scr_clear()
 void
 rxvt_term::scr_reverse_selection ()
 {
-    int             i, col, row, end_row;
-    rend_t         *srp;
-
-    if (selection.op && current_screen == selection.screen) {
-        end_row = TermWin.saveLines - TermWin.view_start;
-        i = selection.beg.row + TermWin.saveLines;
-        row = selection.end.row + TermWin.saveLines;
-        if (i >= end_row)
-            col = selection.beg.col;
-        else {
-            col = 0;
-            i = end_row;
+  int             i, col, row, end_row;
+  rend_t         *srp;
+
+  if (selection.op && current_screen == selection.screen)
+    {
+      end_row = TermWin.saveLines - TermWin.view_start;
+      i = selection.beg.row + TermWin.saveLines;
+      row = selection.end.row + TermWin.saveLines;
+      if (i >= end_row)
+        col = selection.beg.col;
+      else
+        {
+          col = 0;
+          i = end_row;
         }
-        end_row += TermWin.nrow;
-        for (; i < row && i < end_row; i++, col = 0)
-            for (srp = screen.rend[i]; col < TermWin.ncol; col++)
-                srp[col] ^= RS_RVid;
-        if (i == row && i < end_row)
-            for (srp = screen.rend[i]; col < selection.end.col; col++)
-                srp[col] ^= RS_RVid;
+      end_row += TermWin.nrow;
+      for (; i < row && i < end_row; i++, col = 0)
+        for (srp = screen.rend[i]; col < TermWin.ncol; col++)
+          srp[col] ^= RS_RVid;
+      if (i == row && i < end_row)
+        for (srp = screen.rend[i]; col < selection.end.col; col++)
+          srp[col] ^= RS_RVid;
     }
 }
 
@@ -2315,23 +2384,25 @@ rxvt_term::scr_reverse_selection ()
 void
 rxvt_term::scr_dump (int fd)
 {
-    int             row, wrote;
-    unsigned int    width, towrite;
-    char            r1[] = "\n";
-
-    for (row = TermWin.saveLines - TermWin.nscrolled;
-         row < TermWin.saveLines + TermWin.nrow - 1; row++) {
-        width = screen.tlen[row] >= 0 ? screen.tlen[row]
-                                         : TermWin.ncol;
-        for (towrite = width; towrite; towrite -= wrote) {
-            wrote = write(fd, &(screen.text[row][width - towrite]),
-                          towrite);
-            if (wrote < 0)
-                return;         /* XXX: death, no report */
+  int             row, wrote;
+  unsigned int    width, towrite;
+  char            r1[] = "\n";
+
+  for (row = TermWin.saveLines - TermWin.nscrolled;
+       row < TermWin.saveLines + TermWin.nrow - 1; row++)
+    {
+      width = screen.tlen[row] >= 0 ? screen.tlen[row]
+              : TermWin.ncol;
+      for (towrite = width; towrite; towrite -= wrote)
+        {
+          wrote = write(fd, &(screen.text[row][width - towrite]),
+                        towrite);
+          if (wrote < 0)
+            return;         /* XXX: death, no report */
         }
-        if (screen.tlen[row] >= 0)
-            if (write(fd, r1, 1) <= 0)
-                return; /* XXX: death, no report */
+      if (screen.tlen[row] >= 0)
+        if (write(fd, r1, 1) <= 0)
+          return; /* XXX: death, no report */
     }
 }
 #endif
@@ -2346,31 +2417,31 @@ rxvt_term::scr_dump (int fd)
 void
 rxvt_term::selection_check (int check_more)
 {
-    row_col_t       pos;
+  row_col_t       pos;
 
-    if (!selection.op)
-        return;
+  if (!selection.op)
+    return;
 
-    pos.row = pos.col = 0;
-    if ((selection.beg.row < -(int32_t)TermWin.nscrolled)
-        || (selection.beg.row >= TermWin.nrow)
-        || (selection.mark.row < -(int32_t)TermWin.nscrolled)
-        || (selection.mark.row >= TermWin.nrow)
-        || (selection.end.row < -(int32_t)TermWin.nscrolled)
-        || (selection.end.row >= TermWin.nrow)
-        || (check_more == 1
-            && current_screen == selection.screen
-            && !ROWCOL_IS_BEFORE(screen.cur, selection.beg)
-            && ROWCOL_IS_BEFORE(screen.cur, selection.end))
-        || (check_more == 2
-            && ROWCOL_IS_BEFORE(selection.beg, pos)
-            && ROWCOL_IS_AFTER(selection.end, pos))
-        || (check_more == 3
-            && ROWCOL_IS_AFTER(selection.end, pos))
-        || (check_more == 4     /* screen width change */
-            && (selection.beg.row != selection.end.row
-                || selection.end.col > TermWin.ncol)))
-        CLEAR_SELECTION();
+  pos.row = pos.col = 0;
+  if ((selection.beg.row < -(int32_t)TermWin.nscrolled)
+      || (selection.beg.row >= TermWin.nrow)
+      || (selection.mark.row < -(int32_t)TermWin.nscrolled)
+      || (selection.mark.row >= TermWin.nrow)
+      || (selection.end.row < -(int32_t)TermWin.nscrolled)
+      || (selection.end.row >= TermWin.nrow)
+      || (check_more == 1
+          && current_screen == selection.screen
+          && !ROWCOL_IS_BEFORE(screen.cur, selection.beg)
+          && ROWCOL_IS_BEFORE(screen.cur, selection.end))
+      || (check_more == 2
+          && ROWCOL_IS_BEFORE(selection.beg, pos)
+          && ROWCOL_IS_AFTER(selection.end, pos))
+      || (check_more == 3
+          && ROWCOL_IS_AFTER(selection.end, pos))
+      || (check_more == 4     /* screen width change */
+          && (selection.beg.row != selection.end.row
+              || selection.end.col > TermWin.ncol)))
+    CLEAR_SELECTION();
 }
 
 /* ------------------------------------------------------------------------- */
@@ -2382,7 +2453,7 @@ rxvt_term::paste (const unsigned char *data, unsigned int len)
 {
   unsigned int i, j, n;
   unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE);
-  
+
 #if 0
   /* a paste should act like the user is typing, so check scrollTtyKeypress */
   ZERO_SCROLLBACK (r);
@@ -2428,7 +2499,7 @@ rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop)
           if (selnum != Sel_direct)
             selection_request_other (XA_STRING, selnum);
         }
-      
+
       if ((selection_type & Sel_UTF8String))
         {
           int selnum = selection_type & Sel_whereMask;
@@ -2439,7 +2510,7 @@ rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop)
           else
             selection_type = 0;
         }
-      
+
       return 0;
     }
 
@@ -2526,43 +2597,49 @@ rxvt_term::incr_cb (time_watcher &w)
 void
 rxvt_term::selection_property (Window win, Atom prop)
 {
-    int             reget_time = 0;
+  int             reget_time = 0;
 
-    if (prop == None)
+  if (prop == None)
+    return;
+  D_SELECT((stderr, "rxvt_selection_property(%08lx, %lu)", win, (unsigned long)prop));
+  if (selection_wait == Sel_normal)
+    {
+      int             a, afmt;
+      Atom            atype;
+      unsigned long   bytes_after, nitems;
+      unsigned char  *s = NULL;
+
+      a = XGetWindowProperty(Xdisplay, win, prop, 0L, 1L, False,
+                             xa[XA_INCR], &atype, &afmt, &nitems,
+                             &bytes_after, &s);
+      if (s)
+        XFree(s);
+      if (a != Success)
         return;
-    D_SELECT((stderr, "rxvt_selection_property(%08lx, %lu)", win, (unsigned long)prop));
-    if (selection_wait == Sel_normal) {
-        int             a, afmt;
-        Atom            atype;
-        unsigned long   bytes_after, nitems;
-        unsigned char  *s = NULL;
-
-        a = XGetWindowProperty(Xdisplay, win, prop, 0L, 1L, False,
-                               xa[XA_INCR], &atype, &afmt, &nitems,
-                               &bytes_after, &s);
-        if (s)
-            XFree(s);
-        if (a != Success)
-            return;
 #ifndef __CYGWIN32__
-        if (atype == xa[XA_INCR]) {  /* start an INCR transfer */
-            D_SELECT((stderr, "rxvt_selection_property: INCR: starting transfer"));
-            XDeleteProperty(Xdisplay, win, prop);
-            XFlush(Xdisplay);
-            reget_time = 1;
-            selection_wait = Sel_incr;
+      if (atype == xa[XA_INCR])
+        {  /* start an INCR transfer */
+          D_SELECT((stderr, "rxvt_selection_property: INCR: starting transfer"));
+          XDeleteProperty(Xdisplay, win, prop);
+          XFlush(Xdisplay);
+          reget_time = 1;
+          selection_wait = Sel_incr;
         }
 #endif
-    } else if (selection_wait == Sel_incr) {
-        reget_time = 1;
-        if (selection_paste (win, prop, True) == -1) {
-            D_SELECT((stderr, "rxvt_selection_property: INCR: clean end"));
-            selection_wait = Sel_none;
-            incr_ev.stop ();
+
+    }
+  else if (selection_wait == Sel_incr)
+    {
+      reget_time = 1;
+      if (selection_paste (win, prop, True) == -1)
+        {
+          D_SELECT((stderr, "rxvt_selection_property: INCR: clean end"));
+          selection_wait = Sel_none;
+          incr_ev.stop ();
         }
     }
-    if (reget_time) /* received more data so reget time */
-      incr_ev.start (NOW + 10);
+  if (reget_time) /* received more data so reget time */
+    incr_ev.start (NOW + 10);
 }
 /* ------------------------------------------------------------------------- */
 /*
@@ -2577,58 +2654,64 @@ rxvt_term::selection_property (Window win, Atom prop)
 void
 rxvt_term::selection_request (Time tm, int x, int y)
 {
-    D_SELECT((stderr, "rxvt_selection_request(%lu, %d, %d)", tm, x, y));
-    if (x < 0 || x >= TermWin.width || y < 0 || y >= TermWin.height)
-        return;                 /* outside window */
+  D_SELECT((stderr, "rxvt_selection_request(%lu, %d, %d)", tm, x, y));
+  if (x < 0 || x >= TermWin.width || y < 0 || y >= TermWin.height)
+    return;                 /* outside window */
 
-    if (selection.text != NULL) {    /* internal selection */
-        D_SELECT((stderr, "rxvt_selection_request: pasting internal"));
-        paste (selection.text, selection.len);
-        return;
-    } else {
-        int             i;
+  if (selection.text != NULL)
+    {    /* internal selection */
+      D_SELECT((stderr, "rxvt_selection_request: pasting internal"));
+      paste (selection.text, selection.len);
+      return;
+    }
+  else
+    {
+      int             i;
 
-        selection_request_time = tm;
-        selection_wait = Sel_normal;
-        for (i = Sel_Primary; i <= Sel_Clipboard; i++) {
+      selection_request_time = tm;
+      selection_wait = Sel_normal;
+      for (i = Sel_Primary; i <= Sel_Clipboard; i++)
+        {
 #if X_HAVE_UTF8_STRING
-            selection_type = Sel_UTF8String;
-            if (selection_request_other (xa[XA_UTF8_STRING], i))
-                return;
+          selection_type = Sel_UTF8String;
+          if (selection_request_other (xa[XA_UTF8_STRING], i))
+            return;
 #else
-            selection_type = Sel_CompoundText;
-            if (selection_request_other (xa[XA_COMPOUND_TEXT], i))
-                return;
+          selection_type = Sel_CompoundText;
+          if (selection_request_other (xa[XA_COMPOUND_TEXT], i))
+            return;
 #endif
+
         }
     }
-    selection_wait = Sel_none;       /* don't loop in rxvt_selection_paste() */
-    D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0"));
-    selection_paste (Xroot, XA_CUT_BUFFER0, False);
+  selection_wait = Sel_none;       /* don't loop in rxvt_selection_paste() */
+  D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0"));
+  selection_paste (Xroot, XA_CUT_BUFFER0, False);
 }
 
 int
 rxvt_term::selection_request_other (Atom target, int selnum)
 {
-    Atom            sel;
+  Atom            sel;
 #ifdef DEBUG_SELECT
-    char           *debug_xa_names[] = { "PRIMARY", "SECONDARY", "CLIPBOARD" };
+  char           *debug_xa_names[] = { "PRIMARY", "SECONDARY", "CLIPBOARD" };
 #endif
 
-    selection_type |= selnum;
-    if (selnum == Sel_Primary)
-        sel = XA_PRIMARY;
-    else if (selnum == Sel_Secondary)
-        sel = XA_SECONDARY;
-    else
-        sel = xa[XA_CLIPBOARD];
-    if (XGetSelectionOwner(Xdisplay, sel) != None) {
-        D_SELECT((stderr, "rxvt_selection_request_other: pasting %s", debug_xa_names[selnum]));
-        XConvertSelection(Xdisplay, sel, target, xa[XA_VT_SELECTION],
-                          TermWin.vt, selection_request_time);
-        return 1;
+  selection_type |= selnum;
+  if (selnum == Sel_Primary)
+    sel = XA_PRIMARY;
+  else if (selnum == Sel_Secondary)
+    sel = XA_SECONDARY;
+  else
+    sel = xa[XA_CLIPBOARD];
+  if (XGetSelectionOwner(Xdisplay, sel) != None)
+    {
+      D_SELECT((stderr, "rxvt_selection_request_other: pasting %s", debug_xa_names[selnum]));
+      XConvertSelection(Xdisplay, sel, target, xa[XA_VT_SELECTION],
+                        TermWin.vt, selection_request_time);
+      return 1;
     }
-    return 0;
+  return 0;
 }
 
 /* ------------------------------------------------------------------------- */
@@ -2639,14 +2722,14 @@ rxvt_term::selection_request_other (Atom target, int selnum)
 void
 rxvt_term::selection_clear ()
 {
-    D_SELECT((stderr, "rxvt_selection_clear()"));
+  D_SELECT((stderr, "rxvt_selection_clear()"));
 
-    want_refresh = 1;
-    if (selection.text)
-        free(selection.text);
-    selection.text = NULL;
-    selection.len = 0;
-    CLEAR_SELECTION();
+  want_refresh = 1;
+  if (selection.text)
+    free(selection.text);
+  selection.text = NULL;
+  selection.len = 0;
+  CLEAR_SELECTION();
 }
 
 /* ------------------------------------------------------------------------- */
@@ -2657,120 +2740,121 @@ rxvt_term::selection_clear ()
 void
 rxvt_term::selection_make (Time tm)
 {
-    int             i, col, end_col, row, end_row;
-    unsigned char  *new_selection_text;
-    char           *str;
-    text_t         *t;
+  int             i, col, end_col, row, end_row;
+  unsigned char  *new_selection_text;
+  char           *str;
+  text_t         *t;
 #ifdef ACS_ASCII
-    rend_t         *re;
+  rend_t         *re;
 #endif
 
-    D_SELECT((stderr, "rxvt_selection_make(): selection.op=%d, selection.clicks=%d", selection.op, selection.clicks));
-    switch (selection.op) {
-    case SELECTION_CONT:
+  D_SELECT((stderr, "rxvt_selection_make(): selection.op=%d, selection.clicks=%d", selection.op, selection.clicks));
+  switch (selection.op)
+    {
+      case SELECTION_CONT:
         break;
-    case SELECTION_INIT:
+      case SELECTION_INIT:
         CLEAR_SELECTION();
-    /* FALLTHROUGH */
-    case SELECTION_BEGIN:
+        /* FALLTHROUGH */
+      case SELECTION_BEGIN:
         selection.op = SELECTION_DONE;
-    /* FALLTHROUGH */
-    default:
+        /* FALLTHROUGH */
+      default:
         return;
     }
-    selection.op = SELECTION_DONE;
+  selection.op = SELECTION_DONE;
 
-    if (selection.clicks == 4)
-        return;                 /* nothing selected, go away */
+  if (selection.clicks == 4)
+    return;                 /* nothing selected, go away */
 
-    i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1) + 1;
-    str = (char *)rxvt_malloc(i * MB_CUR_MAX + 1);
+  i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1) + 1;
+  str = (char *)rxvt_malloc(i * MB_CUR_MAX + 1);
 
-    new_selection_text = (unsigned char *)str;
+  new_selection_text = (unsigned char *)str;
 
-    col = selection.beg.col;
-    MAX_IT(col, 0);
-    row = selection.beg.row + TermWin.saveLines;
-    end_row = selection.end.row + TermWin.saveLines;
+  col = selection.beg.col;
+  MAX_IT(col, 0);
+  row = selection.beg.row + TermWin.saveLines;
+  end_row = selection.end.row + TermWin.saveLines;
 
-    for (; row <= end_row; row++, col = 0)
-      {
-        t = &(screen.text[row][col]);
+  for (; row <= end_row; row++, col = 0)
+    {
+      t = &(screen.text[row][col]);
 
-        end_col = screen.tlen[row];
+      end_col = screen.tlen[row];
 
-        if (end_col == -1)
-          end_col = TermWin.ncol;
+      if (end_col == -1)
+        end_col = TermWin.ncol;
 
-        if (row == end_row)
-          MIN_IT (end_col, selection.end.col);
+      if (row == end_row)
+        MIN_IT (end_col, selection.end.col);
 
-        for (; col < end_col; col++)
-          if (*t == NOCHAR)
-            t++;
-          else
-            {
-              int len = wctomb (str, *t++);
-              if (len > 0)
-                str += len;
-            }
+      for (; col < end_col; col++)
+        if (*t == NOCHAR)
+          t++;
+        else
+          {
+            int len = wctomb (str, *t++);
+            if (len > 0)
+              str += len;
+          }
 
-        if (screen.tlen[row] != -1 && row != end_row)
-            *str++ = '\n';
-      }
+      if (screen.tlen[row] != -1 && row != end_row)
+        *str++ = '\n';
+    }
 
 #ifndef NO_OLD_SELECTION
-    if (selection_style == OLD_SELECT)
-        if (end_col == TermWin.ncol)
-            *str++ = '\n';
+  if (selection_style == OLD_SELECT)
+    if (end_col == TermWin.ncol)
+      *str++ = '\n';
 #endif
 #ifndef NO_NEW_SELECTION
-    if (selection_style != OLD_SELECT)
-        if (end_col != selection.end.col)
-            *str++ = '\n';
+  if (selection_style != OLD_SELECT)
+    if (end_col != selection.end.col)
+      *str++ = '\n';
 #endif
-    *str = '\0';
+  *str = '\0';
 
-    i = str - (char *)new_selection_text;
-    if (i == 0)
-      {
-        free (new_selection_text);
-        return;
-      }
+  i = str - (char *)new_selection_text;
+  if (i == 0)
+    {
+      free (new_selection_text);
+      return;
+    }
 
-    // due to MB_MAX_CUR, selection wastage is usually high, so realloc
-    if (str - (char *)new_selection_text > 1024)
-      new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1);
+  // due to MB_MAX_CUR, selection wastage is usually high, so realloc
+  if (str - (char *)new_selection_text > 1024)
+    new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1);
 
-    selection.len = i;
+  selection.len = i;
 
-    if (selection.text)
-        free (selection.text);
+  if (selection.text)
+    free (selection.text);
 
-    selection.text = new_selection_text;
+  selection.text = new_selection_text;
 
-    XSetSelectionOwner(Xdisplay, XA_PRIMARY, TermWin.vt, tm);
-    if (XGetSelectionOwner(Xdisplay, XA_PRIMARY) != TermWin.vt)
-        rxvt_print_error("can't get primary selection");
+  XSetSelectionOwner(Xdisplay, XA_PRIMARY, TermWin.vt, tm);
+  if (XGetSelectionOwner(Xdisplay, XA_PRIMARY) != TermWin.vt)
+    rxvt_print_error("can't get primary selection");
 
 
-    {
-      XTextProperty ct;
-      char *cl = (char *)selection.text;
+  {
+    XTextProperty ct;
+    char *cl = (char *)selection.text;
 
-      if (XmbTextListToTextProperty(Xdisplay, &cl, 1, XStringStyle, &ct) >= 0)
-        {
-          XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8,
-                          PropModeReplace, ct.value, ct.nitems);
-          XFree (ct.value);
-        }
-      else
+    if (XmbTextListToTextProperty(Xdisplay, &cl, 1, XStringStyle, &ct) >= 0)
+      {
         XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8,
-                        PropModeReplace, selection.text, (int)selection.len);
-    }
+                        PropModeReplace, ct.value, ct.nitems);
+        XFree (ct.value);
+      }
+    else
+      XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8,
+                      PropModeReplace, selection.text, (int)selection.len);
+  }
 
-    selection_time = tm;
-    D_SELECT((stderr, "rxvt_selection_make(): selection.len=%d", selection.len));
+  selection_time = tm;
+  D_SELECT((stderr, "rxvt_selection_make(): selection.len=%d", selection.len));
 }
 
 /* ------------------------------------------------------------------------- */
@@ -2790,10 +2874,10 @@ rxvt_term::selection_click (int clicks, int x, int y)
 
   if (clicks == 2 || clicks == 3)
     selection_extend_colrow (selection.mark.col,
-                                  selection.mark.row + TermWin.view_start,
-                                  0, /* button 3     */
-                                  1, /* button press */
-                                  0);        /* click change */
+                             selection.mark.row + TermWin.view_start,
+                             0, /* button 3     */
+                             1, /* button press */
+                             0);        /* click change */
 }
 
 /* ------------------------------------------------------------------------- */
@@ -2803,20 +2887,21 @@ rxvt_term::selection_click (int clicks, int x, int y)
 void
 rxvt_term::selection_start_colrow (int col, int row)
 {
-    want_refresh = 1;
-    selection.mark.col = col;
-    selection.mark.row = row - TermWin.view_start;
-    MAX_IT(selection.mark.row, -(int32_t)TermWin.nscrolled);
-    MIN_IT(selection.mark.row, (int32_t)TermWin.nrow - 1);
-    MAX_IT(selection.mark.col, 0);
-    MIN_IT(selection.mark.col, (int32_t)TermWin.ncol - 1);
+  want_refresh = 1;
+  selection.mark.col = col;
+  selection.mark.row = row - TermWin.view_start;
+  MAX_IT(selection.mark.row, -(int32_t)TermWin.nscrolled);
+  MIN_IT(selection.mark.row, (int32_t)TermWin.nrow - 1);
+  MAX_IT(selection.mark.col, 0);
+  MIN_IT(selection.mark.col, (int32_t)TermWin.ncol - 1);
 
-    if (selection.op) {      /* clear the old selection */
-        selection.beg.row = selection.end.row = selection.mark.row;
-        selection.beg.col = selection.end.col = selection.mark.col;
+  if (selection.op)
+    {      /* clear the old selection */
+      selection.beg.row = selection.end.row = selection.mark.row;
+      selection.beg.col = selection.end.col = selection.mark.col;
     }
-    selection.op = SELECTION_INIT;
-    selection.screen = current_screen;
+  selection.op = SELECTION_INIT;
+  selection.screen = current_screen;
 }
 
 /* ------------------------------------------------------------------------- */
@@ -2833,74 +2918,83 @@ rxvt_term::selection_start_colrow (int col, int row)
 void
 rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret)
 {
-    int             col, row, dirnadd, tcol, trow, w1, w2;
-    row_col_t       bound;
-    text_t         *stp;
-    rend_t         *srp;
-
-    if (dirn == UP) {
-        bound.row = TermWin.saveLines - TermWin.nscrolled - 1;
-        bound.col = 0;
-        dirnadd = -1;
-    } else {
-        bound.row = TermWin.saveLines + TermWin.nrow;
-        bound.col = TermWin.ncol - 1;
-        dirnadd = 1;
-    }
-    row = mark->row + TermWin.saveLines;
-    col = mark->col;
-    MAX_IT(col, 0);
-/* find the edge of a word */
-    stp = &(screen.text[row][col]);
-    w1 = DELIMIT_TEXT(*stp);
-
-    if (selection_style != NEW_SELECT) {
-        if (w1 == 1) {
-            stp += dirnadd;
-            if (DELIMIT_TEXT(*stp) == 1)
-                goto Old_Word_Selection_You_Die;
-            col += dirnadd;
+  int             col, row, dirnadd, tcol, trow, w1, w2;
+  row_col_t       bound;
+  text_t         *stp;
+  rend_t         *srp;
+
+  if (dirn == UP)
+    {
+      bound.row = TermWin.saveLines - TermWin.nscrolled - 1;
+      bound.col = 0;
+      dirnadd = -1;
+    }
+  else
+    {
+      bound.row = TermWin.saveLines + TermWin.nrow;
+      bound.col = TermWin.ncol - 1;
+      dirnadd = 1;
+    }
+  row = mark->row + TermWin.saveLines;
+  col = mark->col;
+  MAX_IT(col, 0);
+  /* find the edge of a word */
+  stp = &(screen.text[row][col]);
+  w1 = DELIMIT_TEXT(*stp);
+
+  if (selection_style != NEW_SELECT)
+    {
+      if (w1 == 1)
+        {
+          stp += dirnadd;
+          if (DELIMIT_TEXT(*stp) == 1)
+            goto Old_Word_Selection_You_Die;
+          col += dirnadd;
         }
-        w1 = 0;
+      w1 = 0;
     }
-    srp = (&screen.rend[row][col]);
-    w2 = DELIMIT_REND(*srp);
+  srp = (&screen.rend[row][col]);
+  w2 = DELIMIT_REND(*srp);
 
-    for (;;) {
-        for (; col != bound.col; col += dirnadd) {
-            stp += dirnadd;
-            if (DELIMIT_TEXT(*stp) != w1)
+  for (;;)
+    {
+      for (; col != bound.col; col += dirnadd)
+        {
+          stp += dirnadd;
+          if (DELIMIT_TEXT(*stp) != w1)
+            break;
+          srp += dirnadd;
+          if (DELIMIT_REND(*srp) != w2)
+            break;
+        }
+      if ((col == bound.col) && (row != bound.row))
+        {
+          if (screen.tlen[(row - (dirn == UP ? 1 : 0))] == -1)
+            {
+              trow = row + dirnadd;
+              tcol = dirn == UP ? TermWin.ncol - 1 : 0;
+              if (screen.text[trow] == NULL)
                 break;
-            srp += dirnadd;
-            if (DELIMIT_REND(*srp) != w2)
+              stp = &(screen.text[trow][tcol]);
+              srp = &(screen.rend[trow][tcol]);
+              if (DELIMIT_TEXT(*stp) != w1 || DELIMIT_REND(*srp) != w2)
                 break;
-        }
-        if ((col == bound.col) && (row != bound.row)) {
-            if (screen.tlen[(row - (dirn == UP ? 1 : 0))] == -1) {
-                trow = row + dirnadd;
-                tcol = dirn == UP ? TermWin.ncol - 1 : 0;
-                if (screen.text[trow] == NULL)
-                    break;
-                stp = &(screen.text[trow][tcol]);
-                srp = &(screen.rend[trow][tcol]);
-                if (DELIMIT_TEXT(*stp) != w1 || DELIMIT_REND(*srp) != w2)
-                    break;
-                row = trow;
-                col = tcol;
-                continue;
+              row = trow;
+              col = tcol;
+              continue;
             }
         }
-        break;
+      break;
     }
-  Old_Word_Selection_You_Die:
-    D_SELECT((stderr, "rxvt_selection_delimit_word(%s,...) @ (r:%3d, c:%3d) has boundary (r:%3d, c:%3d)", (dirn == UP ? "up     " : "down"), mark->row, mark->col, row - TermWin.saveLines, col));
+Old_Word_Selection_You_Die:
+  D_SELECT((stderr, "rxvt_selection_delimit_word(%s,...) @ (r:%3d, c:%3d) has boundary (r:%3d, c:%3d)", (dirn == UP ? "up     " : "down"), mark->row, mark->col, row - TermWin.saveLines, col));
 
-    if (dirn == DN)
-        col++;                  /* put us on one past the end */
+  if (dirn == DN)
+    col++;                  /* put us on one past the end */
 
-/* Poke the values back in */
-    ret->row = row - TermWin.saveLines;
-    ret->col = col;
+  /* Poke the values back in */
+  ret->row = row - TermWin.saveLines;
+  ret->col = col;
 }
 
 /* ------------------------------------------------------------------------- */
@@ -2950,8 +3044,8 @@ rxvt_term::selection_extend (int x, int y, int flag)
     selection.clicks = 1;
 
   selection_extend_colrow (col, row, !!flag,  /* ? button 3      */
-                                flag == 1 ? 1 : 0,     /* ? button press  */
-                                0);    /* no click change */
+                           flag == 1 ? 1 : 0,     /* ? button press  */
+                           0);    /* no click change */
 }
 
 /* ------------------------------------------------------------------------- */
@@ -2961,217 +3055,257 @@ rxvt_term::selection_extend (int x, int y, int flag)
 void
 rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange)
 {
-    int16_t         ncol = TermWin.ncol;
-    int             end_col;
-    row_col_t       pos;
-    enum {
-        LEFT, RIGHT
-    } closeto = RIGHT;
+  int16_t         ncol = TermWin.ncol;
+  int             end_col;
+  row_col_t       pos;
+  enum {
+    LEFT, RIGHT
+  } closeto = RIGHT;
 
-    D_SELECT((stderr, "rxvt_selection_extend_colrow(c:%d, r:%d, %d, %d) clicks:%d, op:%d", col, row, button3, buttonpress, selection.clicks, selection.op));
-    D_SELECT((stderr, "rxvt_selection_extend_colrow() ENT  b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col));
+  D_SELECT((stderr, "rxvt_selection_extend_colrow(c:%d, r:%d, %d, %d) clicks:%d, op:%d", col, row, button3, buttonpress, selection.clicks, selection.op));
+  D_SELECT((stderr, "rxvt_selection_extend_colrow() ENT  b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col));
 
-    want_refresh = 1;
-    switch (selection.op) {
-    case SELECTION_INIT:
+  want_refresh = 1;
+  switch (selection.op)
+    {
+      case SELECTION_INIT:
         CLEAR_SELECTION();
         selection.op = SELECTION_BEGIN;
-    /* FALLTHROUGH */
-    case SELECTION_BEGIN:
+        /* FALLTHROUGH */
+      case SELECTION_BEGIN:
         if (row != selection.mark.row || col != selection.mark.col
             || (!button3 && buttonpress))
-            selection.op = SELECTION_CONT;
+          selection.op = SELECTION_CONT;
         break;
-    case SELECTION_DONE:
+      case SELECTION_DONE:
         selection.op = SELECTION_CONT;
-    /* FALLTHROUGH */
-    case SELECTION_CONT:
+        /* FALLTHROUGH */
+      case SELECTION_CONT:
         break;
-    case SELECTION_CLEAR:
+      case SELECTION_CLEAR:
         selection_start_colrow (col, row);
-    /* FALLTHROUGH */
-    default:
+        /* FALLTHROUGH */
+      default:
         return;
     }
-    if (selection.beg.col == selection.end.col
-        && selection.beg.col != selection.mark.col
-        && selection.beg.row == selection.end.row
-        && selection.beg.row != selection.mark.row) {
-        selection.beg.col = selection.end.col = selection.mark.col;
-        selection.beg.row = selection.end.row = selection.mark.row;
-        D_SELECT((stderr, "rxvt_selection_extend_colrow() ENT2 b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col));
+  if (selection.beg.col == selection.end.col
+      && selection.beg.col != selection.mark.col
+      && selection.beg.row == selection.end.row
+      && selection.beg.row != selection.mark.row)
+    {
+      selection.beg.col = selection.end.col = selection.mark.col;
+      selection.beg.row = selection.end.row = selection.mark.row;
+      D_SELECT((stderr, "rxvt_selection_extend_colrow() ENT2 b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col));
     }
 
-    pos.col = col;
-    pos.row = row;
+  pos.col = col;
+  pos.row = row;
 
-    pos.row -= TermWin.view_start;   /* adjust for scroll */
+  pos.row -= TermWin.view_start;   /* adjust for scroll */
 
 #ifndef NO_OLD_SELECTION
-/*
- * This mimics some of the selection behaviour of version 2.20 and before.
- * There are no ``selection modes'', button3 is always character extension.
- * Note: button3 drag is always available, c.f. v2.20
- * Selection always terminates (left or right as appropriate) at the mark.
- */
-    if (selection_style == OLD_SELECT) {
-        if (selection.clicks == 1 || button3) {
-            if (hate_those_clicks) {
-                hate_those_clicks = 0;
-                if (selection.clicks == 1) {
-                    selection.beg.row = selection.mark.row;
-                    selection.beg.col = selection.mark.col;
-                } else {
-                    selection.mark.row = selection.beg.row;
-                    selection.mark.col = selection.beg.col;
+  /*
+   * This mimics some of the selection behaviour of version 2.20 and before.
+   * There are no ``selection modes'', button3 is always character extension.
+   * Note: button3 drag is always available, c.f. v2.20
+   * Selection always terminates (left or right as appropriate) at the mark.
+   */
+  if (selection_style == OLD_SELECT)
+    {
+      if (selection.clicks == 1 || button3)
+        {
+          if (hate_those_clicks)
+            {
+              hate_those_clicks = 0;
+              if (selection.clicks == 1)
+                {
+                  selection.beg.row = selection.mark.row;
+                  selection.beg.col = selection.mark.col;
                 }
+              else
+                {
+                  selection.mark.row = selection.beg.row;
+                  selection.mark.col = selection.beg.col;
+                }
+            }
+          if (ROWCOL_IS_BEFORE(pos, selection.mark))
+            {
+              selection.end.row = selection.mark.row;
+              selection.end.col = selection.mark.col + 1;
+              selection.beg.row = pos.row;
+              selection.beg.col = pos.col;
             }
-            if (ROWCOL_IS_BEFORE(pos, selection.mark)) {
-                selection.end.row = selection.mark.row;
-                selection.end.col = selection.mark.col + 1;
-                selection.beg.row = pos.row;
-                selection.beg.col = pos.col;
-            } else {
-                selection.beg.row = selection.mark.row;
-                selection.beg.col = selection.mark.col;
-                selection.end.row = pos.row;
-                selection.end.col = pos.col + 1;
+          else
+            {
+              selection.beg.row = selection.mark.row;
+              selection.beg.col = selection.mark.col;
+              selection.end.row = pos.row;
+              selection.end.col = pos.col + 1;
             }
-        } else if (selection.clicks == 2) {
-            selection_delimit_word (UP, &(selection.mark),
-                                        &(selection.beg));
-            selection_delimit_word (DN, &(selection.mark),
-                                        &(selection.end));
-            hate_those_clicks = 1;
-        } else if (selection.clicks == 3) {
-            selection.beg.row = selection.end.row = selection.mark.row;
-            selection.beg.col = 0;
-            selection.end.col = ncol;
-            hate_those_clicks = 1;
         }
-        D_SELECT((stderr, "rxvt_selection_extend_colrow() EXIT b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col));
-        return;
+      else if (selection.clicks == 2)
+        {
+          selection_delimit_word (UP, &(selection.mark),
+                                  &(selection.beg));
+          selection_delimit_word (DN, &(selection.mark),
+                                  &(selection.end));
+          hate_those_clicks = 1;
+        }
+      else if (selection.clicks == 3)
+        {
+          selection.beg.row = selection.end.row = selection.mark.row;
+          selection.beg.col = 0;
+          selection.end.col = ncol;
+          hate_those_clicks = 1;
+        }
+      D_SELECT((stderr, "rxvt_selection_extend_colrow() EXIT b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col));
+      return;
     }
 #endif                          /* ! NO_OLD_SELECTION */
 #ifndef NO_NEW_SELECTION
-/* selection_style must not be OLD_SELECT to get here */
-/*
- * This is mainly xterm style selection with a couple of differences, mainly
- * in the way button3 drag extension works.
- * We're either doing: button1 drag; button3 press; or button3 drag
- *  a) button1 drag : select around a midpoint/word/line - that point/word/line
- *     is always at the left/right edge of the selection.
- *  b) button3 press: extend/contract character/word/line at whichever edge of
- *     the selection we are closest to.
- *  c) button3 drag : extend/contract character/word/line - we select around
- *     a point/word/line which is either the start or end of the selection
- *     and it was decided by whichever point/word/line was `fixed' at the
- *     time of the most recent button3 press
- */
-    if (button3 && buttonpress) {       /* button3 press */
-        /*
-         * first determine which edge of the selection we are closest to
-         */
-        if (ROWCOL_IS_BEFORE(pos, selection.beg)
-            || (!ROWCOL_IS_AFTER(pos, selection.end)
-                && (((pos.col - selection.beg.col)
-                     + ((pos.row - selection.beg.row) * ncol))
-                    < ((selection.end.col - pos.col)
-                       + ((selection.end.row - pos.row) * ncol)))))
-             closeto = LEFT;
-        if (closeto == LEFT) {
-            selection.beg.row = pos.row;
-            selection.beg.col = pos.col;
-            selection.mark.row = selection.end.row;
-            selection.mark.col = selection.end.col
-                                    - (selection.clicks == 2);
-        } else {
-            selection.end.row = pos.row;
-            selection.end.col = pos.col;
-            selection.mark.row = selection.beg.row;
-            selection.mark.col = selection.beg.col;
+  /* selection_style must not be OLD_SELECT to get here */
+  /*
+   * This is mainly xterm style selection with a couple of differences, mainly
+   * in the way button3 drag extension works.
+   * We're either doing: button1 drag; button3 press; or button3 drag
+   *  a) button1 drag : select around a midpoint/word/line - that point/word/line
+   *     is always at the left/right edge of the selection.
+   *  b) button3 press: extend/contract character/word/line at whichever edge of
+   *     the selection we are closest to.
+   *  c) button3 drag : extend/contract character/word/line - we select around
+   *     a point/word/line which is either the start or end of the selection
+   *     and it was decided by whichever point/word/line was `fixed' at the
+   *     time of the most recent button3 press
+   */
+  if (button3 && buttonpress)
+    {       /* button3 press */
+      /*
+       * first determine which edge of the selection we are closest to
+       */
+      if (ROWCOL_IS_BEFORE(pos, selection.beg)
+          || (!ROWCOL_IS_AFTER(pos, selection.end)
+              && (((pos.col - selection.beg.col)
+                   + ((pos.row - selection.beg.row) * ncol))
+                  < ((selection.end.col - pos.col)
+                     + ((selection.end.row - pos.row) * ncol)))))
+        closeto = LEFT;
+      if (closeto == LEFT)
+        {
+          selection.beg.row = pos.row;
+          selection.beg.col = pos.col;
+          selection.mark.row = selection.end.row;
+          selection.mark.col = selection.end.col
+                               - (selection.clicks == 2);
         }
-    } else {                    /* button1 drag or button3 drag */
-        if (ROWCOL_IS_AFTER(selection.mark, pos)) {
-            if ((selection.mark.row == selection.end.row)
-                && (selection.mark.col == selection.end.col)
-                && clickchange && selection.clicks == 2)
-                selection.mark.col--;
-            selection.beg.row = pos.row;
-            selection.beg.col = pos.col;
-            selection.end.row = selection.mark.row;
-            selection.end.col = selection.mark.col
-                                   + (selection.clicks == 2);
-        } else {
-            selection.beg.row = selection.mark.row;
-            selection.beg.col = selection.mark.col;
-            selection.end.row = pos.row;
-            selection.end.col = pos.col;
+      else
+        {
+          selection.end.row = pos.row;
+          selection.end.col = pos.col;
+          selection.mark.row = selection.beg.row;
+          selection.mark.col = selection.beg.col;
+        }
+    }
+  else
+    {                    /* button1 drag or button3 drag */
+      if (ROWCOL_IS_AFTER(selection.mark, pos))
+        {
+          if ((selection.mark.row == selection.end.row)
+              && (selection.mark.col == selection.end.col)
+              && clickchange && selection.clicks == 2)
+            selection.mark.col--;
+          selection.beg.row = pos.row;
+          selection.beg.col = pos.col;
+          selection.end.row = selection.mark.row;
+          selection.end.col = selection.mark.col
+                              + (selection.clicks == 2);
+        }
+      else
+        {
+          selection.beg.row = selection.mark.row;
+          selection.beg.col = selection.mark.col;
+          selection.end.row = pos.row;
+          selection.end.col = pos.col;
         }
     }
 
-    if (selection.clicks == 1) {
-        end_col = screen.tlen[selection.beg.row + TermWin.saveLines];
-        if (end_col != -1 && selection.beg.col > end_col) {
+  if (selection.clicks == 1)
+    {
+      end_col = screen.tlen[selection.beg.row + TermWin.saveLines];
+      if (end_col != -1 && selection.beg.col > end_col)
+        {
 #if 1
-            selection.beg.col = ncol;
+          selection.beg.col = ncol;
 #else
-            if (selection.beg.row != selection.end.row)
-                selection.beg.col = ncol;
-            else
-                selection.beg.col = selection.mark.col;
+          if (selection.beg.row != selection.end.row)
+            selection.beg.col = ncol;
+          else
+            selection.beg.col = selection.mark.col;
 #endif
+
         }
-        end_col = screen.tlen[selection.end.row + TermWin.saveLines];
-        if (end_col != -1 && selection.end.col > end_col)
-            selection.end.col = ncol;
-
-    } else if (selection.clicks == 2) {
-        if (ROWCOL_IS_AFTER(selection.end, selection.beg))
-            selection.end.col--;
-        selection_delimit_word (UP, &(selection.beg),
-                                    &(selection.beg));
-        selection_delimit_word (DN, &(selection.end),
-                                    &(selection.end));
-    } else if (selection.clicks == 3) {
+      end_col = screen.tlen[selection.end.row + TermWin.saveLines];
+      if (end_col != -1 && selection.end.col > end_col)
+        selection.end.col = ncol;
+
+    }
+  else if (selection.clicks == 2)
+    {
+      if (ROWCOL_IS_AFTER(selection.end, selection.beg))
+        selection.end.col--;
+      selection_delimit_word (UP, &(selection.beg),
+                              &(selection.beg));
+      selection_delimit_word (DN, &(selection.end),
+                              &(selection.end));
+    }
+  else if (selection.clicks == 3)
+    {
 #ifndef NO_FRILLS
-        if ((Options & Opt_tripleclickwords)) {
-            int             end_row;
-
-            selection_delimit_word (UP, &(selection.beg),
-                                        &(selection.beg));
-            end_row = screen.tlen[selection.mark.row
-                                     + TermWin.saveLines];
-            for (end_row = selection.mark.row; end_row < TermWin.nrow;
-                 end_row++) {
-                end_col = screen.tlen[end_row + TermWin.saveLines];
-                if (end_col != -1) {
-                    selection.end.row = end_row;
-                    selection.end.col = end_col;
-                    selection_remove_trailing_spaces ();
-                    break;
+      if ((Options & Opt_tripleclickwords))
+        {
+          int             end_row;
+
+          selection_delimit_word (UP, &(selection.beg),
+                                  &(selection.beg));
+          end_row = screen.tlen[selection.mark.row
+                                + TermWin.saveLines];
+          for (end_row = selection.mark.row; end_row < TermWin.nrow;
+               end_row++)
+            {
+              end_col = screen.tlen[end_row + TermWin.saveLines];
+              if (end_col != -1)
+                {
+                  selection.end.row = end_row;
+                  selection.end.col = end_col;
+                  selection_remove_trailing_spaces ();
+                  break;
                 }
             }
-        } else
+        }
+      else
 #endif
+
         {
-            if (ROWCOL_IS_AFTER(selection.mark, selection.beg))
-                selection.mark.col++;
-            selection.beg.col = 0;
-            selection.end.col = ncol;
+          if (ROWCOL_IS_AFTER(selection.mark, selection.beg))
+            selection.mark.col++;
+          selection.beg.col = 0;
+          selection.end.col = ncol;
         }
     }
-    if (button3 && buttonpress) {       /* mark may need to be changed */
-        if (closeto == LEFT) {
-            selection.mark.row = selection.end.row;
-            selection.mark.col = selection.end.col
-                                    - (selection.clicks == 2);
-        } else {
-            selection.mark.row = selection.beg.row;
-            selection.mark.col = selection.beg.col;
+  if (button3 && buttonpress)
+    {       /* mark may need to be changed */
+      if (closeto == LEFT)
+        {
+          selection.mark.row = selection.end.row;
+          selection.mark.col = selection.end.col
+                               - (selection.clicks == 2);
+        }
+      else
+        {
+          selection.mark.row = selection.beg.row;
+          selection.mark.col = selection.beg.col;
         }
     }
-    D_SELECT((stderr, "rxvt_selection_extend_colrow() EXIT b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col));
+  D_SELECT((stderr, "rxvt_selection_extend_colrow() EXIT b:(r:%d,c:%d) m:(r:%d,c:%d), e:(r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col));
 #endif                          /* ! NO_NEW_SELECTION */
 }
 
@@ -3179,32 +3313,37 @@ rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int b
 void
 rxvt_term::selection_remove_trailing_spaces ()
 {
-    int32_t         end_col, end_row;
-    text_t         *stp; 
+  int32_t         end_col, end_row;
+  text_t         *stp;
 
-    end_col = selection.end.col;
-    end_row = selection.end.row;
-    for ( ; end_row >= selection.beg.row; ) {
-        stp = screen.text[end_row + TermWin.saveLines];
-        while (--end_col >= 0) {
-            if (stp[end_col] != ' ' && stp[end_col] != '\t')
-                break;
-        }
-        if (end_col >= 0
-            || screen.tlen[end_row - 1 + TermWin.saveLines] != -1) {
-            selection.end.col = end_col + 1;
-            selection.end.row = end_row;
+  end_col = selection.end.col;
+  end_row = selection.end.row;
+  for ( ; end_row >= selection.beg.row; )
+    {
+      stp = screen.text[end_row + TermWin.saveLines];
+      while (--end_col >= 0)
+        {
+          if (stp[end_col] != ' ' && stp[end_col] != '\t')
             break;
         }
-        end_row--;
-        end_col = TermWin.ncol;
+      if (end_col >= 0
+          || screen.tlen[end_row - 1 + TermWin.saveLines] != -1)
+        {
+          selection.end.col = end_col + 1;
+          selection.end.row = end_row;
+          break;
+        }
+      end_row--;
+      end_col = TermWin.ncol;
     }
-    if (selection.mark.row > selection.end.row) {
-        selection.mark.row = selection.end.row;
-        selection.mark.col = selection.end.col;
-    } else if (selection.mark.row == selection.end.row
-               && selection.mark.col > selection.end.col)
-        selection.mark.col = selection.end.col;
+  if (selection.mark.row > selection.end.row)
+    {
+      selection.mark.row = selection.end.row;
+      selection.mark.col = selection.end.col;
+    }
+  else if (selection.mark.row == selection.end.row
+           && selection.mark.col > selection.end.col)
+    selection.mark.col = selection.end.col;
 }
 #endif
 
@@ -3236,97 +3375,107 @@ typedef CARD32 Atom32;
 void
 rxvt_term::selection_send (const XSelectionRequestEvent *rq)
 {
-    XSelectionEvent ev;
-    XTextProperty ct;
-    XICCEncodingStyle style;
-    Atom target;
-
-    ev.type = SelectionNotify;
-    ev.property = None;
-    ev.display = rq->display;
-    ev.requestor = rq->requestor;
-    ev.selection = rq->selection;
-    ev.target = rq->target;
-    ev.time = rq->time;
-
-    if (rq->target == xa[XA_TARGETS]) {
-        Atom32 target_list[5];
-        Atom32 *target = target_list;
-
-        *target++ = (Atom32) xa[XA_TARGETS];
-        *target++ = (Atom32) XA_STRING;
-        *target++ = (Atom32) xa[XA_TEXT];
-        *target++ = (Atom32) xa[XA_COMPOUND_TEXT];
+  XSelectionEvent ev;
+  XTextProperty ct;
+  XICCEncodingStyle style;
+  Atom target;
+
+  ev.type = SelectionNotify;
+  ev.property = None;
+  ev.display = rq->display;
+  ev.requestor = rq->requestor;
+  ev.selection = rq->selection;
+  ev.target = rq->target;
+  ev.time = rq->time;
+
+  if (rq->target == xa[XA_TARGETS])
+    {
+      Atom32 target_list[5];
+      Atom32 *target = target_list;
+
+      *target++ = (Atom32) xa[XA_TARGETS];
+      *target++ = (Atom32) XA_STRING;
+      *target++ = (Atom32) xa[XA_TEXT];
+      *target++ = (Atom32) xa[XA_COMPOUND_TEXT];
 #if X_HAVE_UTF8_STRING
-        *target++ = (Atom32) xa[XA_UTF8_STRING];
+      *target++ = (Atom32) xa[XA_UTF8_STRING];
 #endif
-        XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_ATOM,
-                        (8 * sizeof(target_list[0])), PropModeReplace,
-                        (unsigned char *)target_list,
-                        target - target_list);
-        ev.property = rq->property;
-    } else if (rq->target == xa[XA_MULTIPLE]) {
-        /* TODO: Handle MULTIPLE */
-    } else if (rq->target == xa[XA_TIMESTAMP] && selection.text) {
-        XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_INTEGER,
-                        (8 * sizeof(Time)), PropModeReplace,
-                        (unsigned char *)&selection_time, 1);
-        ev.property = rq->property;
-    } else if (rq->target == XA_STRING
-               || rq->target == xa[XA_TEXT]
-               || rq->target == xa[XA_COMPOUND_TEXT]
-               || rq->target == xa[XA_UTF8_STRING]
-              ) {
-        short freect = 0;
-        int selectlen;
-        char *cl;
-
-        target = rq->target;
-
-        if (target == XA_STRING)
-          // we actually don't do XA_STRING, but who cares, as i18n clients
-          // will ask for another format anyways.
-          style = XStringStyle;
-        else if (target == xa[XA_TEXT])
-          style = XTextStyle;
-        else if (target == xa[XA_COMPOUND_TEXT])
-          style = XCompoundTextStyle;
+      XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_ATOM,
+                      (8 * sizeof(target_list[0])), PropModeReplace,
+                      (unsigned char *)target_list,
+                      target - target_list);
+      ev.property = rq->property;
+    }
+  else if (rq->target == xa[XA_MULTIPLE])
+    {
+      /* TODO: Handle MULTIPLE */
+    }
+  else if (rq->target == xa[XA_TIMESTAMP] && selection.text)
+    {
+      XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_INTEGER,
+                      (8 * sizeof(Time)), PropModeReplace,
+                      (unsigned char *)&selection_time, 1);
+      ev.property = rq->property;
+    }
+  else if (rq->target == XA_STRING
+           || rq->target == xa[XA_TEXT]
+           || rq->target == xa[XA_COMPOUND_TEXT]
+           || rq->target == xa[XA_UTF8_STRING]
+          )
+    {
+      short freect = 0;
+      int selectlen;
+      char *cl;
+
+      target = rq->target;
+
+      if (target == XA_STRING)
+        // we actually don't do XA_STRING, but who cares, as i18n clients
+        // will ask for another format anyways.
+        style = XStringStyle;
+      else if (target == xa[XA_TEXT])
+        style = XTextStyle;
+      else if (target == xa[XA_COMPOUND_TEXT])
+        style = XCompoundTextStyle;
 #if X_HAVE_UTF8_STRING
-        else if (target == xa[XA_UTF8_STRING])
-          style = XUTF8StringStyle;
+      else if (target == xa[XA_UTF8_STRING])
+        style = XUTF8StringStyle;
 #endif
-        else
-          {
-            target = xa[XA_COMPOUND_TEXT];
-            style = XCompoundTextStyle;
-          }
+      else
+        {
+          target = xa[XA_COMPOUND_TEXT];
+          style = XCompoundTextStyle;
+        }
 
-        if (selection.text) {
-            cl = (char *)selection.text;
-            selectlen = selection.len;
-        } else {
-            cl = "";
-            selectlen = 0;
+      if (selection.text)
+        {
+          cl = (char *)selection.text;
+          selectlen = selection.len;
+        }
+      else
+        {
+          cl = "";
+          selectlen = 0;
         }
 
-        if (XmbTextListToTextProperty(Xdisplay, &cl, 1, style, &ct) >= 0)
-            freect = 1;
-        else
-          {
-            /* if we failed to convert then send it raw */
-            ct.value = (unsigned char *)cl;
-            ct.nitems = selectlen;
-          }
+      if (XmbTextListToTextProperty(Xdisplay, &cl, 1, style, &ct) >= 0)
+        freect = 1;
+      else
+        {
+          /* if we failed to convert then send it raw */
+          ct.value = (unsigned char *)cl;
+          ct.nitems = selectlen;
+        }
 
-        XChangeProperty(Xdisplay, rq->requestor, rq->property,
-                        target, 8, PropModeReplace,
-                        ct.value, (int)ct.nitems);
-        ev.property = rq->property;
+      XChangeProperty(Xdisplay, rq->requestor, rq->property,
+                      target, 8, PropModeReplace,
+                      ct.value, (int)ct.nitems);
+      ev.property = rq->property;
 
-        if (freect)
-            XFree (ct.value);
+      if (freect)
+        XFree (ct.value);
     }
-    XSendEvent(Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev);
+  XSendEvent(Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev);
 }
 \f
 /* ------------------------------------------------------------------------- *
@@ -3367,39 +3516,42 @@ rxvt_term::set_position (XPoint *pos)
 void
 rxvt_debug_colors(void)
 {
-    int             color;
-    const char     *name[] = {
-        "fg", "bg",
-        "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"
+  int             color;
+  const char     *name[] =
+    {
+      "fg", "bg",
+      "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"
     };
 
-    fprintf(stderr, "Color ( ");
-    if (rstyle & RS_RVid)
-        fprintf(stderr, "rvid ");
-    if (rstyle & RS_Bold)
-        fprintf(stderr, "bold ");
-    if (rstyle & RS_Blink)
-        fprintf(stderr, "blink ");
-    if (rstyle & RS_Uline)
-        fprintf(stderr, "uline ");
-    fprintf(stderr, "): ");
-
-    color = GET_FGCOLOR(rstyle);
+  fprintf(stderr, "Color ( ");
+  if (rstyle & RS_RVid)
+    fprintf(stderr, "rvid ");
+  if (rstyle & RS_Bold)
+    fprintf(stderr, "bold ");
+  if (rstyle & RS_Blink)
+    fprintf(stderr, "blink ");
+  if (rstyle & RS_Uline)
+    fprintf(stderr, "uline ");
+  fprintf(stderr, "): ");
+
+  color = GET_FGCOLOR(rstyle);
 #ifndef NO_BRIGHTCOLOR
-    if (color >= minBrightCOLOR && color <= maxBrightCOLOR) {
-        color -= (minBrightCOLOR - minCOLOR);
-        fprintf(stderr, "bright ");
+  if (color >= minBrightCOLOR && color <= maxBrightCOLOR)
+    {
+      color -= (minBrightCOLOR - minCOLOR);
+      fprintf(stderr, "bright ");
     }
 #endif
-    fprintf(stderr, "%s on ", name[color]);
+  fprintf(stderr, "%s on ", name[color]);
 
-    color = GET_BGCOLOR(rstyle);
+  color = GET_BGCOLOR(rstyle);
 #ifndef NO_BRIGHTCOLOR
-    if (color >= minBrightCOLOR && color <= maxBrightCOLOR) {
-        color -= (minBrightCOLOR - minCOLOR);
-        fprintf(stderr, "bright ");
+  if (color >= minBrightCOLOR && color <= maxBrightCOLOR)
+    {
+      color -= (minBrightCOLOR - minCOLOR);
+      fprintf(stderr, "bright ");
     }
 #endif
-    fprintf(stderr, "%s\n", name[color]);
+  fprintf(stderr, "%s\n", name[color]);
 }
 #endif
index a68a8d2..4c73bb7 100644 (file)
@@ -41,15 +41,17 @@ const unsigned char n_stp_bits[] = { 0x55, 0xaa };
 #define ARROW_WIDTH   13
 #define ARROW_HEIGHT  13
 
-const char     *const SCROLLER_DIMPLE[] = {
+const char     *const SCROLLER_DIMPLE[] =
+  {
     ".%###.",
     "%#%%%%",
     "#%%...",
     "#%..  ",
     "#%.   ",
     ".%.  ."
-};
-const char     *const SCROLLER_ARROW_UP[] = {
+  };
+const char     *const SCROLLER_ARROW_UP[] =
+  {
     ".............",
     ".............",
     "......%......",
@@ -63,8 +65,9 @@ const char     *const SCROLLER_ARROW_UP[] = {
     "..%#######%..",
     ".............",
     "............."
-};
-const char     *const SCROLLER_ARROW_DOWN[] = {
+  };
+const char     *const SCROLLER_ARROW_DOWN[] =
+  {
     ".............",
     ".............",
     "..%#######%..",
@@ -78,8 +81,9 @@ const char     *const SCROLLER_ARROW_DOWN[] = {
     "......%......",
     ".............",
     "............."
-};
-const char     *const HI_SCROLLER_ARROW_UP[] = {
+  };
+const char     *const HI_SCROLLER_ARROW_UP[] =
+  {
     "             ",
     "             ",
     "      %      ",
@@ -93,8 +97,9 @@ const char     *const HI_SCROLLER_ARROW_UP[] = {
     "  %%%%%%%%%  ",
     "             ",
     "             "
-};
-const char     *const HI_SCROLLER_ARROW_DOWN[] = {
+  };
+const char     *const HI_SCROLLER_ARROW_DOWN[] =
+  {
     "             ",
     "             ",
     "  %%%%%%%%%  ",
@@ -108,177 +113,182 @@ const char     *const HI_SCROLLER_ARROW_DOWN[] = {
     "      %      ",
     "             ",
     "             "
-};
+  };
 
 Pixmap
 rxvt_term::renderPixmap (const char *const *data, int width, int height)
 {
-    char            a;
-    int             x, y;
-    Pixmap          d;
-    GC              pointcolour;
+  char            a;
+  int             x, y;
+  Pixmap          d;
+  GC              pointcolour;
 
-    d = XCreatePixmap(Xdisplay, scrollBar.win, width, height, XDEPTH);
+  d = XCreatePixmap(Xdisplay, scrollBar.win, width, height, XDEPTH);
 
-    for (y = 0; y < height; y++) {
-       for (x = 0; x < width; x++) {
-           if ((a = data[y][x]) == ' ' || a == 'w')
-               pointcolour = whiteGC;
-           else if (a == '.' || a == 'l')
-               pointcolour = grayGC;
-           else if (a == '%' || a == 'd')
-               pointcolour = darkGC;
-           else                /* if (a == '#' || a == 'b' || a) */
-               pointcolour = blackGC;
-           XDrawPoint(Xdisplay, d, pointcolour, x, y);
-       }
+  for (y = 0; y < height; y++)
+    {
+      for (x = 0; x < width; x++)
+        {
+          if ((a = data[y][x]) == ' ' || a == 'w')
+            pointcolour = whiteGC;
+          else if (a == '.' || a == 'l')
+            pointcolour = grayGC;
+          else if (a == '%' || a == 'd')
+            pointcolour = darkGC;
+          else         /* if (a == '#' || a == 'b' || a) */
+            pointcolour = blackGC;
+          XDrawPoint(Xdisplay, d, pointcolour, x, y);
+        }
     }
-    return d;
+  return d;
 }
 
 void
 rxvt_term::init_scrollbar_stuff ()
 {
-    XGCValues       gcvalue;
-    XColor          xcol;
-    Pixmap          stipple;
-    unsigned long   light, dark;
+  XGCValues       gcvalue;
+  XColor          xcol;
+  Pixmap          stipple;
+  unsigned long   light, dark;
 
-    gcvalue.graphics_exposures = False;
+  gcvalue.graphics_exposures = False;
 
-    gcvalue.foreground = PixColors[Color_Black];
-    blackGC = XCreateGC(Xdisplay, scrollBar.win,
-                             GCForeground | GCGraphicsExposures, &gcvalue);
+  gcvalue.foreground = PixColors[Color_Black];
+  blackGC = XCreateGC(Xdisplay, scrollBar.win,
+                      GCForeground | GCGraphicsExposures, &gcvalue);
 
-    gcvalue.foreground = PixColors[Color_White];
-    whiteGC = XCreateGC(Xdisplay, scrollBar.win,
-                             GCForeground | GCGraphicsExposures, &gcvalue);
+  gcvalue.foreground = PixColors[Color_White];
+  whiteGC = XCreateGC(Xdisplay, scrollBar.win,
+                      GCForeground | GCGraphicsExposures, &gcvalue);
 
-    xcol.red = 0xaeba;
-    xcol.green = 0xaaaa;
-    xcol.blue = 0xaeba;
-    //if (!rXAllocColor (&xcol, "light gray"))//TODO//D//
-       xcol.pixel = PixColors[Color_AntiqueWhite];
-    light = gcvalue.foreground = xcol.pixel;
-    grayGC = XCreateGC(Xdisplay, scrollBar.win,
-                            GCForeground | GCGraphicsExposures, &gcvalue);
+  xcol.red = 0xaeba;
+  xcol.green = 0xaaaa;
+  xcol.blue = 0xaeba;
+  //if (!rXAllocColor (&xcol, "light gray"))//TODO//D//
+  xcol.pixel = PixColors[Color_AntiqueWhite];
+  light = gcvalue.foreground = xcol.pixel;
+  grayGC = XCreateGC(Xdisplay, scrollBar.win,
+                     GCForeground | GCGraphicsExposures, &gcvalue);
 
-    xcol.red = 0x51aa;
-    xcol.green = 0x5555;
-    xcol.blue = 0x5144;
-    //if (!rXAllocColor (&xcol, "dark gray"))//TODO//D//
-       xcol.pixel = PixColors[Color_Grey25];
-    dark = gcvalue.foreground = xcol.pixel;
-    darkGC = XCreateGC(Xdisplay, scrollBar.win,
-                            GCForeground | GCGraphicsExposures, &gcvalue);
+  xcol.red = 0x51aa;
+  xcol.green = 0x5555;
+  xcol.blue = 0x5144;
+  //if (!rXAllocColor (&xcol, "dark gray"))//TODO//D//
+  xcol.pixel = PixColors[Color_Grey25];
+  dark = gcvalue.foreground = xcol.pixel;
+  darkGC = XCreateGC(Xdisplay, scrollBar.win,
+                     GCForeground | GCGraphicsExposures, &gcvalue);
 
-    stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win,
-                                   (char *)n_stp_bits, n_stp_width,
-                                   n_stp_height);
+  stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win,
+                                  (char *)n_stp_bits, n_stp_width,
+                                  n_stp_height);
 
-    gcvalue.foreground = dark;
-    gcvalue.background = light;
-    gcvalue.fill_style = FillOpaqueStippled;
-    gcvalue.stipple = stipple;
+  gcvalue.foreground = dark;
+  gcvalue.background = light;
+  gcvalue.fill_style = FillOpaqueStippled;
+  gcvalue.stipple = stipple;
 
-/*    XSetWindowBackground(Xdisplay, scrollBar.win, PixColors[Color_Red]); */
+  /*    XSetWindowBackground(Xdisplay, scrollBar.win, PixColors[Color_Red]); */
 
-    stippleGC = XCreateGC(Xdisplay, scrollBar.win,
-                               GCForeground | GCBackground | GCStipple
-                               | GCFillStyle | GCGraphicsExposures, &gcvalue);
+  stippleGC = XCreateGC(Xdisplay, scrollBar.win,
+                        GCForeground | GCBackground | GCStipple
+                        | GCFillStyle | GCGraphicsExposures, &gcvalue);
 
-    dimple = renderPixmap (SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH,
-                                    SCROLLER_DIMPLE_HEIGHT);
+  dimple = renderPixmap (SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH,
+                         SCROLLER_DIMPLE_HEIGHT);
 
-    upArrow = renderPixmap (SCROLLER_ARROW_UP, ARROW_WIDTH,
-                                     ARROW_HEIGHT);
-    downArrow = renderPixmap (SCROLLER_ARROW_DOWN, ARROW_WIDTH,
-                                       ARROW_HEIGHT);
-    upArrowHi = renderPixmap (HI_SCROLLER_ARROW_UP, ARROW_WIDTH,
-                                       ARROW_HEIGHT);
-    downArrowHi = renderPixmap (HI_SCROLLER_ARROW_DOWN,
-                                         ARROW_WIDTH, ARROW_HEIGHT);
+  upArrow = renderPixmap (SCROLLER_ARROW_UP, ARROW_WIDTH,
+                          ARROW_HEIGHT);
+  downArrow = renderPixmap (SCROLLER_ARROW_DOWN, ARROW_WIDTH,
+                            ARROW_HEIGHT);
+  upArrowHi = renderPixmap (HI_SCROLLER_ARROW_UP, ARROW_WIDTH,
+                            ARROW_HEIGHT);
+  downArrowHi = renderPixmap (HI_SCROLLER_ARROW_DOWN,
+                              ARROW_WIDTH, ARROW_HEIGHT);
 }
 
 /* Draw bevel & arrows */
 void
 rxvt_term::drawBevel (Drawable d, int x1, int y1, int w, int h)
 {
-    int             x2, y2;
+  int             x2, y2;
 
-    x2 = x1 + w - 1;           /* right  point */
-    y2 = y1 + h - 1;           /* bottom point */
-/* white top and left */
-    XDrawLine(Xdisplay, d, whiteGC, x1, y1, x2, y1);
-    XDrawLine(Xdisplay, d, whiteGC, x1, y1, x1, y2);
-/* black bottom and right */
-    XDrawLine(Xdisplay, d, blackGC, x1, y2, x2, y2);
-    XDrawLine(Xdisplay, d, blackGC, x2, y1, x2, y2);
-/* dark inside bottom and right */
-    x1++, y1++, x2--, y2--;    /* move in one point */
-    XDrawLine(Xdisplay, d, darkGC, x1, y2, x2, y2);
-    XDrawLine(Xdisplay, d, darkGC, x2, y1, x2, y2);
+  x2 = x1 + w - 1;             /* right  point */
+  y2 = y1 + h - 1;             /* bottom point */
+  /* white top and left */
+  XDrawLine(Xdisplay, d, whiteGC, x1, y1, x2, y1);
+  XDrawLine(Xdisplay, d, whiteGC, x1, y1, x1, y2);
+  /* black bottom and right */
+  XDrawLine(Xdisplay, d, blackGC, x1, y2, x2, y2);
+  XDrawLine(Xdisplay, d, blackGC, x2, y1, x2, y2);
+  /* dark inside bottom and right */
+  x1++, y1++, x2--, y2--;      /* move in one point */
+  XDrawLine(Xdisplay, d, darkGC, x1, y2, x2, y2);
+  XDrawLine(Xdisplay, d, darkGC, x2, y1, x2, y2);
 }
 
 int
 rxvt_term::scrollbar_show_next (int update, int last_top, int last_bot, int scrollbar_len)
 {
-    int             height = scrollBar.end + SB_BUTTON_TOTAL_HEIGHT + SB_PADDING;
-    Drawable        s;
+  int             height = scrollBar.end + SB_BUTTON_TOTAL_HEIGHT + SB_PADDING;
+  Drawable        s;
 
-    if ((scrollBar.init & R_SB_NEXT) == 0) {
-       scrollBar.init |= R_SB_NEXT;
-       init_scrollbar_stuff ();
+  if ((scrollBar.init & R_SB_NEXT) == 0)
+    {
+      scrollBar.init |= R_SB_NEXT;
+      init_scrollbar_stuff ();
     }
 
-    if (TermWin.nscrolled == 0 || !update) {
-       XFillRectangle(Xdisplay, scrollBar.win, grayGC, 0, 0,
-                      SB_WIDTH_NEXT + 1, height);
-       XDrawRectangle(Xdisplay, scrollBar.win, blackGC, 0,
-                      -SB_BORDER_WIDTH, SB_WIDTH_NEXT,
-                      height + SB_BORDER_WIDTH);
-       XFillRectangle(Xdisplay, scrollBar.win, stippleGC,
-                      SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height);
+  if (TermWin.nscrolled == 0 || !update)
+    {
+      XFillRectangle(Xdisplay, scrollBar.win, grayGC, 0, 0,
+                     SB_WIDTH_NEXT + 1, height);
+      XDrawRectangle(Xdisplay, scrollBar.win, blackGC, 0,
+                     -SB_BORDER_WIDTH, SB_WIDTH_NEXT,
+                     height + SB_BORDER_WIDTH);
+      XFillRectangle(Xdisplay, scrollBar.win, stippleGC,
+                     SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height);
     }
-    if (TermWin.nscrolled) {
-       if (last_top < scrollBar.top || !update)
-           XFillRectangle(Xdisplay, scrollBar.win, stippleGC,
-                          SB_LEFT_PADDING, SB_PADDING + last_top,
-                          SB_BUTTON_WIDTH, scrollBar.top - last_top);
-       if (scrollBar.bot < last_bot || !update)
-           XFillRectangle(Xdisplay, scrollBar.win, stippleGC,
-                          SB_LEFT_PADDING, scrollBar.bot + SB_PADDING,
-                          SB_BUTTON_WIDTH, (last_bot - scrollBar.bot));
-       XFillRectangle(Xdisplay, scrollBar.win, grayGC,
-                      SB_LEFT_PADDING, scrollBar.top + SB_PADDING,
-                      SB_BUTTON_WIDTH, scrollbar_len);
-       XCopyArea(Xdisplay, dimple, scrollBar.win, whiteGC, 0, 0,
-                 SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT,
-                 (SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2,
-                 scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT +
-                 (scrollbar_len - SCROLLER_DIMPLE_HEIGHT) / 2);
+  if (TermWin.nscrolled)
+    {
+      if (last_top < scrollBar.top || !update)
+        XFillRectangle(Xdisplay, scrollBar.win, stippleGC,
+                       SB_LEFT_PADDING, SB_PADDING + last_top,
+                       SB_BUTTON_WIDTH, scrollBar.top - last_top);
+      if (scrollBar.bot < last_bot || !update)
+        XFillRectangle(Xdisplay, scrollBar.win, stippleGC,
+                       SB_LEFT_PADDING, scrollBar.bot + SB_PADDING,
+                       SB_BUTTON_WIDTH, (last_bot - scrollBar.bot));
+      XFillRectangle(Xdisplay, scrollBar.win, grayGC,
+                     SB_LEFT_PADDING, scrollBar.top + SB_PADDING,
+                     SB_BUTTON_WIDTH, scrollbar_len);
+      XCopyArea(Xdisplay, dimple, scrollBar.win, whiteGC, 0, 0,
+                SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT,
+                (SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2,
+                scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT +
+                (scrollbar_len - SCROLLER_DIMPLE_HEIGHT) / 2);
 
-       drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X,
-                      scrollBar.top + SB_PADDING, SB_BUTTON_WIDTH,
-                      scrollbar_len);
-       drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X,
-                      height - SB_BUTTON_BOTH_HEIGHT, SB_BUTTON_WIDTH,
-                      SB_BUTTON_HEIGHT);
-       drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X,
-                      height - SB_BUTTON_SINGLE_HEIGHT, SB_BUTTON_WIDTH,
-                      SB_BUTTON_HEIGHT);
+      drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X,
+                 scrollBar.top + SB_PADDING, SB_BUTTON_WIDTH,
+                 scrollbar_len);
+      drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X,
+                 height - SB_BUTTON_BOTH_HEIGHT, SB_BUTTON_WIDTH,
+                 SB_BUTTON_HEIGHT);
+      drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X,
+                 height - SB_BUTTON_SINGLE_HEIGHT, SB_BUTTON_WIDTH,
+                 SB_BUTTON_HEIGHT);
 
-       s = (scrollbar_isUp()) ? upArrowHi : upArrow;
-       XCopyArea(Xdisplay, s, scrollBar.win, whiteGC, 0, 0,
-                 ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
-                 height - SB_BUTTON_BOTH_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
+      s = (scrollbar_isUp()) ? upArrowHi : upArrow;
+      XCopyArea(Xdisplay, s, scrollBar.win, whiteGC, 0, 0,
+                ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
+                height - SB_BUTTON_BOTH_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
 
-       s = (scrollbar_isDn()) ? downArrowHi : downArrow;
-       XCopyArea(Xdisplay, s, scrollBar.win, whiteGC, 0, 0,
-                 ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
-                 height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
+      s = (scrollbar_isDn()) ? downArrowHi : downArrow;
+      XCopyArea(Xdisplay, s, scrollBar.win, whiteGC, 0, 0,
+                ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
+                height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
     }
-    return 1;
+  return 1;
 }
 #endif                         /* NEXT_SCROLLBAR */
 /*----------------------- end-of-file (C source) -----------------------*/
index f45893f..48115c4 100644 (file)
 int
 rxvt_term::scrollbar_show_plain (int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len)
 {
-    int             xsb = 0;
-    int             sbwidth = scrollBar.width - 1;
+  int             xsb = 0;
+  int             sbwidth = scrollBar.width - 1;
 
-    if ((scrollBar.init & R_SB_PLAIN) == 0) {
-       XGCValues       gcvalue;
+  if ((scrollBar.init & R_SB_PLAIN) == 0)
+    {
+      XGCValues       gcvalue;
 
-       scrollBar.init |= R_SB_PLAIN;
-       gcvalue.foreground = PixColors[Color_fg];
-       gcvalue.background = PixColors[Color_bg];
+      scrollBar.init |= R_SB_PLAIN;
+      gcvalue.foreground = PixColors[Color_fg];
+      gcvalue.background = PixColors[Color_bg];
 
-       pscrollbarGC = XCreateGC(Xdisplay, scrollBar.win,
-                                      GCForeground | GCBackground
-                                      | GCFillStyle, &gcvalue);
+      pscrollbarGC = XCreateGC(Xdisplay, scrollBar.win,
+                               GCForeground | GCBackground
+                               | GCFillStyle, &gcvalue);
     }
-/* instead of XClearWindow (Xdisplay, scrollBar.win); */
-    xsb = (Options & Opt_scrollBar_right) ? 1 : 0;
-    if (last_top < scrollBar.top)
-       XClearArea(Xdisplay, scrollBar.win,
-                  sb_shadow + xsb, last_top,
-                  sbwidth + 1, (scrollBar.top - last_top), False);
+  /* instead of XClearWindow (Xdisplay, scrollBar.win); */
+  xsb = (Options & Opt_scrollBar_right) ? 1 : 0;
+  if (last_top < scrollBar.top)
+    XClearArea(Xdisplay, scrollBar.win,
+               sb_shadow + xsb, last_top,
+               sbwidth + 1, (scrollBar.top - last_top), False);
 
-    if (scrollBar.bot < last_bot)
-       XClearArea(Xdisplay, scrollBar.win,
-                  sb_shadow + xsb, scrollBar.bot,
-                  sbwidth + 1, (last_bot - scrollBar.bot), False);
+  if (scrollBar.bot < last_bot)
+    XClearArea(Xdisplay, scrollBar.win,
+               sb_shadow + xsb, scrollBar.bot,
+               sbwidth + 1, (last_bot - scrollBar.bot), False);
 
-/* scrollbar slider */
-    XFillRectangle(Xdisplay, scrollBar.win, pscrollbarGC,
-                  xsb + 1, scrollBar.top, sbwidth, scrollbar_len);
+  /* scrollbar slider */
+  XFillRectangle(Xdisplay, scrollBar.win, pscrollbarGC,
+                 xsb + 1, scrollBar.top, sbwidth, scrollbar_len);
 
-    return 1;
+  return 1;
 }
 #endif                         /* XTERM_SCROLLBAR */
 /*----------------------- end-of-file (C source) -----------------------*/
index 8b2ef63..5d93de0 100644 (file)
 void
 rxvt_term::Draw_button (int x, int y, int state, int dirn)
 {
-    unsigned int    sz, sz2;
-    XPoint          pt[3];
-    GC              top, bot;
-
-    sz = scrollBar.width;
-    sz2 = sz / 2;
-    switch (state) {
-    case +1:
-       top = topShadowGC;
-       bot = botShadowGC;
-       break;
-    case -1:
-       top = botShadowGC;
-       bot = topShadowGC;
-       break;
-    default:
-       top = bot = scrollbarGC;
-       break;
+  unsigned int    sz, sz2;
+  XPoint          pt[3];
+  GC              top, bot;
+
+  sz = scrollBar.width;
+  sz2 = sz / 2;
+  switch (state)
+    {
+      case +1:
+        top = topShadowGC;
+        bot = botShadowGC;
+        break;
+      case -1:
+        top = botShadowGC;
+        bot = topShadowGC;
+        break;
+      default:
+        top = bot = scrollbarGC;
+        break;
     }
 
-/* fill triangle */
-    pt[0].x = x;
-    pt[1].x = x + sz - 1;
-    pt[2].x = x + sz2;
-    if (dirn == UP) {
-       pt[0].y = pt[1].y = y + sz - 1;
-       pt[2].y = y;
-    } else {
-       pt[0].y = pt[1].y = y;
-       pt[2].y = y + sz - 1;
+  /* fill triangle */
+  pt[0].x = x;
+  pt[1].x = x + sz - 1;
+  pt[2].x = x + sz2;
+  if (dirn == UP)
+    {
+      pt[0].y = pt[1].y = y + sz - 1;
+      pt[2].y = y;
+    }
+  else
+    {
+      pt[0].y = pt[1].y = y;
+      pt[2].y = y + sz - 1;
     }
-    XFillPolygon(Xdisplay, scrollBar.win, scrollbarGC,
-                pt, 3, Convex, CoordModeOrigin);
+  XFillPolygon(Xdisplay, scrollBar.win, scrollbarGC,
+               pt, 3, Convex, CoordModeOrigin);
 
-/* draw base */
-    XDrawLine(Xdisplay, scrollBar.win, (dirn == UP ? bot : top),
-             pt[0].x, pt[0].y, pt[1].x, pt[1].y);
+  /* draw base */
+  XDrawLine(Xdisplay, scrollBar.win, (dirn == UP ? bot : top),
+            pt[0].x, pt[0].y, pt[1].x, pt[1].y);
 
-/* draw shadow on left */
-    pt[1].x = x + sz2 - 1;
-    pt[1].y = y + (dirn == UP ? 0 : sz - 1);
-    XDrawLine(Xdisplay, scrollBar.win, top,
-             pt[0].x, pt[0].y, pt[1].x, pt[1].y);
+  /* draw shadow on left */
+  pt[1].x = x + sz2 - 1;
+  pt[1].y = y + (dirn == UP ? 0 : sz - 1);
+  XDrawLine(Xdisplay, scrollBar.win, top,
+            pt[0].x, pt[0].y, pt[1].x, pt[1].y);
 
 #if (SHADOW > 1)
-/* doubled */
-    pt[0].x++;
-    if (dirn == UP) {
-       pt[0].y--;
-       pt[1].y++;
-    } else {
-       pt[0].y++;
-       pt[1].y--;
+  /* doubled */
+  pt[0].x++;
+  if (dirn == UP)
+    {
+      pt[0].y--;
+      pt[1].y++;
+    }
+  else
+    {
+      pt[0].y++;
+      pt[1].y--;
     }
-    XDrawLine(Xdisplay, scrollBar.win, top,
-             pt[0].x, pt[0].y, pt[1].x, pt[1].y);
+  XDrawLine(Xdisplay, scrollBar.win, top,
+            pt[0].x, pt[0].y, pt[1].x, pt[1].y);
 #endif
-/* draw shadow on right */
-    pt[1].x = x + sz - 1;
-/*  pt[2].x = x + sz2; */
-    pt[1].y = y + (dirn == UP ? sz - 1 : 0);
-    pt[2].y = y + (dirn == UP ? 0 : sz - 1);
-    XDrawLine(Xdisplay, scrollBar.win, bot,
-             pt[2].x, pt[2].y, pt[1].x, pt[1].y);
+  /* draw shadow on right */
+  pt[1].x = x + sz - 1;
+  /*  pt[2].x = x + sz2; */
+  pt[1].y = y + (dirn == UP ? sz - 1 : 0);
+  pt[2].y = y + (dirn == UP ? 0 : sz - 1);
+  XDrawLine(Xdisplay, scrollBar.win, bot,
+            pt[2].x, pt[2].y, pt[1].x, pt[1].y);
 #if (SHADOW > 1)
-/* doubled */
-    pt[1].x--;
-    if (dirn == UP) {
-       pt[2].y++;
-       pt[1].y--;
-    } else {
-       pt[2].y--;
-       pt[1].y++;
+  /* doubled */
+  pt[1].x--;
+  if (dirn == UP)
+    {
+      pt[2].y++;
+      pt[1].y--;
     }
-    XDrawLine(Xdisplay, scrollBar.win, bot,
-             pt[2].x, pt[2].y, pt[1].x, pt[1].y);
+  else
+    {
+      pt[2].y--;
+      pt[1].y++;
+    }
+  XDrawLine(Xdisplay, scrollBar.win, bot,
+            pt[2].x, pt[2].y, pt[1].x, pt[1].y);
 #endif
 }
 
 int
 rxvt_term::scrollbar_show_rxvt (int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len)
 {
-    int             sbshadow = sb_shadow;
-    int             sbwidth = (int)scrollBar.width;
-
-    if ((scrollBar.init & R_SB_RXVT) == 0) {
-       XGCValues       gcvalue;
-
-       scrollBar.init |= R_SB_RXVT;
-       gcvalue.foreground = PixColors[Color_trough];
-       if (sbshadow) {
-           XSetWindowBackground(Xdisplay, scrollBar.win,
-                                gcvalue.foreground);
-           XClearWindow(Xdisplay, scrollBar.win);
-       }
-    } else {
-/* instead of XClearWindow (Xdisplay, scrollBar.win); */
-       if (last_top < scrollBar.top)
-           XClearArea(Xdisplay, scrollBar.win,
-                      sbshadow, last_top,
-                      sbwidth, (scrollBar.top - last_top),
-                      False);
-
-       if (scrollBar.bot < last_bot)
-           XClearArea(Xdisplay, scrollBar.win,
-                      sbshadow, scrollBar.bot,
-                      sbwidth, (last_bot - scrollBar.bot),
-                      False);
+  int             sbshadow = sb_shadow;
+  int             sbwidth = (int)scrollBar.width;
+
+  if ((scrollBar.init & R_SB_RXVT) == 0)
+    {
+      XGCValues       gcvalue;
+
+      scrollBar.init |= R_SB_RXVT;
+      gcvalue.foreground = PixColors[Color_trough];
+      if (sbshadow)
+        {
+          XSetWindowBackground(Xdisplay, scrollBar.win,
+                               gcvalue.foreground);
+          XClearWindow(Xdisplay, scrollBar.win);
+        }
+    }
+  else
+    {
+      /* instead of XClearWindow (Xdisplay, scrollBar.win); */
+      if (last_top < scrollBar.top)
+        XClearArea(Xdisplay, scrollBar.win,
+                   sbshadow, last_top,
+                   sbwidth, (scrollBar.top - last_top),
+                   False);
+
+      if (scrollBar.bot < last_bot)
+        XClearArea(Xdisplay, scrollBar.win,
+                   sbshadow, scrollBar.bot,
+                   sbwidth, (last_bot - scrollBar.bot),
+                   False);
     }
 
-/* scrollbar slider */
+  /* scrollbar slider */
 #ifdef SB_BORDER
-    {
-       int             xofs;
+  {
+    int             xofs;
 
-       if (Options & Opt_scrollBar_right)
-           xofs = 0;
-       else
-           xofs = sbshadow ? sbwidth : sbwidth - 1;
+    if (Options & Opt_scrollBar_right)
+      xofs = 0;
+    else
+      xofs = sbshadow ? sbwidth : sbwidth - 1;
 
-       XDrawLine(Xdisplay, scrollBar.win, botShadowGC,
-                 xofs, 0, xofs, scrollBar.end + sbwidth);
-    }
+    XDrawLine(Xdisplay, scrollBar.win, botShadowGC,
+              xofs, 0, xofs, scrollBar.end + sbwidth);
+  }
 #endif
-    XFillRectangle(Xdisplay, scrollBar.win, scrollbarGC,
-                  sbshadow, scrollBar.top, sbwidth,
-                  scrollbar_len);
-
-    if (sbshadow)
-       /* trough shadow */
-       rxvt_Draw_Shadow(Xdisplay, scrollBar.win,
-                        botShadowGC, topShadowGC,
-                        0, 0,
-                        sbwidth + 2 * sbshadow, /* scrollbar_TotalWidth() */
-                        scrollBar.end + (sbwidth + 1) + sbshadow);
-/* shadow for scrollbar slider */
+  XFillRectangle(Xdisplay, scrollBar.win, scrollbarGC,
+                 sbshadow, scrollBar.top, sbwidth,
+                 scrollbar_len);
+
+  if (sbshadow)
+    /* trough shadow */
     rxvt_Draw_Shadow(Xdisplay, scrollBar.win,
-                    topShadowGC, botShadowGC,
-                    sbshadow, scrollBar.top, sbwidth,
-                    scrollbar_len);
-
-/*
- * Redraw scrollbar arrows
- */
-    Draw_button (sbshadow, sbshadow,
-                    (scrollbar_isUp() ? -1 : +1), UP);
-    Draw_button (sbshadow, (scrollBar.end + 1),
-                    (scrollbar_isDn() ? -1 : +1), DN);
-    return 1;
+                     botShadowGC, topShadowGC,
+                     0, 0,
+                     sbwidth + 2 * sbshadow, /* scrollbar_TotalWidth() */
+                     scrollBar.end + (sbwidth + 1) + sbshadow);
+  /* shadow for scrollbar slider */
+  rxvt_Draw_Shadow(Xdisplay, scrollBar.win,
+                   topShadowGC, botShadowGC,
+                   sbshadow, scrollBar.top, sbwidth,
+                   scrollbar_len);
+
+  /*
+   * Redraw scrollbar arrows
+   */
+  Draw_button (sbshadow, sbshadow,
+               (scrollbar_isUp() ? -1 : +1), UP);
+  Draw_button (sbshadow, (scrollBar.end + 1),
+               (scrollbar_isDn() ? -1 : +1), DN);
+  return 1;
 }
 #endif                         /* RXVT_SCROLLBAR */
 /*----------------------- end-of-file (C source) -----------------------*/
index 90d08a9..c85c0d6 100644 (file)
@@ -34,50 +34,52 @@ const unsigned char x_stp_bits[] = { 0xaa, 0x55 };
 int
 rxvt_term::scrollbar_show_xterm (int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len)
 {
-    int             xsb = 0;
-    int             sbwidth = scrollBar.width - 1;
+  int             xsb = 0;
+  int             sbwidth = scrollBar.width - 1;
 
-    if ((scrollBar.init & R_SB_XTERM) == 0) {
-       XGCValues       gcvalue;
+  if ((scrollBar.init & R_SB_XTERM) == 0)
+    {
+      XGCValues       gcvalue;
 
-       scrollBar.init |= R_SB_XTERM;
-       gcvalue.stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win,
-                                               (char *)x_stp_bits, x_stp_width,
-                                               x_stp_height);
-       if (!gcvalue.stipple) {
-           rxvt_print_error("can't create bitmap");
-           exit(EXIT_FAILURE);
-       }
-       gcvalue.fill_style = FillOpaqueStippled;
-       gcvalue.foreground = PixColors[Color_fg];
-       gcvalue.background = PixColors[Color_bg];
+      scrollBar.init |= R_SB_XTERM;
+      gcvalue.stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win,
+                                              (char *)x_stp_bits, x_stp_width,
+                                              x_stp_height);
+      if (!gcvalue.stipple)
+        {
+          rxvt_print_error("can't create bitmap");
+          exit(EXIT_FAILURE);
+        }
+      gcvalue.fill_style = FillOpaqueStippled;
+      gcvalue.foreground = PixColors[Color_fg];
+      gcvalue.background = PixColors[Color_bg];
 
-       xscrollbarGC = XCreateGC(Xdisplay, scrollBar.win,
-                                GCForeground | GCBackground
-                                | GCFillStyle | GCStipple, &gcvalue);
-       gcvalue.foreground = PixColors[Color_border];
-       ShadowGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground, &gcvalue);
+      xscrollbarGC = XCreateGC(Xdisplay, scrollBar.win,
+                               GCForeground | GCBackground
+                               | GCFillStyle | GCStipple, &gcvalue);
+      gcvalue.foreground = PixColors[Color_border];
+      ShadowGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground, &gcvalue);
     }
-/* instead of XClearWindow (Xdisplay, scrollBar.win); */
-    xsb = (Options & Opt_scrollBar_right) ? 1 : 0;
-    if (last_top < scrollBar.top)
-       XClearArea(Xdisplay, scrollBar.win,
-                  sb_shadow + xsb, last_top,
-                  sbwidth, (scrollBar.top - last_top), False);
+  /* instead of XClearWindow (Xdisplay, scrollBar.win); */
+  xsb = (Options & Opt_scrollBar_right) ? 1 : 0;
+  if (last_top < scrollBar.top)
+    XClearArea(Xdisplay, scrollBar.win,
+               sb_shadow + xsb, last_top,
+               sbwidth, (scrollBar.top - last_top), False);
 
-    if (scrollBar.bot < last_bot)
-       XClearArea(Xdisplay, scrollBar.win,
-                  sb_shadow + xsb, scrollBar.bot,
-                  sbwidth, (last_bot - scrollBar.bot), False);
+  if (scrollBar.bot < last_bot)
+    XClearArea(Xdisplay, scrollBar.win,
+               sb_shadow + xsb, scrollBar.bot,
+               sbwidth, (last_bot - scrollBar.bot), False);
 
-/* scrollbar slider */
-    XFillRectangle(Xdisplay, scrollBar.win, xscrollbarGC,
-                  xsb + 1, scrollBar.top, sbwidth - 2, scrollbar_len);
+  /* scrollbar slider */
+  XFillRectangle(Xdisplay, scrollBar.win, xscrollbarGC,
+                 xsb + 1, scrollBar.top, sbwidth - 2, scrollbar_len);
 
-    XDrawLine(Xdisplay, scrollBar.win, ShadowGC,
-             xsb ? 0 : sbwidth, scrollBar.beg,
-             xsb ? 0 : sbwidth, scrollBar.end);
-    return 1;
+  XDrawLine(Xdisplay, scrollBar.win, ShadowGC,
+            xsb ? 0 : sbwidth, scrollBar.beg,
+            xsb ? 0 : sbwidth, scrollBar.end);
+  return 1;
 }
 #endif                         /* XTERM_SCROLLBAR */
 /*----------------------- end-of-file (C source) -----------------------*/
index e093a31..e8f6b19 100644 (file)
 int
 rxvt_term::scrollbar_mapping (int map)
 {
-    int             change = 0;
+  int             change = 0;
 
 #ifdef HAVE_SCROLLBARS
-    if (map && !scrollbar_visible()) {
-       scrollBar.setIdle ();
-       if (!scrollBar.win)
-           resize_scrollbar ();
-       if (scrollBar.win) {
-           XMapWindow(Xdisplay, scrollBar.win);
-           change = 1;
-       }
-    } else if (!map && scrollbar_visible()) {
-       scrollBar.state = 0;
-       XUnmapWindow(Xdisplay, scrollBar.win);
-       change = 1;
+  if (map && !scrollbar_visible())
+    {
+      scrollBar.setIdle ();
+      if (!scrollBar.win)
+        resize_scrollbar ();
+      if (scrollBar.win)
+        {
+          XMapWindow(Xdisplay, scrollBar.win);
+          change = 1;
+        }
+    }
+  else if (!map && scrollbar_visible())
+    {
+      scrollBar.state = 0;
+      XUnmapWindow(Xdisplay, scrollBar.win);
+      change = 1;
     }
 #endif
-    return change;
+  return change;
 }
 
 void
 rxvt_term::resize_scrollbar ()
 {
 #ifdef HAVE_SCROLLBARS
-    int delayed_init = 0;
+  int delayed_init = 0;
 
 #define R_SCROLLBEG_XTERM      0
 #define R_SCROLLEND_XTERM      szHint.height
@@ -70,57 +74,62 @@ rxvt_term::resize_scrollbar ()
                                    (2 * sb_shadow)
 
 #if defined(PLAIN_SCROLLBAR)
-    if (scrollBar.style == R_SB_PLAIN) {
-       scrollBar.beg = R_SCROLLBEG_XTERM;
-       scrollBar.end = R_SCROLLEND_XTERM;
-       scrollBar.update = &rxvt_term::scrollbar_show_plain;
+  if (scrollBar.style == R_SB_PLAIN)
+    {
+      scrollBar.beg = R_SCROLLBEG_XTERM;
+      scrollBar.end = R_SCROLLEND_XTERM;
+      scrollBar.update = &rxvt_term::scrollbar_show_plain;
     }
 #endif
 #if defined(XTERM_SCROLLBAR)
-    if (scrollBar.style == R_SB_XTERM) {
-       scrollBar.beg = R_SCROLLBEG_XTERM;
-       scrollBar.end = R_SCROLLEND_XTERM;
-       scrollBar.update = &rxvt_term::scrollbar_show_xterm;
+  if (scrollBar.style == R_SB_XTERM)
+    {
+      scrollBar.beg = R_SCROLLBEG_XTERM;
+      scrollBar.end = R_SCROLLEND_XTERM;
+      scrollBar.update = &rxvt_term::scrollbar_show_xterm;
     }
 #endif
 #if defined(NEXT_SCROLLBAR)
-    if (scrollBar.style == R_SB_NEXT) {
-       scrollBar.beg = R_SCROLLBEG_NEXT;
-       scrollBar.end = R_SCROLLEND_NEXT;
-       scrollBar.update = &rxvt_term::scrollbar_show_next;
+  if (scrollBar.style == R_SB_NEXT)
+    {
+      scrollBar.beg = R_SCROLLBEG_NEXT;
+      scrollBar.end = R_SCROLLEND_NEXT;
+      scrollBar.update = &rxvt_term::scrollbar_show_next;
     }
 #endif
 #if defined(RXVT_SCROLLBAR)
-    if (scrollBar.style == R_SB_RXVT) {
-       scrollBar.beg = R_SCROLLBEG_RXVT;
-       scrollBar.end = R_SCROLLEND_RXVT;
-       scrollBar.update = &rxvt_term::scrollbar_show_rxvt;
+  if (scrollBar.style == R_SB_RXVT)
+    {
+      scrollBar.beg = R_SCROLLBEG_RXVT;
+      scrollBar.end = R_SCROLLEND_RXVT;
+      scrollBar.update = &rxvt_term::scrollbar_show_rxvt;
     }
 #endif
 
-    if (!scrollBar.win) {
-/* create the scrollbar window */
-       scrollBar.win = XCreateSimpleWindow(Xdisplay,
-                                              TermWin.parent[0],
-                                              window_sb_x, 0,
-                                              scrollbar_TotalWidth(),
-                                              szHint.height,
-                                              0,
-                                              PixColors[Color_fg],
-                                              PixColors[Color_bg]);
+  if (!scrollBar.win)
+    {
+      /* create the scrollbar window */
+      scrollBar.win = XCreateSimpleWindow(Xdisplay,
+                                          TermWin.parent[0],
+                                          window_sb_x, 0,
+                                          scrollbar_TotalWidth(),
+                                          szHint.height,
+                                          0,
+                                          PixColors[Color_fg],
+                                          PixColors[Color_bg]);
 #ifdef DEBUG_X
-       XStoreName(Xdisplay, scrollBar.win, "scrollbar");
+      XStoreName(Xdisplay, scrollBar.win, "scrollbar");
 #endif
-       XDefineCursor(Xdisplay, scrollBar.win, leftptr_cursor);
-       XSelectInput(Xdisplay, scrollBar.win,
-                    (ExposureMask | ButtonPressMask | ButtonReleaseMask
-                     | Button1MotionMask | Button2MotionMask
-                     | Button3MotionMask));
-       delayed_init = 1;
+      XDefineCursor(Xdisplay, scrollBar.win, leftptr_cursor);
+      XSelectInput(Xdisplay, scrollBar.win,
+                   (ExposureMask | ButtonPressMask | ButtonReleaseMask
+                    | Button1MotionMask | Button2MotionMask
+                    | Button3MotionMask));
+      delayed_init = 1;
     }
-    scrollbar_show (1);
-    if (delayed_init)
-       XMapWindow (Xdisplay, scrollBar.win);
+  scrollbar_show (1);
+  if (delayed_init)
+    XMapWindow (Xdisplay, scrollBar.win);
 #endif
 }
 
@@ -130,102 +139,106 @@ rxvt_term::resize_scrollbar ()
 int
 rxvt_term::scrollbar_show (int update)
 {
-    int             ret = 0;
+  int             ret = 0;
 #ifdef HAVE_SCROLLBARS
-    int             top, bot, len, adj;
-
-    if (!scrollbar_visible())
-       return 0;
-
-    if (update) {
-       top = (TermWin.nscrolled - TermWin.view_start);
-       bot = top + (TermWin.nrow - 1);
-       len = max((TermWin.nscrolled + (TermWin.nrow - 1)), 1);
-       adj = (((bot - top) * scrollbar_size()) % len) > 0 ? 1 : 0;
-
-       scrollBar.top = (scrollBar.beg + (top * scrollbar_size()) / len);
-       scrollbar_len = ((bot - top) * scrollbar_size()) / len +
-                             scrollbar_minheight() + adj;
-       scrollBar.bot = (scrollBar.top + scrollbar_len);
-       /* no change */
-       if (scrollBar.top == last_top
-           && scrollBar.bot == last_bot
-           && (scrollBar.state == last_state || !scrollbar_isUpDn()))
-           return 0;
+  int             top, bot, len, adj;
+
+  if (!scrollbar_visible())
+    return 0;
+
+  if (update)
+    {
+      top = (TermWin.nscrolled - TermWin.view_start);
+      bot = top + (TermWin.nrow - 1);
+      len = max((TermWin.nscrolled + (TermWin.nrow - 1)), 1);
+      adj = (((bot - top) * scrollbar_size()) % len) > 0 ? 1 : 0;
+
+      scrollBar.top = (scrollBar.beg + (top * scrollbar_size()) / len);
+      scrollbar_len = ((bot - top) * scrollbar_size()) / len +
+                      scrollbar_minheight() + adj;
+      scrollBar.bot = (scrollBar.top + scrollbar_len);
+      /* no change */
+      if (scrollBar.top == last_top
+          && scrollBar.bot == last_bot
+          && (scrollBar.state == last_state || !scrollbar_isUpDn()))
+        return 0;
     }
 
-    ret = (this->*scrollBar.update) (update, last_top, last_bot, scrollbar_len);
+  ret = (this->*scrollBar.update) (update, last_top, last_bot, scrollbar_len);
 
-    last_top = scrollBar.top;
-    last_bot = scrollBar.bot;
-    last_state = scrollBar.state;
+  last_top = scrollBar.top;
+  last_bot = scrollBar.bot;
+  last_state = scrollBar.state;
 #endif
 
-    return ret;
+  return ret;
 }
 
 void
 rxvt_term::setup_scrollbar (const char *scrollalign, const char *scrollstyle, const char *thickness)
 {
 #ifdef HAVE_SCROLLBARS
-    int             i;
-    short           style, width;
+  int             i;
+  short           style, width;
 
 # if defined(RXVT_SCROLLBAR)
-    style = R_SB_RXVT;
+  style = R_SB_RXVT;
 # elif defined(XTERM_SCROLLBAR)
-    style = R_SB_XTERM;
+  style = R_SB_XTERM;
 # elif defined(NEXT_SCROLLBAR)
-    style = R_SB_NEXT;
+  style = R_SB_NEXT;
 # elif defined(PLAIN_SCROLLBAR)
-    style = R_SB_PLAIN;
+  style = R_SB_PLAIN;
 #else
-    style = R_SB_RXVT;
+  style = R_SB_RXVT;
 # endif
 
 # if (defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR))
-    if (scrollstyle) {
+  if (scrollstyle)
+    {
 #  ifdef NEXT_SCROLLBAR
-       if (STRNCASECMP(scrollstyle, "next", 4) == 0)
-           style = R_SB_NEXT;
+      if (STRNCASECMP(scrollstyle, "next", 4) == 0)
+        style = R_SB_NEXT;
 #  endif
 #  ifdef XTERM_SCROLLBAR
-       if (STRNCASECMP(scrollstyle, "xterm", 5) == 0)
-           style = R_SB_XTERM;
+      if (STRNCASECMP(scrollstyle, "xterm", 5) == 0)
+        style = R_SB_XTERM;
 #  endif
 #  ifdef PLAIN_SCROLLBAR
-       if (STRNCASECMP(scrollstyle, "plain", 5) == 0)
-           style = R_SB_PLAIN;
+      if (STRNCASECMP(scrollstyle, "plain", 5) == 0)
+        style = R_SB_PLAIN;
 #  endif
+
     }
 # endif
-    if (style == R_SB_NEXT)
-       width = SB_WIDTH_NEXT;
-    else if (style == R_SB_XTERM)
-       width = SB_WIDTH_XTERM;
-    else if (style == R_SB_PLAIN)
-       width = SB_WIDTH_PLAIN;
-    else /* if (style == R_SB_RXVT) */
-       width = SB_WIDTH_RXVT;
-
-    if (style != R_SB_NEXT)    /* dishonour request - for now */
+  if (style == R_SB_NEXT)
+    width = SB_WIDTH_NEXT;
+  else if (style == R_SB_XTERM)
+    width = SB_WIDTH_XTERM;
+  else if (style == R_SB_PLAIN)
+    width = SB_WIDTH_PLAIN;
+  else /* if (style == R_SB_RXVT) */
+    width = SB_WIDTH_RXVT;
+
+  if (style != R_SB_NEXT)      /* dishonour request - for now */
     if (thickness && (i = atoi(thickness)) >= SB_WIDTH_MINIMUM)
-       width = min(i, SB_WIDTH_MAXIMUM);
+      width = min(i, SB_WIDTH_MAXIMUM);
 
 # if defined(RXVT_SCROLLBAR)
-    if (!(Options & Opt_scrollBar_floating) && style == R_SB_RXVT)
-       sb_shadow = SHADOW;
+  if (!(Options & Opt_scrollBar_floating) && style == R_SB_RXVT)
+    sb_shadow = SHADOW;
 # endif
 
-    scrollBar.style = style;
-    scrollBar.width = width;
+  scrollBar.style = style;
+  scrollBar.width = width;
 
-    /* scrollbar_align = R_SB_ALIGN_CENTRE; */
-    if (scrollalign) {
-       if (STRNCASECMP(scrollalign, "top", 3) == 0)
-           scrollbar_align = R_SB_ALIGN_TOP;
-       else if (STRNCASECMP(scrollalign, "bottom", 6) == 0)
-           scrollbar_align = R_SB_ALIGN_BOTTOM;
+  /* scrollbar_align = R_SB_ALIGN_CENTRE; */
+  if (scrollalign)
+    {
+      if (STRNCASECMP(scrollalign, "top", 3) == 0)
+        scrollbar_align = R_SB_ALIGN_TOP;
+      else if (STRNCASECMP(scrollalign, "bottom", 6) == 0)
+        scrollbar_align = R_SB_ALIGN_BOTTOM;
     }
 #endif
 }
index c30426e..400fd3a 100644 (file)
@@ -1,7 +1,7 @@
 /*--------------------------------*-C-*---------------------------------*
  * File:       strings.c
  *----------------------------------------------------------------------*
- * $Id: strings.C,v 1.3 2004-01-31 00:20:21 pcg Exp $
+ * $Id: strings.C,v 1.4 2004-02-01 01:34:41 pcg Exp $
  *
  * All portions of code are copyright by their respective author/s.
  * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com>
 int
 strcasecmp(const char *s1, const char *s2)
 {
-    for ( ; tolower(*s1) == tolower(*s2); s1++, s2++)
-       if (!*s1)
-           return 0;
-    return (int)(tolower(*s1) - tolower(*s2));
+  for ( ; tolower(*s1) == tolower(*s2); s1++, s2++)
+    if (!*s1)
+      return 0;
+  return (int)(tolower(*s1) - tolower(*s2));
 }
 
 int
 strncasecmp(const char *s1, const char *s2, size_t n)
 {
-    for ( ; n-- && (tolower(*s1) == tolower(*s2)); s1++, s2++)
-       if (!*s1)
-           return 0;
-    if (n == 0)
-       return 0;
-    return (int)(tolower(*s1) - tolower(*s2));
+  for ( ; n-- && (tolower(*s1) == tolower(*s2)); s1++, s2++)
+    if (!*s1)
+      return 0;
+  if (n == 0)
+    return 0;
+  return (int)(tolower(*s1) - tolower(*s2));
 }
 
 char           *
 strcpy(char *d, const char *s)
 {
-    char          *r = d;
+  char          *r = d;
 
-    for ( ; (*r++ = *s++) != '\0'; ) ;
-    return d;
+  for ( ; (*r++ = *s++) != '\0'; ) ;
+  return d;
 }
 
 char           *
 strncpy(char *d, const char *s, size_t len)
 {
-    char          *r = d;
-
-    if (len)
-       for ( ; len; len--)
-           if ((*r++ = *s++) == '\0') {
-               for ( ; --len; )
-                   *r++ = '\0';
-               break;
-           }
-    return d;
+  char          *r = d;
+
+  if (len)
+    for ( ; len; len--)
+      if ((*r++ = *s++) == '\0')
+        {
+          for ( ; --len; )
+            *r++ = '\0';
+          break;
+        }
+  return d;
 }
 
 int
 strcmp(const char *s1, const char *s2)
 {
-    for ( ; (*s1 == *s2++); )
-       if (*s1++ == '\0')
-           return 0;
-    return (int) ((unsigned char) *s1 - (unsigned char) *--s2);
+  for ( ; (*s1 == *s2++); )
+    if (*s1++ == '\0')
+      return 0;
+  return (int) ((unsigned char) *s1 - (unsigned char) *--s2);
 }
 
 int
 strncmp(const char *s1, const char *s2, size_t len)
 {
-    if (len) {
-       for ( ; len-- && (*s1++ == *s2++); ) ;
-       if (++len)
-           return (int) ((unsigned char) *--s1 - (unsigned char) *--s2);
+  if (len)
+    {
+      for ( ; len-- && (*s1++ == *s2++); ) ;
+      if (++len)
+        return (int) ((unsigned char) *--s1 - (unsigned char) *--s2);
     }
-    return 0;
+  return 0;
 }
 
 char           *
 strcat(char *s1, const char *s2)
 {
-    char           *r = s1;
+  char           *r = s1;
 
-    if (*r != '\0')
-       for ( ; *++r != '\0'; ) ;
-    for ( ; (*r++ = *s2++) != '\0'; ) ;
+  if (*r != '\0')
+    for ( ; *++r != '\0'; ) ;
+  for ( ; (*r++ = *s2++) != '\0'; ) ;
 
-    return s1;
+  return s1;
 }
 
 char           *
 strncat(char *s1, const char *s2, size_t len)
 {
-    char           *r = s1;
+  char           *r = s1;
 
-    if (*r != '\0')
-       for ( ; *++r != '\0'; ) ;
-    for ( ; len-- && ((*r++ = *s2++) != '\0'); ) ;
-    *r = '\0';
+  if (*r != '\0')
+    for ( ; *++r != '\0'; ) ;
+  for ( ; len-- && ((*r++ = *s2++) != '\0'); ) ;
+  *r = '\0';
 
-    return s1;
+  return s1;
 }
 
 size_t
 strlen(const char *s)
 {
-    size_t         len = 0;
+  size_t         len = 0;
 
-    for ( ; *s++ != '\0'; len++) ;
-    return len;
+  for ( ; *s++ != '\0'; len++) ;
+  return len;
 }
 
 char           *
 strdup(const char *s)
 {
-    size_t         len = STRLEN(s) + 1;
-    char          *c;
+  size_t         len = STRLEN(s) + 1;
+  char          *c;
 
-    if ((c = malloc(len)) != NULL)
-       MEMCPY(c, s, len);
-    return c;
+  if ((c = malloc(len)) != NULL)
+    MEMCPY(c, s, len);
+  return c;
 }
 
 char           *
 index(const char *s, int c)
 {
-    return STRCHR(s, c);
+  return STRCHR(s, c);
 }
 
 char           *
 strchr(const char *s, int c)
 {
-    char          *p = NULL;
-
-    for (;;) {
-       if (*s == (char)c) {
-           p = (char *)s;
-           break;
-       }
-       if (*s++ == '\0')
-           break;
+  char          *p = NULL;
+
+  for (;;)
+    {
+      if (*s == (char)c)
+        {
+          p = (char *)s;
+          break;
+        }
+      if (*s++ == '\0')
+        break;
     }
-    return p;
+  return p;
 
 }
 
 char           *
 rindex(const char *s, int c)
 {
-    return STRRCHR(s, c);
+  return STRRCHR(s, c);
 }
 
 char           *
 strrchr(const char *s, int c)
 {
-    char          *p = NULL;
-
-    for (;;) {
-       if (*s == (char)c)
-           p = (char *)s;
-       if (*s++ == '\0')
-           break;
+  char          *p = NULL;
+
+  for (;;)
+    {
+      if (*s == (char)c)
+        p = (char *)s;
+      if (*s++ == '\0')
+        break;
     }
-    return p;
+  return p;
 }
 
 void           *
 memcpy(void *s1, const void *s2, size_t len)
 {
-    /* has extra stack and time but less code space */
-    return MEMMOVE(s1, s2, len);
+  /* has extra stack and time but less code space */
+  return MEMMOVE(s1, s2, len);
 }
 
 /*--------------------------------------------------------------------------*
@@ -196,44 +201,50 @@ memcpy(void *s1, const void *s2, size_t len)
 void           *
 memmove(void *d, const void *s, size_t len)
 {
-    u_intp_t        i;
-    unsigned char  *dst = (unsigned char *)d;
-    const unsigned char *src = (const unsigned char *)s;
-
-    if (len && d != s) {
-       if ((u_intp_t)d < (u_intp_t)s) {
-       /* forwards */
-           i = (-(u_intp_t)dst) & (SIZEOF_INT_P - 1);
-           if (len >= 16 && i == ((-(u_intp_t)src) & (SIZEOF_INT_P - 1))) {
-           /* speed up since src & dst are offset correctly */
-               len -= (size_t)i;
-               for ( ; i--; )
-                   *dst++ = *src++;
-               for (i = (u_intp_t)(len / SIZEOF_INT_P); i--; )
-                   *((u_intp_t *)dst)++ = *((const u_intp_t *)src)++;
-               len &= (SIZEOF_INT_P - 1);
-           }
-           for ( ; len--; )
-               *dst++ = *src++;
-       } else {
-       /* backwards */
-           dst += len;
-           src += len;
-           i = ((u_intp_t)dst) & (SIZEOF_INT_P - 1);
-           if (len >= 16 && i == (((u_intp_t)src) & (SIZEOF_INT_P - 1))) {
-           /* speed up since src & dst are offset correctly */
-               len -= (size_t)i;
-               for ( ; i--; )
-                   *--dst = *--src;
-               for (i = (u_intp_t)(len / SIZEOF_INT_P); i--; )
-                   *--((u_intp_t *)dst) = *--((const u_intp_t *)src);
-               len &= (SIZEOF_INT_P - 1);
-           }
-           for ( ; len--; )
-               *--dst = *--src;
-       }
+  u_intp_t        i;
+  unsigned char  *dst = (unsigned char *)d;
+  const unsigned char *src = (const unsigned char *)s;
+
+  if (len && d != s)
+    {
+      if ((u_intp_t)d < (u_intp_t)s)
+        {
+          /* forwards */
+          i = (-(u_intp_t)dst) & (SIZEOF_INT_P - 1);
+          if (len >= 16 && i == ((-(u_intp_t)src) & (SIZEOF_INT_P - 1)))
+            {
+              /* speed up since src & dst are offset correctly */
+              len -= (size_t)i;
+              for ( ; i--; )
+                *dst++ = *src++;
+              for (i = (u_intp_t)(len / SIZEOF_INT_P); i--; )
+                *((u_intp_t *)dst)++ = *((const u_intp_t *)src)++;
+              len &= (SIZEOF_INT_P - 1);
+            }
+          for ( ; len--; )
+            *dst++ = *src++;
+        }
+      else
+        {
+          /* backwards */
+          dst += len;
+          src += len;
+          i = ((u_intp_t)dst) & (SIZEOF_INT_P - 1);
+          if (len >= 16 && i == (((u_intp_t)src) & (SIZEOF_INT_P - 1)))
+            {
+              /* speed up since src & dst are offset correctly */
+              len -= (size_t)i;
+              for ( ; i--; )
+                *--dst = *--src;
+              for (i = (u_intp_t)(len / SIZEOF_INT_P); i--; )
+                *--((u_intp_t *)dst) = *--((const u_intp_t *)src);
+              len &= (SIZEOF_INT_P - 1);
+            }
+          for ( ; len--; )
+            *--dst = *--src;
+        }
     }
-    return d;
+  return d;
 }
 
 /*--------------------------------------------------------------------------*
@@ -246,45 +257,48 @@ memmove(void *d, const void *s, size_t len)
 void
 bzero(void *b, size_t len)
 {
-    MEMSET(b, 0, len);
+  MEMSET(b, 0, len);
 }
 
 void           *
 memset(void *p, int c1, size_t len)
 {
-    u_intp_t        i, val;
-    unsigned char   c = (unsigned char) c1;
-    unsigned char  *lp = (unsigned char *) p;
-
-    if (len) {
-       if (len >= 16) { /* < 16 probably not worth all the calculations */
-/* write out preceding characters so we align on an integer boundary */
-           if ((i = ((-(u_intp_t)p) & (SIZEOF_INT_P - 1)))) {
-               len -= (size_t)i;
-               for (; i--;)
-                   *lp++ = c;
-           }
-
-/* do the fast writing */
-           val = (c << 8) + c;
+  u_intp_t        i, val;
+  unsigned char   c = (unsigned char) c1;
+  unsigned char  *lp = (unsigned char *) p;
+
+  if (len)
+    {
+      if (len >= 16)
+        { /* < 16 probably not worth all the calculations */
+          /* write out preceding characters so we align on an integer boundary */
+          if ((i = ((-(u_intp_t)p) & (SIZEOF_INT_P - 1))))
+            {
+              len -= (size_t)i;
+              for (; i--;)
+                *lp++ = c;
+            }
+
+          /* do the fast writing */
+          val = (c << 8) + c;
 #if SIZEOF_INT_P >= 4
-           val |= (val << 16);
+          val |= (val << 16);
 #endif
 #if SIZEOF_INT_P >= 8
-           val |= (val << 32);
+          val |= (val << 32);
 #endif
 #if SIZEOF_INT_P == 16
-           val |= (val << 64);
+          val |= (val << 64);
 #endif
-           for (i = (u_intp_t)(len / SIZEOF_INT_P); i--;)
-               *((u_intp_t *)lp)++ = val;
-           len &= (SIZEOF_INT_P - 1);
-       }
-/* write trailing characters */
-       for (; len--;)
-           *lp++ = c;
+          for (i = (u_intp_t)(len / SIZEOF_INT_P); i--;)
+            *((u_intp_t *)lp)++ = val;
+          len &= (SIZEOF_INT_P - 1);
+        }
+      /* write trailing characters */
+      for (; len--;)
+        *lp++ = c;
     }
-    return p;
+  return p;
 }
 #endif
 /*----------------------- end-of-file (C source) -----------------------*/
index 62e88e2..053f420 100644 (file)
@@ -1,7 +1,7 @@
 /*--------------------------------*-C-*---------------------------------*
  * File:       xdefaults.c
  *----------------------------------------------------------------------*
- * $Id: xdefaults.C,v 1.8 2004-01-31 00:20:21 pcg Exp $
+ * $Id: xdefaults.C,v 1.9 2004-02-01 01:34:41 pcg Exp $
  *
  * All portions of code are copyright by their respective author/s.
  * Copyright (c) 1994      Robert Nation <nation@rocket.sanders.lockheed.com>
@@ -73,198 +73,200 @@ static const char *const xnames[2] = { ".Xdefaults", ".Xresources" };
 #define optList_size()                                                 \
     (sizeof(optList) / sizeof(optList[0]))
 
-static const struct {
+static const struct
+  {
     const unsigned long flag;  /* Option flag */
     const int       doff;      /* data offset */
     const char     *kw;                /* keyword */
     const char     *opt;       /* option */
     const char     *arg;       /* argument */
     const char     *desc;      /* description */
-} optList[] = {
-    STRG(Rs_display_name, NULL, "d", NULL, NULL),      /* short form */
-    STRG(Rs_display_name, NULL, "display", "string", "X server to contact"),
-    STRG(Rs_term_name, "termName", "tn", "string",
-        "value of the TERM environment variable"),
-    STRG(Rs_geometry, NULL, "g", NULL, NULL),  /* short form */
-    STRG(Rs_geometry, "geometry", "geometry", "geometry",
-        "size (in characters) and position"),
-    SWCH("C", Opt_console, "intercept console messages"),
-    SWCH("iconic", Opt_iconic, "start iconic"),
-    SWCH("ic", Opt_iconic, NULL),      /* short form */
-    BOOL(Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo,
-        "reverse video"),
-    BOOL(Rs_loginShell, "loginShell", "ls", Opt_loginShell, "login shell"),
-    BOOL(Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, "jump scrolling"),
+  }
+optList[] = {
+              STRG(Rs_display_name, NULL, "d", NULL, NULL),    /* short form */
+              STRG(Rs_display_name, NULL, "display", "string", "X server to contact"),
+              STRG(Rs_term_name, "termName", "tn", "string",
+                   "value of the TERM environment variable"),
+              STRG(Rs_geometry, NULL, "g", NULL, NULL),        /* short form */
+              STRG(Rs_geometry, "geometry", "geometry", "geometry",
+                   "size (in characters) and position"),
+              SWCH("C", Opt_console, "intercept console messages"),
+              SWCH("iconic", Opt_iconic, "start iconic"),
+              SWCH("ic", Opt_iconic, NULL),    /* short form */
+              BOOL(Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo,
+                   "reverse video"),
+              BOOL(Rs_loginShell, "loginShell", "ls", Opt_loginShell, "login shell"),
+              BOOL(Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, "jump scrolling"),
 #ifdef HAVE_SCROLLBARS
-    BOOL(Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, "scrollbar"),
-    BOOL(Rs_scrollBar_right, "scrollBar_right", "sr", Opt_scrollBar_right,
-        "scrollbar right"),
-    BOOL(Rs_scrollBar_floating, "scrollBar_floating", "st",
-        Opt_scrollBar_floating, "scrollbar without a trough"),
-#endif
-    BOOL(Rs_scrollTtyOutput, "scrollTtyOutput", NULL, Opt_scrollTtyOutput,
-        NULL),
-    BOOL(Rs_scrollTtyOutput, NULL, "si", Opt_Reverse | Opt_scrollTtyOutput,
-        "scroll-on-tty-output inhibit"),
-    BOOL(Rs_scrollTtyKeypress, "scrollTtyKeypress", "sk", Opt_scrollTtyKeypress,
-        "scroll-on-keypress"),
-    BOOL(Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer,
-        "scroll-with-buffer"),
+              BOOL(Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, "scrollbar"),
+              BOOL(Rs_scrollBar_right, "scrollBar_right", "sr", Opt_scrollBar_right,
+                   "scrollbar right"),
+              BOOL(Rs_scrollBar_floating, "scrollBar_floating", "st",
+                   Opt_scrollBar_floating, "scrollbar without a trough"),
+#endif
+              BOOL(Rs_scrollTtyOutput, "scrollTtyOutput", NULL, Opt_scrollTtyOutput,
+                   NULL),
+              BOOL(Rs_scrollTtyOutput, NULL, "si", Opt_Reverse | Opt_scrollTtyOutput,
+                   "scroll-on-tty-output inhibit"),
+              BOOL(Rs_scrollTtyKeypress, "scrollTtyKeypress", "sk", Opt_scrollTtyKeypress,
+                   "scroll-on-keypress"),
+              BOOL(Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer,
+                   "scroll-with-buffer"),
 #ifdef TRANSPARENT
-    BOOL(Rs_transparent, "inheritPixmap", "ip", Opt_transparent,
-        "inherit parent pixmap"),
-    BOOL(Rs_transparent_all, "inheritPixmapforce", "ipf", Opt_transparent_all,
-        "forcefully inherit root pixmap"),
-    SWCH("tr", Opt_transparent, NULL),
+              BOOL(Rs_transparent, "inheritPixmap", "ip", Opt_transparent,
+                   "inherit parent pixmap"),
+              BOOL(Rs_transparent_all, "inheritPixmapforce", "ipf", Opt_transparent_all,
+                   "forcefully inherit root pixmap"),
+              SWCH("tr", Opt_transparent, NULL),
 #endif
-    BOOL(Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, "utmp inhibit"),
+              BOOL(Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, "utmp inhibit"),
 #ifndef NO_BELL
-    BOOL(Rs_visualBell, "visualBell", "vb", Opt_visualBell, "visual bell"),
+              BOOL(Rs_visualBell, "visualBell", "vb", Opt_visualBell, "visual bell"),
 # if ! defined(NO_MAPALERT) && defined(MAPALERT_OPTION)
-    BOOL(Rs_mapAlert, "mapAlert", NULL, Opt_mapAlert, NULL),
+              BOOL(Rs_mapAlert, "mapAlert", NULL, Opt_mapAlert, NULL),
 # endif
 #endif
 #ifdef META8_OPTION
-    BOOL(Rs_meta8, "meta8", NULL, Opt_meta8, NULL),
+              BOOL(Rs_meta8, "meta8", NULL, Opt_meta8, NULL),
 #endif
 #ifdef MOUSE_WHEEL
-    BOOL(Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage,
-        NULL),
+              BOOL(Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage,
+                   NULL),
 #endif
 #ifdef MULTICHAR_SET
-    BOOL(Rs_mc_hack, "multibyte_cursor", "mcc", Opt_mc_hack,
-        "Multibyte character cursor movement"),
+              BOOL(Rs_mc_hack, "multibyte_cursor", "mcc", Opt_mc_hack,
+                   "Multibyte character cursor movement"),
 #endif
 #ifndef NO_FRILLS
-    BOOL(Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords,
-        "triple click word selection"),
+              BOOL(Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords,
+                   "triple click word selection"),
 #endif
 #ifdef CURSOR_BLINK
-    BOOL(Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"),
+              BOOL(Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"),
 #endif
 #ifdef POINTER_BLANK
-    BOOL(Rs_pointerBlank, "pointerBlank", "pb", Opt_pointerBlank, "switch off pointer after delay"),
-#endif
-    STRG(Rs_color + Color_bg, "background", "bg", "color", "background color"),
-    STRG(Rs_color + Color_fg, "foreground", "fg", "color", "foreground color"),
-    RSTRG(Rs_color + minCOLOR + 0, "color0", "color"),
-    RSTRG(Rs_color + minCOLOR + 1, "color1", "color"),
-    RSTRG(Rs_color + minCOLOR + 2, "color2", "color"),
-    RSTRG(Rs_color + minCOLOR + 3, "color3", "color"),
-    RSTRG(Rs_color + minCOLOR + 4, "color4", "color"),
-    RSTRG(Rs_color + minCOLOR + 5, "color5", "color"),
-    RSTRG(Rs_color + minCOLOR + 6, "color6", "color"),
-    RSTRG(Rs_color + minCOLOR + 7, "color7", "color"),
+              BOOL(Rs_pointerBlank, "pointerBlank", "pb", Opt_pointerBlank, "switch off pointer after delay"),
+#endif
+              STRG(Rs_color + Color_bg, "background", "bg", "color", "background color"),
+              STRG(Rs_color + Color_fg, "foreground", "fg", "color", "foreground color"),
+              RSTRG(Rs_color + minCOLOR + 0, "color0", "color"),
+              RSTRG(Rs_color + minCOLOR + 1, "color1", "color"),
+              RSTRG(Rs_color + minCOLOR + 2, "color2", "color"),
+              RSTRG(Rs_color + minCOLOR + 3, "color3", "color"),
+              RSTRG(Rs_color + minCOLOR + 4, "color4", "color"),
+              RSTRG(Rs_color + minCOLOR + 5, "color5", "color"),
+              RSTRG(Rs_color + minCOLOR + 6, "color6", "color"),
+              RSTRG(Rs_color + minCOLOR + 7, "color7", "color"),
 #ifndef NO_BRIGHTCOLOR
-    RSTRG(Rs_color + minBrightCOLOR + 0, "color8", "color"),
-    RSTRG(Rs_color + minBrightCOLOR + 1, "color9", "color"),
-    RSTRG(Rs_color + minBrightCOLOR + 2, "color10", "color"),
-    RSTRG(Rs_color + minBrightCOLOR + 3, "color11", "color"),
-    RSTRG(Rs_color + minBrightCOLOR + 4, "color12", "color"),
-    RSTRG(Rs_color + minBrightCOLOR + 5, "color13", "color"),
-    RSTRG(Rs_color + minBrightCOLOR + 6, "color14", "color"),
-    RSTRG(Rs_color + minBrightCOLOR + 7, "color15", "color"),
+              RSTRG(Rs_color + minBrightCOLOR + 0, "color8", "color"),
+              RSTRG(Rs_color + minBrightCOLOR + 1, "color9", "color"),
+              RSTRG(Rs_color + minBrightCOLOR + 2, "color10", "color"),
+              RSTRG(Rs_color + minBrightCOLOR + 3, "color11", "color"),
+              RSTRG(Rs_color + minBrightCOLOR + 4, "color12", "color"),
+              RSTRG(Rs_color + minBrightCOLOR + 5, "color13", "color"),
+              RSTRG(Rs_color + minBrightCOLOR + 6, "color14", "color"),
+              RSTRG(Rs_color + minBrightCOLOR + 7, "color15", "color"),
 #endif                         /* NO_BRIGHTCOLOR */
 #ifndef NO_BOLD_UNDERLINE_REVERSE
-    RSTRG(Rs_color + Color_BD, "colorBD", "color"),
-    RSTRG(Rs_color + Color_UL, "colorUL", "color"),
-    RSTRG(Rs_color + Color_RV, "colorRV", "color"),
+              RSTRG(Rs_color + Color_BD, "colorBD", "color"),
+              RSTRG(Rs_color + Color_UL, "colorUL", "color"),
+              RSTRG(Rs_color + Color_RV, "colorRV", "color"),
 #endif                         /* ! NO_BOLD_UNDERLINE_REVERSE */
 #ifdef KEEP_SCROLLCOLOR
-    RSTRG(Rs_color + Color_scroll, "scrollColor", "color"),
-    RSTRG(Rs_color + Color_trough, "troughColor", "color"),
+              RSTRG(Rs_color + Color_scroll, "scrollColor", "color"),
+              RSTRG(Rs_color + Color_trough, "troughColor", "color"),
 #endif                         /* KEEP_SCROLLCOLOR */
 #ifdef OPTION_HC
-    STRG(Rs_color + Color_HC, "highlightColor", "hc", "color", "highlight color"),
+              STRG(Rs_color + Color_HC, "highlightColor", "hc", "color", "highlight color"),
 #endif
 #if defined (XPM_BACKGROUND) || (MENUBAR_MAX)
-    RSTRG(Rs_path, "path", "search path"),
+              RSTRG(Rs_path, "path", "search path"),
 #endif                         /* defined (XPM_BACKGROUND) || (MENUBAR_MAX) */
 #ifdef XPM_BACKGROUND
-    STRG(Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]",
-        "background pixmap"),
+              STRG(Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]",
+                   "background pixmap"),
 #endif                         /* XPM_BACKGROUND */
 #if (MENUBAR_MAX)
-    RSTRG(Rs_menu, "menu", "name[;tag]"),
+              RSTRG(Rs_menu, "menu", "name[;tag]"),
 #endif
-    STRG(Rs_font, "font", "fn", "fontname", "normal text font"),
-/* fonts: command-line option = resource name */
+              STRG(Rs_font, "font", "fn", "fontname", "normal text font"),
+              /* fonts: command-line option = resource name */
 #ifdef USE_XIM
-    STRG(Rs_inputMethod, "inputMethod", "im", "name", "name of input method"),
-    STRG(Rs_preeditType, "preeditType", "pt", "style",
-        "input style: style = OverTheSpot|OffTheSpot|Root"),
+              STRG(Rs_inputMethod, "inputMethod", "im", "name", "name of input method"),
+              STRG(Rs_preeditType, "preeditType", "pt", "style",
+                   "input style: style = OverTheSpot|OffTheSpot|Root"),
 #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
-    STRG(Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"),
+              STRG(Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"),
 #endif
 #endif                         /* USE_XIM */
 #ifdef GREEK_SUPPORT
-    STRG(Rs_greek_keyboard, "greek_keyboard", "grk", "mode",
-        "greek keyboard mapping; mode = iso | ibm"),
-    RSTRG(Rs_greektoggle_key, "greektoggle_key", "keysym"),
-#endif
-    STRG(Rs_name, NULL, "name", "string",
-        "client instance, icon, and title strings"),
-    STRG(Rs_title, "title", "title", "string", "title name for window"),
-    STRG(Rs_title, NULL, "T", NULL, NULL),     /* short form */
-    STRG(Rs_iconName, "iconName", "n", "string", "icon name for window"),
+              STRG(Rs_greek_keyboard, "greek_keyboard", "grk", "mode",
+                   "greek keyboard mapping; mode = iso | ibm"),
+              RSTRG(Rs_greektoggle_key, "greektoggle_key", "keysym"),
+#endif
+              STRG(Rs_name, NULL, "name", "string",
+                   "client instance, icon, and title strings"),
+              STRG(Rs_title, "title", "title", "string", "title name for window"),
+              STRG(Rs_title, NULL, "T", NULL, NULL),   /* short form */
+              STRG(Rs_iconName, "iconName", "n", "string", "icon name for window"),
 #ifndef NO_CURSORCOLOR
-    STRG(Rs_color + Color_cursor, "cursorColor", "cr", "color", "cursor color"),
-/* command-line option = resource name */
-    RSTRG(Rs_color + Color_cursor2, "cursorColor2", "color"),
+              STRG(Rs_color + Color_cursor, "cursorColor", "cr", "color", "cursor color"),
+              /* command-line option = resource name */
+              RSTRG(Rs_color + Color_cursor2, "cursorColor2", "color"),
 #endif                         /* NO_CURSORCOLOR */
-    STRG(Rs_color + Color_pointer, "pointerColor", "pr", "color",
-        "pointer color"),
-    STRG(Rs_color + Color_border, "borderColor", "bd", "color",
-        "border color"),
-    STRG(Rs_saveLines, "saveLines", "sl", "number",
-        "number of scrolled lines to save"),
+              STRG(Rs_color + Color_pointer, "pointerColor", "pr", "color",
+                   "pointer color"),
+              STRG(Rs_color + Color_border, "borderColor", "bd", "color",
+                   "border color"),
+              STRG(Rs_saveLines, "saveLines", "sl", "number",
+                   "number of scrolled lines to save"),
 #ifndef NO_FRILLS
-    STRG(Rs_ext_bwidth, "externalBorder", "w", "number",
-        "external border in pixels"),
-    STRG(Rs_ext_bwidth, NULL, "bw", NULL, NULL),
-    STRG(Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL),
-    STRG(Rs_int_bwidth, "internalBorder", "b", "number",
-        "internal border in pixels"),
+              STRG(Rs_ext_bwidth, "externalBorder", "w", "number",
+                   "external border in pixels"),
+              STRG(Rs_ext_bwidth, NULL, "bw", NULL, NULL),
+              STRG(Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL),
+              STRG(Rs_int_bwidth, "internalBorder", "b", "number",
+                   "internal border in pixels"),
 #endif
 #ifndef NO_LINESPACE
-    STRG(Rs_lineSpace, "lineSpace", "lsp", "number",
-        "number of extra pixels between rows"),
+              STRG(Rs_lineSpace, "lineSpace", "lsp", "number",
+                   "number of extra pixels between rows"),
 #endif
-    STRG(Rs_scrollBar_thickness, "thickness", "sbt", "number",
-        "scrollbar thickness/width in pixels"),
+              STRG(Rs_scrollBar_thickness, "thickness", "sbt", "number",
+                   "scrollbar thickness/width in pixels"),
 #ifdef POINTER_BLANK
-    RSTRG(Rs_pointerBlankDelay, "pointerBlankDelay", "number"),
+              RSTRG(Rs_pointerBlankDelay, "pointerBlankDelay", "number"),
 #endif
 #ifndef NO_BACKSPACE_KEY
-    RSTRG(Rs_backspace_key, "backspacekey", "string"),
+              RSTRG(Rs_backspace_key, "backspacekey", "string"),
 #endif
 #ifndef NO_DELETE_KEY
-    RSTRG(Rs_delete_key, "deletekey", "string"),
+              RSTRG(Rs_delete_key, "deletekey", "string"),
 #endif
-    RSTRG(Rs_selectstyle, "selectstyle", "mode"),
-    RSTRG(Rs_scrollstyle, "scrollstyle", "mode"),
+              RSTRG(Rs_selectstyle, "selectstyle", "mode"),
+              RSTRG(Rs_scrollstyle, "scrollstyle", "mode"),
 #ifdef HAVE_SCROLLBARS
-    RSTRG(Rs_scrollBar_align, "scrollBar_align", "mode"),
+              RSTRG(Rs_scrollBar_align, "scrollBar_align", "mode"),
 #endif
 #ifdef PRINTPIPE
-    RSTRG(Rs_print_pipe, "print-pipe", "string"),
+              RSTRG(Rs_print_pipe, "print-pipe", "string"),
 #endif
 #if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
-    RSTRG(Rs_bigfont_key, "bigfont_key", "keysym"),
-    RSTRG(Rs_smallfont_key, "smallfont_key", "keysym"),
+              RSTRG(Rs_bigfont_key, "bigfont_key", "keysym"),
+              RSTRG(Rs_smallfont_key, "smallfont_key", "keysym"),
 #endif
-    STRG(Rs_modifier, "modifier", "mod", "modifier",
-        "meta modifier = alt|meta|hyper|super|mod1|...|mod5"),
-    INFO("xrm", "string", "X resource"),
+              STRG(Rs_modifier, "modifier", "mod", "modifier",
+                   "meta modifier = alt|meta|hyper|super|mod1|...|mod5"),
+              INFO("xrm", "string", "X resource"),
 #ifdef CUTCHAR_RESOURCE
-    RSTRG(Rs_cutchars, "cutchars", "string"),
+              RSTRG(Rs_cutchars, "cutchars", "string"),
 #endif                         /* CUTCHAR_RESOURCE */
 #ifdef ACS_ASCII
-    RSTRG(Rs_acs_chars, "acsChars", "string"),
+              RSTRG(Rs_acs_chars, "acsChars", "string"),
 #endif                         /* ACS_ASCII */
-    RSTRG(Rs_answerbackstring, "answerbackString", "string"),
-    INFO("e", "command arg ...", "command to execute")
-};
+              RSTRG(Rs_answerbackstring, "answerbackString", "string"),
+              INFO("e", "command arg ...", "command to execute")
+            };
 
 #undef INFO
 #undef STRG
@@ -276,81 +278,81 @@ static const struct {
 static const char releasestring[] = "Rxvt v" VERSION " - released: " DATE "\n";
 static const char optionsstring[] = "Options: "
 #if defined(XPM_BACKGROUND)
-    "XPM,"
+                                    "XPM,"
 #endif
 #if defined(TRANSPARENT)
-    "transparent,"
+                                    "transparent,"
 #endif
 #if defined(UTMP_SUPPORT)
-    "utmp,"
+                                    "utmp,"
 #endif
 #if defined(MENUBAR)
-    "menubar,"
+                                    "menubar,"
 #endif
 #if !defined(NO_FRILLS)
-    "frills,"
+                                    "frills,"
 #endif
 #if !defined(NO_LINESPACE)
-    "linespace,"
+                                    "linespace,"
 #endif
 #if defined(PREFER_24BIT)
-    "24bit,"
+                                    "24bit,"
 #endif
 #if defined(USE_XIM)
-    "XIM,"
+                                    "XIM,"
 #endif
 #if defined(MULTICHAR_SET)
-    "multichar_languages,"
+                                    "multichar_languages,"
 #endif
-    "scrollbars="
+                                    "scrollbars="
 #if !defined(HAVE_SCROLLBARS)
-    "NONE"
+                                    "NONE"
 #else
 # if defined(RXVT_SCROLLBAR)
-    "rxvt"
+                                    "rxvt"
 #  if defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR)
-    "+"
+                                    "+"
 #  endif
 # endif
 # if defined(NEXT_SCROLLBAR)
-    "NeXT"
+                                    "NeXT"
 #  if defined(XTERM_SCROLLBAR)
-    "+"
+                                    "+"
 #  endif
 # endif
 # if defined(XTERM_SCROLLBAR)
-    "xterm"
+                                    "xterm"
 # endif
 #endif
-    ","
+                                    ","
 #if defined(GREEK_SUPPORT)
-    "Greek,"
+                                    "Greek,"
 #endif
 #if defined(RXVT_GRAPHICS)
-    "graphics,"
+                                    "graphics,"
 #endif
 #if defined(NO_BACKSPACE_KEY)
-    "no_backspace,"
+                                    "no_backspace,"
 #endif
 #if defined(NO_DELETE_KEY)
-    "no_delete,"
+                                    "no_delete,"
 #endif
 #if !defined(NO_STRINGS)
-    "strings,"
+                                    "strings,"
 #endif
 #if defined(TTY_256COLOR)
-    "256colour,"
+                                    "256colour,"
 #endif
 #if defined(NO_RESOURCES)
-    "NoResources"
+                                    "NoResources"
 #else
 # if defined(USE_XGETDEFAULT)
-    "XGetDefaults"
+                                    "XGetDefaults"
 # else
-    ".Xdefaults"
+                                    ".Xdefaults"
 # endif
 #endif
-    "\nUsage: ";               /* Usage */
+                                    "\nUsage: ";               /* Usage */
 
 #define INDENT 18
 
@@ -359,83 +361,88 @@ static const char optionsstring[] = "Options: "
 static void
 rxvt_usage(int type)
 {
-    unsigned int    i, col;
-
-    write(STDERR_FILENO, releasestring, sizeof(releasestring) - 1);
-    write(STDERR_FILENO, optionsstring, sizeof(optionsstring) - 1);
-    write(STDERR_FILENO, APL_NAME, sizeof(APL_NAME) - 1);
-
-    switch (type) {
-    case 0:                    /* brief listing */
-       fprintf(stderr, " [-help] [--help]\n");
-       for (col = 1, i = 0; i < optList_size(); i++)
-           if (optList[i].desc != NULL) {
-               int             len = 0;
-
-               if (!optList_isBool(i)) {
-                   len = optList_strlen(i);
-                   if (len > 0)
-                       len++;  /* account for space */
-               }
+  unsigned int    i, col;
+
+  write(STDERR_FILENO, releasestring, sizeof(releasestring) - 1);
+  write(STDERR_FILENO, optionsstring, sizeof(optionsstring) - 1);
+  write(STDERR_FILENO, APL_NAME, sizeof(APL_NAME) - 1);
+
+  switch (type)
+    {
+      case 0:                  /* brief listing */
+        fprintf(stderr, " [-help] [--help]\n");
+        for (col = 1, i = 0; i < optList_size(); i++)
+          if (optList[i].desc != NULL)
+            {
+              int             len = 0;
+
+              if (!optList_isBool(i))
+                {
+                  len = optList_strlen(i);
+                  if (len > 0)
+                    len++;     /* account for space */
+                }
 #ifdef DEBUG_STRICT
-               assert(optList[i].opt != NULL);
-#endif
-               len += 4 + STRLEN(optList[i].opt) + (optList_isBool(i) ? 2: 0);
-               col += len;
-               if (col > 79) { /* assume regular width */
-                   putc('\n', stderr);
-                   col = 1 + len;
-               }
-               fprintf(stderr, " [-%s%s", (optList_isBool(i) ? "/+" : ""),
-                       optList[i].opt);
-               if (optList_strlen(i))
-                   fprintf(stderr, " %s]", optList[i].arg);
-               else
-                   fprintf(stderr, "]");
-           }
-       break;
-
-    case 1:                    /* full command-line listing */
-       fprintf(stderr, " [options] [-e command args]\n\n"
-               "where options include:\n");
-       for (i = 0; i < optList_size(); i++)
-           if (optList[i].desc != NULL) {
+              assert(optList[i].opt != NULL);
+#endif
+              len += 4 + STRLEN(optList[i].opt) + (optList_isBool(i) ? 2: 0);
+              col += len;
+              if (col > 79)
+                {      /* assume regular width */
+                  putc('\n', stderr);
+                  col = 1 + len;
+                }
+              fprintf(stderr, " [-%s%s", (optList_isBool(i) ? "/+" : ""),
+                      optList[i].opt);
+              if (optList_strlen(i))
+                fprintf(stderr, " %s]", optList[i].arg);
+              else
+                fprintf(stderr, "]");
+            }
+        break;
+
+      case 1:                  /* full command-line listing */
+        fprintf(stderr, " [options] [-e command args]\n\n"
+                "where options include:\n");
+        for (i = 0; i < optList_size(); i++)
+          if (optList[i].desc != NULL)
+            {
 #ifdef DEBUG_STRICT
-               assert(optList[i].opt != NULL);
-#endif
-               fprintf(stderr, "  %s%s %-*s%s%s\n",
-                       (optList_isBool(i) ? "-/+" : "-"), optList[i].opt,
-                       (INDENT - STRLEN(optList[i].opt)
-                        + (optList_isBool(i) ? 0 : 2)),
-                       (optList[i].arg ? optList[i].arg : ""),
-                       (optList_isBool(i) ? "turn on/off " : ""),
-                       optList[i].desc);
-           }
-       fprintf(stderr, "\n  --help to list long-options");
-       break;
-
-    case 2:                    /* full resource listing */
-       fprintf(stderr,
-               " [options] [-e command args]\n\n"
-               "where resources (long-options) include:\n");
-
-       for (i = 0; i < optList_size(); i++)
-           if (optList[i].kw != NULL)
-               fprintf(stderr, "  %s: %*s%s\n",
-                       optList[i].kw,
-                       (INDENT - STRLEN(optList[i].kw)), "", /* XXX */
-                       (optList_isBool(i) ? "boolean" : optList[i].arg));
+              assert(optList[i].opt != NULL);
+#endif
+              fprintf(stderr, "  %s%s %-*s%s%s\n",
+                      (optList_isBool(i) ? "-/+" : "-"), optList[i].opt,
+                      (INDENT - STRLEN(optList[i].opt)
+                       + (optList_isBool(i) ? 0 : 2)),
+                      (optList[i].arg ? optList[i].arg : ""),
+                      (optList_isBool(i) ? "turn on/off " : ""),
+                      optList[i].desc);
+            }
+        fprintf(stderr, "\n  --help to list long-options");
+        break;
+
+      case 2:                  /* full resource listing */
+        fprintf(stderr,
+                " [options] [-e command args]\n\n"
+                "where resources (long-options) include:\n");
+
+        for (i = 0; i < optList_size(); i++)
+          if (optList[i].kw != NULL)
+            fprintf(stderr, "  %s: %*s%s\n",
+                    optList[i].kw,
+                    (INDENT - STRLEN(optList[i].kw)), "", /* XXX */
+                    (optList_isBool(i) ? "boolean" : optList[i].arg));
 #ifdef KEYSYM_RESOURCE
-       fprintf(stderr, "  " "keysym.sym" ": %*s%s\n",
-               (INDENT - sizeof("keysym.sym") + 1), "", /* XXX */
-               "keysym");
+        fprintf(stderr, "  " "keysym.sym" ": %*s%s\n",
+                (INDENT - sizeof("keysym.sym") + 1), "", /* XXX */
+                "keysym");
 #endif
-       fprintf(stderr, "\n  -help to list options");
-       break;
+        fprintf(stderr, "\n  -help to list options");
+        break;
     }
-    fprintf(stderr, "\n\n");
-    exit(EXIT_FAILURE);
-    /* NOTREACHED */
+  fprintf(stderr, "\n\n");
+  exit(EXIT_FAILURE);
+  /* NOTREACHED */
 }
 
 /*}}} */
@@ -444,97 +451,112 @@ rxvt_usage(int type)
 void
 rxvt_term::get_options (int argc, const char *const *argv)
 {
-    int             i, bad_option = 0;
-    static const char On[3] = "ON", Off[4] = "OFF";
+  int             i, bad_option = 0;
+  static const char On[3] = "ON", Off[4] = "OFF";
 
-    for (i = 1; i < argc; i++) {
-       unsigned int    entry, longopt = 0;
-       const char     *flag, *opt;
+  for (i = 1; i < argc; i++)
+    {
+      unsigned int    entry, longopt = 0;
+      const char     *flag, *opt;
 
-       opt = argv[i];
+      opt = argv[i];
 #ifdef DEBUG_RESOURCES
-       fprintf(stderr, "argv[%d] = %s: ", i, opt);
-#endif
-       if (*opt == '-') {
-           flag = On;
-           if (*++opt == '-')
-               longopt = *opt++;       /* long option */
-       } else if (*opt == '+') {
-           flag = Off;
-           if (*++opt == '+')
-               longopt = *opt++;       /* long option */
-       } else {
-           bad_option = 1;
-           rxvt_print_error("bad option \"%s\"", opt);
-           continue;
-       }
-
-       if (!STRCMP(opt, "help"))
-           rxvt_usage(longopt ? 2 : 1);
-       if (!STRCMP(opt, "h"))
-           rxvt_usage(0);
-
-       /* feature: always try to match long-options */
-       for (entry = 0; entry < optList_size(); entry++)
-           if ((optList[entry].kw && !STRCMP(opt, optList[entry].kw))
-               || (!longopt
-                   && optList[entry].opt && !STRCMP(opt, optList[entry].opt)))
-               break;
-
-       if (entry < optList_size()) {
-           if (optList_isReverse(entry))
-               flag = flag == On ? Off : On;
-           if (optList_strlen(entry)) {        /* string value */
-               const char     *str = argv[++i];
+      fprintf(stderr, "argv[%d] = %s: ", i, opt);
+#endif
+      if (*opt == '-')
+        {
+          flag = On;
+          if (*++opt == '-')
+            longopt = *opt++;  /* long option */
+        }
+      else if (*opt == '+')
+        {
+          flag = Off;
+          if (*++opt == '+')
+            longopt = *opt++;  /* long option */
+        }
+      else
+        {
+          bad_option = 1;
+          rxvt_print_error("bad option \"%s\"", opt);
+          continue;
+        }
+
+      if (!STRCMP(opt, "help"))
+        rxvt_usage(longopt ? 2 : 1);
+      if (!STRCMP(opt, "h"))
+        rxvt_usage(0);
+
+      /* feature: always try to match long-options */
+      for (entry = 0; entry < optList_size(); entry++)
+        if ((optList[entry].kw && !STRCMP(opt, optList[entry].kw))
+            || (!longopt
+                && optList[entry].opt && !STRCMP(opt, optList[entry].opt)))
+          break;
+
+      if (entry < optList_size())
+        {
+          if (optList_isReverse(entry))
+            flag = flag == On ? Off : On;
+          if (optList_strlen(entry))
+            {  /* string value */
+              const char     *str = argv[++i];
 
 #ifdef DEBUG_RESOURCES
-               fprintf(stderr, "string (%s,%s) = ",
-                       optList[entry].opt ? optList[entry].opt : "nil",
-                       optList[entry].kw ? optList[entry].kw : "nil");
+              fprintf(stderr, "string (%s,%s) = ",
+                      optList[entry].opt ? optList[entry].opt : "nil",
+                      optList[entry].kw ? optList[entry].kw : "nil");
 #endif
-               if (flag == On && str && (optList[entry].doff != -1)) {
+              if (flag == On && str && (optList[entry].doff != -1))
+                {
 #ifdef DEBUG_RESOURCES
-                   fprintf(stderr, "\"%s\"\n", str);
-#endif
-                   rs[optList[entry].doff] = str;
-                   /*
-                    * special cases are handled in main.c:main() to allow
-                    * X resources to set these values before we settle for
-                    * default values
-                    */
-               }
+                  fprintf(stderr, "\"%s\"\n", str);
+#endif
+                  rs[optList[entry].doff] = str;
+                  /*
+                   * special cases are handled in main.c:main() to allow
+                   * X resources to set these values before we settle for
+                   * default values
+                   */
+                }
 #ifdef DEBUG_RESOURCES
-               else
-                   fprintf(stderr, "???\n");
+              else
+                fprintf(stderr, "???\n");
 #endif
-           } else {            /* boolean value */
+
+            }
+          else
+            {          /* boolean value */
 #ifdef DEBUG_RESOURCES
-               fprintf(stderr, "boolean (%s,%s) = %s\n",
-                       optList[entry].opt, optList[entry].kw, flag);
-#endif
-               if (flag == On)
-                   Options |= (optList[entry].flag);
-               else
-                   Options &= ~(optList[entry].flag);
-
-               if (optList[entry].doff != -1)
-                   rs[optList[entry].doff] = flag;
-           }
-       } else
+              fprintf(stderr, "boolean (%s,%s) = %s\n",
+                      optList[entry].opt, optList[entry].kw, flag);
+#endif
+              if (flag == On)
+                Options |= (optList[entry].flag);
+              else
+                Options &= ~(optList[entry].flag);
+
+              if (optList[entry].doff != -1)
+                rs[optList[entry].doff] = flag;
+            }
+        }
+      else
 #ifdef KEYSYM_RESOURCE
-           /* if (!STRNCMP(opt, "keysym.", sizeof("keysym.") - 1)) */
-       if (rxvt_Str_match(opt, "keysym.")) {
-           const char     *str = argv[++i];
-
-           if (str != NULL)
-               parse_keysym (opt + sizeof("keysym.") - 1, str);
-       } else
+        /* if (!STRNCMP(opt, "keysym.", sizeof("keysym.") - 1)) */
+        if (rxvt_Str_match(opt, "keysym."))
+          {
+            const char     *str = argv[++i];
+
+            if (str != NULL)
+              parse_keysym (opt + sizeof("keysym.") - 1, str);
+          }
+        else
 #endif
           bad_option = 1;
     }
 
-    if (bad_option)
-       rxvt_usage(0);
+  if (bad_option)
+    rxvt_usage(0);
 }
 
 /*}}} */
@@ -553,13 +575,13 @@ rxvt_term::get_options (int argc, const char *const *argv)
 bool
 rxvt_define_key(XrmDatabase *database __attribute__((unused)), XrmBindingList bindings __attribute__((unused)), XrmQuarkList quarks, XrmRepresentation *type __attribute__((unused)), XrmValue *value, XPointer closure __attribute__((unused)))
 {
-    int             last;
+  int             last;
 
-    for (last = 0; quarks[last] != NULLQUARK; last++)  /* look for last quark in list */
-       ;
-    last--;
-    GET_R->parse_keysym (XrmQuarkToString(quarks[last]), (char *)value->addr);//D//TODO
-    return False;
+  for (last = 0; quarks[last] != NULLQUARK; last++)    /* look for last quark in list */
+    ;
+  last--;
+  GET_R->parse_keysym (XrmQuarkToString(quarks[last]), (char *)value->addr);//D//TODO
+  return False;
 }
 
 /*
@@ -574,68 +596,77 @@ rxvt_define_key(XrmDatabase *database __attribute__((unused)), XrmBindingList bi
 int
 rxvt_term::parse_keysym (const char *str, const char *arg)
 {
-    int             n, sym;
-    char           *key_string, *newarg = NULL;
-    char            newargstr[NEWARGLIM];
-
-    if (arg == NULL) {
-       if ((n = rxvt_Str_match(str, "keysym.")) == 0)
-           return 0;
-       str += n;               /* skip `keysym.' */
+  int             n, sym;
+  char           *key_string, *newarg = NULL;
+  char            newargstr[NEWARGLIM];
+
+  if (arg == NULL)
+    {
+      if ((n = rxvt_Str_match(str, "keysym.")) == 0)
+        return 0;
+      str += n;                /* skip `keysym.' */
     }
-/* some scanf() have trouble with a 0x prefix */
-    if (isdigit(str[0])) {
-       if (str[0] == '0' && toupper(str[1]) == 'X')
-           str += 2;
-       if (arg) {
-           if (sscanf(str, (STRCHR(str, ':') ? "%x:" : "%x"), &sym) != 1)
-               return -1;
-       } else {
-           if (sscanf(str, "%x:", &sym) != 1)
-               return -1;
-
-           /* cue to ':', it's there since sscanf() worked */
-           STRNCPY(newargstr, STRCHR(str, ':') + 1, NEWARGLIM - 1);
-           newargstr[NEWARGLIM - 1] = '\0';
-           newarg = newargstr;
-       }
-    } else {
-       /*
-        * convert keysym name to keysym number
-        */
-       STRNCPY(newargstr, str, NEWARGLIM - 1);
-       newargstr[NEWARGLIM - 1] = '\0';
-       if (arg == NULL) {
-           if ((newarg = STRCHR(newargstr, ':')) == NULL)
-               return -1;
-           *newarg++ = '\0';   /* terminate keysym name */
-       }
-       if ((sym = XStringToKeysym(newargstr)) == None)
-           return -1;
+  /* some scanf() have trouble with a 0x prefix */
+  if (isdigit(str[0]))
+    {
+      if (str[0] == '0' && toupper(str[1]) == 'X')
+        str += 2;
+      if (arg)
+        {
+          if (sscanf(str, (STRCHR(str, ':') ? "%x:" : "%x"), &sym) != 1)
+            return -1;
+        }
+      else
+        {
+          if (sscanf(str, "%x:", &sym) != 1)
+            return -1;
+
+          /* cue to ':', it's there since sscanf() worked */
+          STRNCPY(newargstr, STRCHR(str, ':') + 1, NEWARGLIM - 1);
+          newargstr[NEWARGLIM - 1] = '\0';
+          newarg = newargstr;
+        }
+    }
+  else
+    {
+      /*
+       * convert keysym name to keysym number
+       */
+      STRNCPY(newargstr, str, NEWARGLIM - 1);
+      newargstr[NEWARGLIM - 1] = '\0';
+      if (arg == NULL)
+        {
+          if ((newarg = STRCHR(newargstr, ':')) == NULL)
+            return -1;
+          *newarg++ = '\0';    /* terminate keysym name */
+        }
+      if ((sym = XStringToKeysym(newargstr)) == None)
+        return -1;
     }
 
-    if (sym < 0xFF00 || sym > 0xFFFF)  /* we only do extended keys */
-       return -1;
-    sym &= 0xFF;
-    if (Keysym_map[sym] != NULL)       /* already set ? */
-       return -1;
+  if (sym < 0xFF00 || sym > 0xFFFF)    /* we only do extended keys */
+    return -1;
+  sym &= 0xFF;
+  if (Keysym_map[sym] != NULL) /* already set ? */
+    return -1;
 
-    if (newarg == NULL) {
-       STRNCPY(newargstr, arg, NEWARGLIM - 1);
-       newargstr[NEWARGLIM - 1] = '\0';
-       newarg = newargstr;
+  if (newarg == NULL)
+    {
+      STRNCPY(newargstr, arg, NEWARGLIM - 1);
+      newargstr[NEWARGLIM - 1] = '\0';
+      newarg = newargstr;
     }
-    rxvt_Str_trim(newarg);
-    if (*newarg == '\0' || (n = rxvt_Str_escaped(newarg)) == 0)
-       return -1;
-    MIN_IT(n, 255);
-    key_string = (char *)rxvt_malloc((n + 1) * sizeof(char));
+  rxvt_Str_trim(newarg);
+  if (*newarg == '\0' || (n = rxvt_Str_escaped(newarg)) == 0)
+    return -1;
+  MIN_IT(n, 255);
+  key_string = (char *)rxvt_malloc((n + 1) * sizeof(char));
 
-    key_string[0] = n;
-    STRNCPY(key_string + 1, newarg, n);
-    Keysym_map[sym] = (unsigned char *)key_string;
+  key_string[0] = n;
+  STRNCPY(key_string + 1, newarg, n);
+  Keysym_map[sym] = (unsigned char *)key_string;
 
-    return 1;
+  return 1;
 }
 
 # endif                                /* KEYSYM_RESOURCE */
@@ -648,62 +679,67 @@ rxvt_term::parse_keysym (const char *str, const char *arg)
 void
 rxvt_term::get_xdefaults (FILE *stream, const char *name)
 {
-    unsigned int    len;
-    char           *str, buffer[256];
+  unsigned int    len;
+  char           *str, buffer[256];
 
-    if (stream == NULL)
-       return;
-    len = STRLEN(name);
-    while ((str = fgets(buffer, sizeof(buffer), stream)) != NULL) {
-       unsigned int    entry, n;
+  if (stream == NULL)
+    return;
+  len = STRLEN(name);
+  while ((str = fgets(buffer, sizeof(buffer), stream)) != NULL)
+    {
+      unsigned int    entry, n;
 
-       while (*str && isspace(*str))
-           str++;              /* leading whitespace */
+      while (*str && isspace(*str))
+        str++;         /* leading whitespace */
 
-       if ((str[len] != '*' && str[len] != '.')
-           || (len && STRNCMP(str, name, len)))
-           continue;
-       str += (len + 1);       /* skip `name*' or `name.' */
+      if ((str[len] != '*' && str[len] != '.')
+          || (len && STRNCMP(str, name, len)))
+        continue;
+      str += (len + 1);        /* skip `name*' or `name.' */
 
 # ifdef KEYSYM_RESOURCE
-       if (!parse_keysym (str, NULL))
+      if (!parse_keysym (str, NULL))
 # endif                                /* KEYSYM_RESOURCE */
-           for (entry = 0; entry < optList_size(); entry++) {
-               const char     *kw = optList[entry].kw;
-
-               if (kw == NULL)
-                   continue;
-               n = STRLEN (kw);
-               if (str[n] == ':' && rxvt_Str_match(str, kw)) {
-                   /* skip `keyword:' */
-                   str += (n + 1);
-                   rxvt_Str_trim(str);
-                   n = STRLEN(str);
-                   if (n && rs[optList[entry].doff] == NULL) {
-                       /* not already set */
-                       int             s;
-                       char           *p = (char *)rxvt_malloc((n + 1) * sizeof(char));
-
-                       STRCPY(p, str);
-                       rs[optList[entry].doff] = p;
-                       if (optList_isBool(entry)) {
-                           s = STRCASECMP(str, "TRUE") == 0
-                               || STRCASECMP(str, "YES") == 0
-                               || STRCASECMP(str, "ON") == 0
-                               || STRCASECMP(str, "1") == 0;
-                           if (optList_isReverse(entry))
-                               s = !s;
-                           if (s)
-                               Options |= (optList[entry].flag);
-                           else
-                               Options &= ~(optList[entry].flag);
-                       }
-                   }
-                   break;
-               }
-           }
+        for (entry = 0; entry < optList_size(); entry++)
+          {
+            const char     *kw = optList[entry].kw;
+
+            if (kw == NULL)
+              continue;
+            n = STRLEN (kw);
+            if (str[n] == ':' && rxvt_Str_match(str, kw))
+              {
+                /* skip `keyword:' */
+                str += (n + 1);
+                rxvt_Str_trim(str);
+                n = STRLEN(str);
+                if (n && rs[optList[entry].doff] == NULL)
+                  {
+                    /* not already set */
+                    int             s;
+                    char           *p = (char *)rxvt_malloc((n + 1) * sizeof(char));
+
+                    STRCPY(p, str);
+                    rs[optList[entry].doff] = p;
+                    if (optList_isBool(entry))
+                      {
+                        s = STRCASECMP(str, "TRUE") == 0
+                            || STRCASECMP(str, "YES") == 0
+                            || STRCASECMP(str, "ON") == 0
+                            || STRCASECMP(str, "1") == 0;
+                        if (optList_isReverse(entry))
+                          s = !s;
+                        if (s)
+                          Options |= (optList[entry].flag);
+                        else
+                          Options &= ~(optList[entry].flag);
+                      }
+                  }
+                break;
+              }
+          }
     }
-    rewind(stream);
+  rewind(stream);
 }
 
 /*}}} */
@@ -722,24 +758,25 @@ rxvt_term::extract_resources (Display *display __attribute__((unused)), const ch
 
 # if defined XAPPLOADDIR
 #  if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
-    /* Compute the path of the possibly available localized Rxvt file */ 
-    char           *localepath = NULL;
-
-    if (locale != NULL) {      /* XXX: must limit length of string */
-       localepath = (char *)rxvt_malloc(256); 
-       sprintf(localepath, XAPPLOADDIRLOCALE "/" APL_SUBCLASS,
-               (int)(258 - sizeof(XAPPLOADDIRLOCALE) - sizeof(APL_SUBCLASS)),
-               locale);        /* 258 = 255 + 4 (-.*s) - 1 (/) */
+  /* Compute the path of the possibly available localized Rxvt file */
+  char           *localepath = NULL;
+
+  if (locale != NULL)
+    {  /* XXX: must limit length of string */
+      localepath = (char *)rxvt_malloc(256);
+      sprintf(localepath, XAPPLOADDIRLOCALE "/" APL_SUBCLASS,
+              (int)(258 - sizeof(XAPPLOADDIRLOCALE) - sizeof(APL_SUBCLASS)),
+              locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */
     }
 
-    {
+  {
 #  endif
 # endif
 
 # ifdef USE_XGETDEFAULT
-/*
- * get resources using the X library function
- */
+    /*
    * get resources using the X library function
    */
     int             entry;
 
 #  ifdef XrmEnumOneLevel
@@ -753,99 +790,107 @@ rxvt_term::extract_resources (Display *display __attribute__((unused)), const ch
     XrmInitialize();
     database = NULL;
 
-/* Get any Xserver defaults */
+    /* Get any Xserver defaults */
 
     displayResource = XResourceManagerString(display);
     if (displayResource != NULL)
-       database = XrmGetStringDatabase(displayResource);
+      database = XrmGetStringDatabase(displayResource);
 
 #   ifdef HAVE_EXTRA_XRESOURCE_FILES
-/* Add in ~/.Xdefaults or ~/.Xresources */
+    /* Add in ~/.Xdefaults or ~/.Xresources */
     {
-       char           *ptr;
-
-       if ((ptr = (char *)getenv("HOME")) == NULL)
-           ptr = ".";
-
-       for (i = 0; i < (sizeof(xnames) / sizeof(xnames[0])); i++) {
-           sprintf(fname, "%-.*s/%s", sizeof(fname) - STRLEN(xnames[i]) - 2,
-                   ptr, xnames[i]);
-           if ((rdb1 = XrmGetFileDatabase(fname)) != NULL) {
-               XrmMergeDatabases(rdb1, &database);
+      char           *ptr;
+
+      if ((ptr = (char *)getenv("HOME")) == NULL)
+        ptr = ".";
+
+      for (i = 0; i < (sizeof(xnames) / sizeof(xnames[0])); i++)
+        {
+          sprintf(fname, "%-.*s/%s", sizeof(fname) - STRLEN(xnames[i]) - 2,
+                  ptr, xnames[i]);
+          if ((rdb1 = XrmGetFileDatabase(fname)) != NULL)
+            {
+              XrmMergeDatabases(rdb1, &database);
 #    ifndef HAVE_BOTH_XRESOURCE_FILES
-               break;
+              break;
 #    endif
-           }
-       }
+
+            }
+        }
     }
 #   endif
 
-/* Add in XENVIRONMENT file */
+    /* Add in XENVIRONMENT file */
 
     if ((xe = (char *)getenv("XENVIRONMENT")) != NULL
-       && (rdb1 = XrmGetFileDatabase(xe)) != NULL)
-       XrmMergeDatabases(rdb1, &database);
+        && (rdb1 = XrmGetFileDatabase(xe)) != NULL)
+      XrmMergeDatabases(rdb1, &database);
 
-/* Add in Rxvt file */
+    /* Add in Rxvt file */
 #   if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
     if (localepath == NULL || (rdb1 = XrmGetFileDatabase(localepath)) == NULL)
 #   endif
-    rdb1 = XrmGetFileDatabase(XAPPLOADDIR "/" APL_SUBCLASS);
+      rdb1 = XrmGetFileDatabase(XAPPLOADDIR "/" APL_SUBCLASS);
     if (rdb1 != NULL)
-        XrmMergeDatabases(rdb1, &database);
-
-/* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */
-    if ((xe = (char *)getenv("XAPPLRESDIR")) != NULL) {
-       sprintf(fname, "%-.*s/" APL_SUBCLASS, sizeof(fname)
-               - sizeof(APL_SUBCLASS) - 2, xe);
-       if ((rdb1 = XrmGetFileDatabase(fname)) != NULL)
-           XrmMergeDatabases(rdb1, &database);
-    }
+      XrmMergeDatabases(rdb1, &database);
+
+    /* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */
+    if ((xe = (char *)getenv("XAPPLRESDIR")) != NULL)
+      {
+        sprintf(fname, "%-.*s/" APL_SUBCLASS, sizeof(fname)
+                - sizeof(APL_SUBCLASS) - 2, xe);
+        if ((rdb1 = XrmGetFileDatabase(fname)) != NULL)
+          XrmMergeDatabases(rdb1, &database);
+      }
 
     XrmSetDatabase(display, database);
 #  endif
 
-/*
- * Query resources for options that affect us
- */
-    for (entry = 0; entry < optList_size(); entry++) {
-       int             s;
-       char           *p, *p0;
-       const char     *kw = optList[entry].kw;
-
-       if (kw == NULL || rs[optList[entry].doff] != NULL)
-           continue;           /* previously set */
-
-       p = XGetDefault(display, name, kw);
-       p0 = XGetDefault(display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw);
-       if (p == NULL || (p0 && STRCMP(p, p0) == 0)) {
-           p = XGetDefault(display, APL_SUBCLASS, kw);
-           if (p == NULL || (p0 && STRCMP(p, p0) == 0))
-               p = XGetDefault(display, APL_CLASS, kw);
-       }
-       if (p == NULL && p0)
-           p = p0;
-       if (p) {
-           rs[optList[entry].doff] = p;
-
-           if (optList_isBool(entry)) {
-               s = STRCASECMP(p, "TRUE") == 0
-                   || STRCASECMP(p, "YES") == 0
-                   || STRCASECMP(p, "ON") == 0
-                   || STRCASECMP(p, "1") == 0;
-               if (optList_isReverse(entry))
-                   s = !s;
-               if (s)
-                   Options |= (optList[entry].flag);
-               else
-                   Options &= ~(optList[entry].flag);
-           }
-       }
-    }
-
-/*
- * [R5 or later]: enumerate the resource database
- */
+    /*
+     * Query resources for options that affect us
+     */
+    for (entry = 0; entry < optList_size(); entry++)
+      {
+        int             s;
+        char           *p, *p0;
+        const char     *kw = optList[entry].kw;
+
+        if (kw == NULL || rs[optList[entry].doff] != NULL)
+          continue;            /* previously set */
+
+        p = XGetDefault(display, name, kw);
+        p0 = XGetDefault(display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw);
+        if (p == NULL || (p0 && STRCMP(p, p0) == 0))
+          {
+            p = XGetDefault(display, APL_SUBCLASS, kw);
+            if (p == NULL || (p0 && STRCMP(p, p0) == 0))
+              p = XGetDefault(display, APL_CLASS, kw);
+          }
+        if (p == NULL && p0)
+          p = p0;
+        if (p)
+          {
+            rs[optList[entry].doff] = p;
+
+            if (optList_isBool(entry))
+              {
+                s = STRCASECMP(p, "TRUE") == 0
+                    || STRCASECMP(p, "YES") == 0
+                    || STRCASECMP(p, "ON") == 0
+                    || STRCASECMP(p, "1") == 0;
+                if (optList_isReverse(entry))
+                  s = !s;
+                if (s)
+                  Options |= (optList[entry].flag);
+                else
+                  Options &= ~(optList[entry].flag);
+              }
+          }
+      }
+
+    /*
+     * [R5 or later]: enumerate the resource database
+     */
 #  ifdef XrmEnumOneLevel
 #   ifdef KEYSYM_RESOURCE
     name_prefix[0] = XrmStringToName(name);
@@ -854,132 +899,139 @@ rxvt_term::extract_resources (Display *display __attribute__((unused)), const ch
     class_prefix[0] = XrmStringToName(APL_SUBCLASS);
     class_prefix[1] = XrmStringToName("Keysym");
     class_prefix[2] = NULLQUARK;
-/* XXX: Need to check sizeof(rxvt_t) == sizeof(XPointer) */
+    /* XXX: Need to check sizeof(rxvt_t) == sizeof(XPointer) */
     XrmEnumerateDatabase(XrmGetDatabase(display), name_prefix, class_prefix,
-                        XrmEnumOneLevel, rxvt_define_key, NULL);
+                         XrmEnumOneLevel, rxvt_define_key, NULL);
     name_prefix[0] = XrmStringToName(APL_CLASS);
     name_prefix[1] = XrmStringToName("keysym");
     class_prefix[0] = XrmStringToName(APL_CLASS);
     class_prefix[1] = XrmStringToName("Keysym");
-/* XXX: Need to check sizeof(rxvt_t) == sizeof(XPointer) */
+    /* XXX: Need to check sizeof(rxvt_t) == sizeof(XPointer) */
     XrmEnumerateDatabase(XrmGetDatabase(display), name_prefix, class_prefix,
-                        XrmEnumOneLevel, rxvt_define_key, NULL);
+                         XrmEnumOneLevel, rxvt_define_key, NULL);
 #   endif
 #  endif
 
 # else                         /* USE_XGETDEFAULT */
-/* get resources the hard way, but save lots of memory */
+    /* get resources the hard way, but save lots of memory */
     FILE           *fd = NULL;
     char           *home;
 
-    if ((home = getenv("HOME")) != NULL) {
-       unsigned int    i, len = STRLEN(home) + 2;
-       char           *f = NULL;
-
-       for (i = 0; i < (sizeof(xnames) / sizeof(xnames[0])); i++) {
-           f = (char *)rxvt_realloc(f, (len + STRLEN(xnames[i])) * sizeof(char));
-
-           sprintf(f, "%s/%s", home, xnames[i]);
-
-           if ((fd = fopen(f, "r")) != NULL)
-               break;
-       }
-       free(f);
-    }
-/*
- * The normal order to match resources is the following:
- * @ global resources (partial match, ~/.Xdefaults)
- * @ application file resources (XAPPLOADDIR/Rxvt)
- * @ class resources (~/.Xdefaults)
- * @ private resources (~/.Xdefaults)
- *
- * However, for the hand-rolled resources, the matching algorithm
- * checks if a resource string value has already been allocated
- * and won't overwrite it with (in this case) a less specific
- * resource value.
- *
- * This avoids multiple allocation.  Also, when we've called this
- * routine command-line string options have already been applied so we
- * needn't to allocate for those resources.
- *
- * So, search in resources from most to least specific.
- *
- * Also, use a special sub-class so that we can use either or both of
- * "XTerm" and "Rxvt" as class names.
- */
+    if ((home = getenv("HOME")) != NULL)
+      {
+        unsigned int    i, len = STRLEN(home) + 2;
+        char           *f = NULL;
+
+        for (i = 0; i < (sizeof(xnames) / sizeof(xnames[0])); i++)
+          {
+            f = (char *)rxvt_realloc(f, (len + STRLEN(xnames[i])) * sizeof(char));
+
+            sprintf(f, "%s/%s", home, xnames[i]);
+
+            if ((fd = fopen(f, "r")) != NULL)
+              break;
+          }
+        free(f);
+      }
+    /*
+    * The normal order to match resources is the following:
+    * @ global resources (partial match, ~/.Xdefaults)
+    * @ application file resources (XAPPLOADDIR/Rxvt)
+    * @ class resources (~/.Xdefaults)
+    * @ private resources (~/.Xdefaults)
+    *
+    * However, for the hand-rolled resources, the matching algorithm
+    * checks if a resource string value has already been allocated
+    * and won't overwrite it with (in this case) a less specific
+    * resource value.
+    *
+    * This avoids multiple allocation.  Also, when we've called this
+    * routine command-line string options have already been applied so we
+    * needn't to allocate for those resources.
+    *
+    * So, search in resources from most to least specific.
+    *
+    * Also, use a special sub-class so that we can use either or both of
+    * "XTerm" and "Rxvt" as class names.
+    */
 
     get_xdefaults (fd, name);
     get_xdefaults (fd, APL_SUBCLASS);
 
 #  if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR)
+
     {
-       FILE           *ad = NULL;
+      FILE           *ad = NULL;
 
 #   if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
-       if (localepath == NULL || (ad = fopen(localepath, "r")) == NULL)
+      if (localepath == NULL || (ad = fopen(localepath, "r")) == NULL)
 #   endif
-       ad = fopen(XAPPLOADDIR "/" APL_SUBCLASS, "r");
-       if (ad != NULL) {
-           get_xdefaults (ad, APL_SUBCLASS);
-           get_xdefaults (ad, "");
-           fclose(ad);
-       }
+        ad = fopen(XAPPLOADDIR "/" APL_SUBCLASS, "r");
+      if (ad != NULL)
+        {
+          get_xdefaults (ad, APL_SUBCLASS);
+          get_xdefaults (ad, "");
+          fclose(ad);
+        }
     }
 #  endif                       /* XAPPLOADDIR */
 
     get_xdefaults (fd, APL_CLASS);
     get_xdefaults (fd, "");    /* partial match */
     if (fd != NULL)
-       fclose(fd);
+      fclose(fd);
 # endif                                /* USE_XGETDEFAULT */
 
 # if defined XAPPLOADDIR
 #  if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
-    }
 
-    /* Free the path of the possibly available localized Rxvt file */ 
-    free(localepath);
+  }
+
+  /* Free the path of the possibly available localized Rxvt file */
+  free(localepath);
 #  endif
 # endif
 
 #endif                         /* NO_RESOURCES */
 
-/*
- * even without resources, at least do this setup for command-line
- * options and command-line long options
- */
+  /*
  * even without resources, at least do this setup for command-line
  * options and command-line long options
  */
 #ifdef MULTICHAR_SET
-    set_multichar_encoding (rs[Rs_multichar_encoding]);
+  set_multichar_encoding (rs[Rs_multichar_encoding]);
 #endif
 #ifdef GREEK_SUPPORT
-/* this could be a function in grkelot.c */
-/* void set_greek_keyboard (const char * str); */
-    if (rs[Rs_greek_keyboard]) {
-       if (!STRCMP(rs[Rs_greek_keyboard], "iso"))
-           greek_setmode(GREEK_ELOT928);       /* former -grk9 */
-       else if (!STRCMP(rs[Rs_greek_keyboard], "ibm"))
-           greek_setmode(GREEK_IBM437);        /* former -grk4 */
-    }
+  /* this could be a function in grkelot.c */
+  /* void set_greek_keyboard (const char * str); */
+  if (rs[Rs_greek_keyboard])
     {
-       KeySym          sym;
-
-       if (rs[Rs_greektoggle_key]
-           && ((sym = XStringToKeysym(rs[Rs_greektoggle_key])) != 0))
-           ks_greekmodeswith = sym;
+      if (!STRCMP(rs[Rs_greek_keyboard], "iso"))
+        greek_setmode(GREEK_ELOT928);  /* former -grk9 */
+      else if (!STRCMP(rs[Rs_greek_keyboard], "ibm"))
+        greek_setmode(GREEK_IBM437);   /* former -grk4 */
     }
+  {
+    KeySym          sym;
+
+    if (rs[Rs_greektoggle_key]
+        && ((sym = XStringToKeysym(rs[Rs_greektoggle_key])) != 0))
+      ks_greekmodeswith = sym;
+  }
 #endif                         /* GREEK_SUPPORT */
 
 #if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
-    {
-       KeySym          sym;
-
-       if (rs[Rs_bigfont_key]
-           && ((sym = XStringToKeysym(rs[Rs_bigfont_key])) != 0))
-           ks_bigfont = sym;
-       if (rs[Rs_smallfont_key]
-           && ((sym = XStringToKeysym(rs[Rs_smallfont_key])) != 0))
-           ks_smallfont = sym;
-    }
+
+  {
+    KeySym          sym;
+
+    if (rs[Rs_bigfont_key]
+        && ((sym = XStringToKeysym(rs[Rs_bigfont_key])) != 0))
+      ks_bigfont = sym;
+    if (rs[Rs_smallfont_key]
+        && ((sym = XStringToKeysym(rs[Rs_smallfont_key])) != 0))
+      ks_smallfont = sym;
+  }
 #endif
 }
 
index 77e0608..273273c 100644 (file)
--- a/src/xpm.C
+++ b/src/xpm.C
@@ -1,7 +1,7 @@
 /*--------------------------------*-C-*---------------------------------*
  * File:       xpm.c
  *----------------------------------------------------------------------*
- * $Id: xpm.C,v 1.6 2004-01-31 02:15:02 pcg Exp $
+ * $Id: xpm.C,v 1.7 2004-02-01 01:34:41 pcg Exp $
  *
  * All portions of code are copyright by their respective author/s.
  * Copyright (c) 1997      Carsten Haitzler <raster@zip.com.au>
 int
 rxvt_term::scale_pixmap (const char *geom)
 {
-    int             flags, changed = 0;
-    int             x = 0, y = 0;
-    unsigned int    w = 0, h = 0;
-    unsigned int    n;
-    char           *p, *str;
-    bgPixmap_t     *bgpixmap = &(bgPixmap);
+  int             flags, changed = 0;
+  int             x = 0, y = 0;
+  unsigned int    w = 0, h = 0;
+  unsigned int    n;
+  char           *p, *str;
+  bgPixmap_t     *bgpixmap = &(bgPixmap);
 
 #define MAXLEN_GEOM            sizeof("[1000x1000+1000+1000]")
 
-    if (geom == NULL)
-       return 0;
-    str = (char *)rxvt_malloc (MAXLEN_GEOM + 1);
-    if (!STRCMP(geom, "?")) {
-       sprintf(str, "[%dx%d+%d+%d]",   /* can't presume snprintf() ! */
-               min(bgpixmap->w, 9999), min(bgpixmap->h, 9999),
-               min(bgpixmap->x, 9999), min(bgpixmap->y, 9999));
-       xterm_seq (XTerm_title, str, CHAR_ST);
-       free(str);
-       return 0;
+  if (geom == NULL)
+    return 0;
+  str = (char *)rxvt_malloc (MAXLEN_GEOM + 1);
+  if (!STRCMP(geom, "?"))
+    {
+      sprintf(str, "[%dx%d+%d+%d]",    /* can't presume snprintf() ! */
+              min(bgpixmap->w, 9999), min(bgpixmap->h, 9999),
+              min(bgpixmap->x, 9999), min(bgpixmap->y, 9999));
+      xterm_seq (XTerm_title, str, CHAR_ST);
+      free(str);
+      return 0;
     }
 
-    if ((p = STRCHR(geom, ';')) == NULL)
-       p = STRCHR(geom, '\0');
-    n = (p - geom);
-    if (n <= MAXLEN_GEOM) {
-       STRNCPY(str, geom, n);
-       str[n] = '\0';
-
-       flags = XParseGeometry(str, &x, &y, &w, &h);
-       if (!flags) {
-           flags |= WidthValue;
-           w = 0;
-       }                       /* default is tile */
-       if (flags & WidthValue) {
-           if (!(flags & XValue))
-               x = 50;
-           if (!(flags & HeightValue))
-               h = w;
-           if (w && !h) {
-               w = (bgpixmap->w * w) / 100;
-               h = bgpixmap->h;
-           } else if (h && !w) {
-               w = bgpixmap->w;
-               h = (bgpixmap->h * h) / 100;
-           }
-           if (w > 1000)
-               w = 1000;
-           if (h > 1000)
-               h = 1000;
-           if (bgpixmap->w != (short)w) {
-               bgpixmap->w = (short)w;
-               changed++;
-           }
-           if (bgpixmap->h != (short)h) {
-               bgpixmap->h = (short)h;
-               changed++;
-           }
-       }
-       if (!(flags & YValue)) {
-           if (flags & XNegative)
-               flags |= YNegative;
-           y = x;
-       }
-
-       if (!(flags & WidthValue) && geom[0] != '=') {
-           x += bgpixmap->x;
-           y += bgpixmap->y;
-       } else {
-           if (flags & XNegative)
-               x += 100;
-           if (flags & YNegative)
-               y += 100;
-       }
-       MIN_IT(x, 100);
-       MIN_IT(y, 100);
-       MAX_IT(x, 0);
-       MAX_IT(y, 0);
-       if (bgpixmap->x != x) {
-           bgpixmap->x = x;
-           changed++;
-       }
-       if (bgpixmap->y != y) {
-           bgpixmap->y = y;
-           changed++;
-       }
+  if ((p = STRCHR(geom, ';')) == NULL)
+    p = STRCHR(geom, '\0');
+  n = (p - geom);
+  if (n <= MAXLEN_GEOM)
+    {
+      STRNCPY(str, geom, n);
+      str[n] = '\0';
+
+      flags = XParseGeometry(str, &x, &y, &w, &h);
+      if (!flags)
+        {
+          flags |= WidthValue;
+          w = 0;
+        }                      /* default is tile */
+      if (flags & WidthValue)
+        {
+          if (!(flags & XValue))
+            x = 50;
+          if (!(flags & HeightValue))
+            h = w;
+          if (w && !h)
+            {
+              w = (bgpixmap->w * w) / 100;
+              h = bgpixmap->h;
+            }
+          else if (h && !w)
+            {
+              w = bgpixmap->w;
+              h = (bgpixmap->h * h) / 100;
+            }
+          if (w > 1000)
+            w = 1000;
+          if (h > 1000)
+            h = 1000;
+          if (bgpixmap->w != (short)w)
+            {
+              bgpixmap->w = (short)w;
+              changed++;
+            }
+          if (bgpixmap->h != (short)h)
+            {
+              bgpixmap->h = (short)h;
+              changed++;
+            }
+        }
+      if (!(flags & YValue))
+        {
+          if (flags & XNegative)
+            flags |= YNegative;
+          y = x;
+        }
+
+      if (!(flags & WidthValue) && geom[0] != '=')
+        {
+          x += bgpixmap->x;
+          y += bgpixmap->y;
+        }
+      else
+        {
+          if (flags & XNegative)
+            x += 100;
+          if (flags & YNegative)
+            y += 100;
+        }
+      MIN_IT(x, 100);
+      MIN_IT(y, 100);
+      MAX_IT(x, 0);
+      MAX_IT(y, 0);
+      if (bgpixmap->x != x)
+        {
+          bgpixmap->x = x;
+          changed++;
+        }
+      if (bgpixmap->y != y)
+        {
+          bgpixmap->y = y;
+          changed++;
+        }
     }
-    free(str);
-    return changed;
+  free(str);
+  return changed;
 }
 
 void
 rxvt_term::resize_pixmap ()
 {
-    XGCValues       gcvalue;
-    GC              gc;
-    unsigned int    width = TermWin_TotalWidth();
-    unsigned int    height = TermWin_TotalHeight();
-
-    if (TermWin.pixmap != None)
-       XFreePixmap(Xdisplay, TermWin.pixmap);
-
-    if (bgPixmap.pixmap == None) { /* So be it: I'm not using pixmaps */
-       TermWin.pixmap = None;
-       if (!(Options & Opt_transparent) || am_transparent == 0)
-           XSetWindowBackground(Xdisplay, TermWin.vt,
-                                PixColors[Color_bg]);
-       return;
+  XGCValues       gcvalue;
+  GC              gc;
+  unsigned int    width = TermWin_TotalWidth();
+  unsigned int    height = TermWin_TotalHeight();
+
+  if (TermWin.pixmap != None)
+    XFreePixmap(Xdisplay, TermWin.pixmap);
+
+  if (bgPixmap.pixmap == None)
+    { /* So be it: I'm not using pixmaps */
+      TermWin.pixmap = None;
+      if (!(Options & Opt_transparent) || am_transparent == 0)
+        XSetWindowBackground(Xdisplay, TermWin.vt,
+                             PixColors[Color_bg]);
+      return;
     }
 
-    gcvalue.foreground = PixColors[Color_bg];
-    gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground, &gcvalue);
-
-    if (bgPixmap.pixmap != None) {     /* we have a specified pixmap */
-       unsigned int    w = bgPixmap.w, h = bgPixmap.h,
-                       x = bgPixmap.x, y = bgPixmap.y;
-        unsigned int    xpmh = xpmAttr.height,
-                       xpmw = xpmAttr.width;
-
-       /*
-        * don't zoom pixmap too much nor expand really small pixmaps
-        */
-       if (w > 1000 || h > 1000)
-           w = 1;
-       else if (width > (10 * xpmw)
-                || height > (10 * xpmh))
-           w = 0;              /* tile */
-
-       if (w == 0) {
-           /* basic X tiling - let the X server do it */
-           TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt,
-                                             xpmw, xpmh,
-                                             (unsigned int)XDEPTH);
-           XCopyArea(Xdisplay, bgPixmap.pixmap, TermWin.pixmap, gc,
-                     0, 0, xpmw, xpmh, 0, 0);
-       } else {
-           float           incr, p;
-           Pixmap          tmp;
-
-           TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt,
-                                             width, height,
-                                             (unsigned int)XDEPTH);
-           /*
-            * horizontal scaling
-            */
-           rxvt_pixmap_incr(&w, &x, &incr, &p, width, xpmw);
-
-           tmp = XCreatePixmap(Xdisplay, TermWin.vt,
-                               width, xpmh, (unsigned int)XDEPTH);
-           XFillRectangle(Xdisplay, tmp, gc, 0, 0, width,
-                          xpmh);
-
-           for ( /*nil */ ; x < w; x++, p += incr) {
-               if (p >= xpmw)
-                   p = 0;
-               /* copy one column from the original pixmap to the tmp pixmap */
-               XCopyArea(Xdisplay, bgPixmap.pixmap, tmp, gc,
-                         (int)p, 0, 1, xpmh, (int)x, 0);
-           }
-
-           /*
-            * vertical scaling
-            */
-           rxvt_pixmap_incr(&h, &y, &incr, &p, height, xpmh);
-
-           if (y > 0)
-               XFillRectangle(Xdisplay, TermWin.pixmap, gc, 0, 0, width,
-                              y);
-           if (h < height)
-               XFillRectangle(Xdisplay, TermWin.pixmap, gc, 0, (int)h,
-                              width, height - h + 1);
-           for ( /*nil */ ; y < h; y++, p += incr) {
-               if (p >= xpmh)
-                   p = 0;
-               /* copy one row from the tmp pixmap to the main pixmap */
-               XCopyArea(Xdisplay, tmp, TermWin.pixmap, gc,
-                         0, (int)p, width, 1, 0, (int)y);
-           }
-           XFreePixmap(Xdisplay, tmp);
-       }
+  gcvalue.foreground = PixColors[Color_bg];
+  gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground, &gcvalue);
+
+  if (bgPixmap.pixmap != None)
+    {  /* we have a specified pixmap */
+      unsigned int    w = bgPixmap.w, h = bgPixmap.h,
+                                          x = bgPixmap.x, y = bgPixmap.y;
+      unsigned int    xpmh = xpmAttr.height,
+                             xpmw = xpmAttr.width;
+
+      /*
+       * don't zoom pixmap too much nor expand really small pixmaps
+       */
+      if (w > 1000 || h > 1000)
+        w = 1;
+      else if (width > (10 * xpmw)
+               || height > (10 * xpmh))
+        w = 0;         /* tile */
+
+      if (w == 0)
+        {
+          /* basic X tiling - let the X server do it */
+          TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt,
+                                         xpmw, xpmh,
+                                         (unsigned int)XDEPTH);
+          XCopyArea(Xdisplay, bgPixmap.pixmap, TermWin.pixmap, gc,
+                    0, 0, xpmw, xpmh, 0, 0);
+        }
+      else
+        {
+          float           incr, p;
+          Pixmap          tmp;
+
+          TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt,
+                                         width, height,
+                                         (unsigned int)XDEPTH);
+          /*
+           * horizontal scaling
+           */
+          rxvt_pixmap_incr(&w, &x, &incr, &p, width, xpmw);
+
+          tmp = XCreatePixmap(Xdisplay, TermWin.vt,
+                              width, xpmh, (unsigned int)XDEPTH);
+          XFillRectangle(Xdisplay, tmp, gc, 0, 0, width,
+                         xpmh);
+
+          for ( /*nil */ ; x < w; x++, p += incr)
+            {
+              if (p >= xpmw)
+                p = 0;
+              /* copy one column from the original pixmap to the tmp pixmap */
+              XCopyArea(Xdisplay, bgPixmap.pixmap, tmp, gc,
+                        (int)p, 0, 1, xpmh, (int)x, 0);
+            }
+
+          /*
+           * vertical scaling
+           */
+          rxvt_pixmap_incr(&h, &y, &incr, &p, height, xpmh);
+
+          if (y > 0)
+            XFillRectangle(Xdisplay, TermWin.pixmap, gc, 0, 0, width,
+                           y);
+          if (h < height)
+            XFillRectangle(Xdisplay, TermWin.pixmap, gc, 0, (int)h,
+                           width, height - h + 1);
+          for ( /*nil */ ; y < h; y++, p += incr)
+            {
+              if (p >= xpmh)
+                p = 0;
+              /* copy one row from the tmp pixmap to the main pixmap */
+              XCopyArea(Xdisplay, tmp, TermWin.pixmap, gc,
+                        0, (int)p, width, 1, 0, (int)y);
+            }
+          XFreePixmap(Xdisplay, tmp);
+        }
     }
-    XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt, TermWin.pixmap);
-    XFreeGC(Xdisplay, gc);
-    am_transparent = 0;
+  XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt, TermWin.pixmap);
+  XFreeGC(Xdisplay, gc);
+  am_transparent = 0;
 
-    XClearWindow(Xdisplay, TermWin.vt);
+  XClearWindow(Xdisplay, TermWin.vt);
 
-    XSync(Xdisplay, False);
+  XSync(Xdisplay, False);
 }
 
 /*
@@ -249,110 +271,125 @@ rxvt_term::resize_pixmap ()
 static void
 rxvt_pixmap_incr(unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight)
 {
-    unsigned int    cwh, cxy;
-    float           cincr, cp;
-
-    cp = 0;
-    cincr = (float)xpmwidthheight;
-    cxy = *xy;
-    cwh = *wh;
-    if (cwh == 1) {    /* display one image, no horizontal/vertical scaling */
-       cincr = (float)widthheight;
-       if (xpmwidthheight <= widthheight) {
-           cwh = xpmwidthheight;
-           cxy = (cxy * (widthheight - cwh)) / 100;    /* beware! order */
-           cwh += cxy;
-       } else {
-           cxy = 0;
-           cwh = widthheight;
-       }
-    } else if (cwh < 10) {     /* fit WH images across/down screen */
-       cincr *= cwh;
-       cxy = 0;
-       cwh = widthheight;
-    } else {
-       cincr *= 100.0 / cwh;
-       if (cwh < 100) {        /* contract */
-           float           pos;
-
-           cwh = (cwh * widthheight) / 100;
-           pos = (float)cxy / 100 * widthheight - (cwh / 2);
-
-           cxy = (widthheight - cwh);
-           if (pos <= 0)
-               cxy = 0;
-           else if (pos < cxy)
-               cxy = (int) pos;
-           cwh += cxy;
-       } else {        /* expand */
-           if (cxy > 0) {      /* position */
-               float           pos;
-
-               pos = (float)cxy / 100 * xpmwidthheight - (cincr / 2);
-               cp = xpmwidthheight - cincr;
-               if (pos <= 0)
-                   cp = 0;
-               else if (pos < cp)
-                   cp = pos;
-           }
-           cxy = 0;
-           cwh = widthheight;
-       }
+  unsigned int    cwh, cxy;
+  float           cincr, cp;
+
+  cp = 0;
+  cincr = (float)xpmwidthheight;
+  cxy = *xy;
+  cwh = *wh;
+  if (cwh == 1)
+    {  /* display one image, no horizontal/vertical scaling */
+      cincr = (float)widthheight;
+      if (xpmwidthheight <= widthheight)
+        {
+          cwh = xpmwidthheight;
+          cxy = (cxy * (widthheight - cwh)) / 100;     /* beware! order */
+          cwh += cxy;
+        }
+      else
+        {
+          cxy = 0;
+          cwh = widthheight;
+        }
     }
-    cincr /= widthheight;
-    *wh = cwh;
-    *xy = cxy;
-    *incr = cincr;
-    *p = cp;
+  else if (cwh < 10)
+    {  /* fit WH images across/down screen */
+      cincr *= cwh;
+      cxy = 0;
+      cwh = widthheight;
+    }
+  else
+    {
+      cincr *= 100.0 / cwh;
+      if (cwh < 100)
+        {      /* contract */
+          float           pos;
+
+          cwh = (cwh * widthheight) / 100;
+          pos = (float)cxy / 100 * widthheight - (cwh / 2);
+
+          cxy = (widthheight - cwh);
+          if (pos <= 0)
+            cxy = 0;
+          else if (pos < cxy)
+            cxy = (int) pos;
+          cwh += cxy;
+        }
+      else
+        {      /* expand */
+          if (cxy > 0)
+            {  /* position */
+              float           pos;
+
+              pos = (float)cxy / 100 * xpmwidthheight - (cincr / 2);
+              cp = xpmwidthheight - cincr;
+              if (pos <= 0)
+                cp = 0;
+              else if (pos < cp)
+                cp = pos;
+            }
+          cxy = 0;
+          cwh = widthheight;
+        }
+    }
+  cincr /= widthheight;
+  *wh = cwh;
+  *xy = cxy;
+  *incr = cincr;
+  *p = cp;
 }
 
 Pixmap
 rxvt_term::set_bgPixmap (const char *file)
 {
-    char           *f;
+  char           *f;
 
-    assert(file != NULL);
+  assert(file != NULL);
 
-    if (bgPixmap.pixmap != None) {
-       XFreePixmap(Xdisplay, bgPixmap.pixmap);
-       bgPixmap.pixmap = None;
+  if (bgPixmap.pixmap != None)
+    {
+      XFreePixmap(Xdisplay, bgPixmap.pixmap);
+      bgPixmap.pixmap = None;
     }
-    XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[Color_bg]);
-
-    if (*file != '\0') {
-/*      XWindowAttributes attr; */
-
-       /*
-        * we already have the required attributes
-        */
-/*      XGetWindowAttributes(Xdisplay, TermWin.vt, &attr); */
-
-       xpmAttr.closeness = 30000;
-       xpmAttr.colormap = XCMAP;
-       xpmAttr.visual = XVISUAL;
-       xpmAttr.depth = XDEPTH;
-       xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual |
-                                  XpmDepth | XpmSize | XpmReturnPixels);
-
-       /* search environment variables here too */
-       f = (char *)rxvt_File_find(file, ".xpm", rs[Rs_path]);
-       if (f == NULL
-           || XpmReadFileToPixmap(Xdisplay, Xroot, f,
-                                  &bgPixmap.pixmap, NULL,
-                                  &xpmAttr)) {
-           char           *p;
-
-           /* semi-colon delimited */
-           if ((p = STRCHR(file, ';')) == NULL)
-               p = STRCHR(file, '\0');
-
-           rxvt_print_error("couldn't load XPM file \"%.*s\"", (p - file),
-                            file);
-       }
-       free(f);
+  XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[Color_bg]);
+
+  if (*file != '\0')
+    {
+      /*      XWindowAttributes attr; */
+
+      /*
+       * we already have the required attributes
+       */
+      /*      XGetWindowAttributes(Xdisplay, TermWin.vt, &attr); */
+
+      xpmAttr.closeness = 30000;
+      xpmAttr.colormap = XCMAP;
+      xpmAttr.visual = XVISUAL;
+      xpmAttr.depth = XDEPTH;
+      xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual |
+                           XpmDepth | XpmSize | XpmReturnPixels);
+
+      /* search environment variables here too */
+      f = (char *)rxvt_File_find(file, ".xpm", rs[Rs_path]);
+      if (f == NULL
+          || XpmReadFileToPixmap(Xdisplay, Xroot, f,
+                                 &bgPixmap.pixmap, NULL,
+                                 &xpmAttr))
+        {
+          char           *p;
+
+          /* semi-colon delimited */
+          if ((p = STRCHR(file, ';')) == NULL)
+            p = STRCHR(file, '\0');
+
+          rxvt_print_error("couldn't load XPM file \"%.*s\"", (p - file),
+                           file);
+        }
+      free(f);
     }
-    resize_pixmap ();
-    return bgPixmap.pixmap;
+  resize_pixmap ();
+  return bgPixmap.pixmap;
 }
 
 #endif                         /* XPM_BACKGROUND */